Skip to content

Commit

Permalink
Merge pull request #1941 from joreiff/pr-easyinstall
Browse files Browse the repository at this point in the history
Make easy_install command less strict (fixes #1405)
  • Loading branch information
jaraco authored Feb 6, 2020
2 parents 5d17586 + 6ee1a1c commit 757deb1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
4 changes: 4 additions & 0 deletions changelog.d/1941.change.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Improve editable installs with PEP 518 build isolation:

* The ``--user`` option is now always available. A warning is issued if the user site directory is not available.
* The error shown when the install directory is not in ``PYTHONPATH`` has been turned into a warning.
23 changes: 10 additions & 13 deletions setuptools/command/easy_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,19 +157,16 @@ class easy_install(Command):
"allow building eggs from local checkouts"),
('version', None, "print version information and exit"),
('no-find-links', None,
"Don't load find-links defined in packages being installed")
"Don't load find-links defined in packages being installed"),
('user', None, "install in user site-package '%s'" % site.USER_SITE)
]
boolean_options = [
'zip-ok', 'multi-version', 'exclude-scripts', 'upgrade', 'always-copy',
'editable',
'no-deps', 'local-snapshots-ok', 'version'
'no-deps', 'local-snapshots-ok', 'version',
'user'
]

if site.ENABLE_USER_SITE:
help_msg = "install in user site-package '%s'" % site.USER_SITE
user_options.append(('user', None, help_msg))
boolean_options.append('user')

negative_opt = {'always-unzip': 'zip-ok'}
create_index = PackageIndex

Expand Down Expand Up @@ -273,6 +270,9 @@ def finalize_options(self):
self.config_vars['userbase'] = self.install_userbase
self.config_vars['usersite'] = self.install_usersite

elif self.user:
log.warn("WARNING: The user site-packages directory is disabled.")

self._fix_install_dir_for_user_site()

self.expand_basedirs()
Expand Down Expand Up @@ -479,8 +479,9 @@ def check_site_dir(self):
self.cant_write_to_target()

if not is_site_dir and not self.multi_version:
# Can't install non-multi to non-site dir
raise DistutilsError(self.no_default_version_msg())
# Can't install non-multi to non-site dir with easy_install
pythonpath = os.environ.get('PYTHONPATH', '')
log.warn(self.__no_default_msg, self.install_dir, pythonpath)

if is_site_dir:
if self.pth_file is None:
Expand Down Expand Up @@ -1311,10 +1312,6 @@ def byte_compile(self, to_compile):
Please make the appropriate changes for your system and try again.
""").strip()

def no_default_version_msg(self):
template = self.__no_default_msg
return template % (self.install_dir, os.environ.get('PYTHONPATH', ''))

def install_site_py(self):
"""Make sure there's a site.py in the target dir, if needed"""

Expand Down

0 comments on commit 757deb1

Please sign in to comment.