Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
Fix editable --user installs with build isolation
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Bienkowski committed Mar 6, 2022
1 parent 45340d0 commit b828c32
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
1 change: 1 addition & 0 deletions changelog.d/3151.breaking.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Made ``setup.py develop --user`` install to the user site packages directory even if it is disabled in the current interpreter.
18 changes: 6 additions & 12 deletions setuptools/command/easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,8 @@ def initialize_options(self):
self.install_data = None
self.install_base = None
self.install_platbase = None
if site.ENABLE_USER_SITE:
self.install_userbase = site.USER_BASE
self.install_usersite = site.USER_SITE
else:
self.install_userbase = None
self.install_usersite = None
self.install_userbase = site.USER_BASE
self.install_usersite = site.USER_SITE
self.no_find_links = None

# Options not specifiable via command line
Expand Down Expand Up @@ -253,11 +249,9 @@ def finalize_options(self): # noqa: C901 # is too complex (25) # FIXME
getattr(sys, 'windir', '').replace('.', ''),
)

if site.ENABLE_USER_SITE:
self.config_vars['userbase'] = self.install_userbase
self.config_vars['usersite'] = self.install_usersite

elif self.user:
self.config_vars['userbase'] = self.install_userbase
self.config_vars['usersite'] = self.install_usersite
if self.user and not site.ENABLE_USER_SITE:
log.warn("WARNING: The user site-packages directory is disabled.")

self._fix_install_dir_for_user_site()
Expand Down Expand Up @@ -373,7 +367,7 @@ def _fix_install_dir_for_user_site(self):
"""
Fix the install_dir if "--user" was used.
"""
if not self.user or not site.ENABLE_USER_SITE:
if not self.user:
return

self.create_home_path()
Expand Down
6 changes: 2 additions & 4 deletions setuptools/tests/test_easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -1146,8 +1146,6 @@ def test_editable_user_and_build_isolation(setup_context, monkeypatch, tmpdir):

# == Assert ==
# Should not install to sys.prefix
with pytest.raises(AssertionError):
assert sys_prefix.listdir() == []
assert sys_prefix.listdir() == []
# Should install to user site
with pytest.raises(AssertionError):
assert {f.basename for f in user_site.listdir()} == {'UNKNOWN.egg-link'}
assert {f.basename for f in user_site.listdir()} == {'UNKNOWN.egg-link'}

0 comments on commit b828c32

Please sign in to comment.