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
hexagonrecursion committed Mar 5, 2022
1 parent 94ee8d0 commit dc28730
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
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
8 changes: 3 additions & 5 deletions setuptools/tests/test_easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -1133,8 +1133,6 @@ def test_editable_install_honors_user_under_build_isolation(setup_context, monke

## Assert:
# Should not install to sys.prefix
with pytest.raises(AssertionError):
assert sys_prefix.listdir() == []
# Should install to site.USER_BASE
with pytest.raises(AssertionError):
assert (USER_BASE / 'lib').isdir()
assert sys_prefix.listdir() == []
# Should install to site.USER_BASE:
assert (USER_BASE / 'lib').isdir()

0 comments on commit dc28730

Please sign in to comment.