Skip to content

Commit 757deb1

Browse files
authored
Merge pull request #1941 from joreiff/pr-easyinstall
Make easy_install command less strict (fixes #1405)
2 parents 5d17586 + 6ee1a1c commit 757deb1

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

changelog.d/1941.change.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Improve editable installs with PEP 518 build isolation:
2+
3+
* The ``--user`` option is now always available. A warning is issued if the user site directory is not available.
4+
* The error shown when the install directory is not in ``PYTHONPATH`` has been turned into a warning.

setuptools/command/easy_install.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,16 @@ class easy_install(Command):
157157
"allow building eggs from local checkouts"),
158158
('version', None, "print version information and exit"),
159159
('no-find-links', None,
160-
"Don't load find-links defined in packages being installed")
160+
"Don't load find-links defined in packages being installed"),
161+
('user', None, "install in user site-package '%s'" % site.USER_SITE)
161162
]
162163
boolean_options = [
163164
'zip-ok', 'multi-version', 'exclude-scripts', 'upgrade', 'always-copy',
164165
'editable',
165-
'no-deps', 'local-snapshots-ok', 'version'
166+
'no-deps', 'local-snapshots-ok', 'version',
167+
'user'
166168
]
167169

168-
if site.ENABLE_USER_SITE:
169-
help_msg = "install in user site-package '%s'" % site.USER_SITE
170-
user_options.append(('user', None, help_msg))
171-
boolean_options.append('user')
172-
173170
negative_opt = {'always-unzip': 'zip-ok'}
174171
create_index = PackageIndex
175172

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

273+
elif self.user:
274+
log.warn("WARNING: The user site-packages directory is disabled.")
275+
276276
self._fix_install_dir_for_user_site()
277277

278278
self.expand_basedirs()
@@ -479,8 +479,9 @@ def check_site_dir(self):
479479
self.cant_write_to_target()
480480

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

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

1314-
def no_default_version_msg(self):
1315-
template = self.__no_default_msg
1316-
return template % (self.install_dir, os.environ.get('PYTHONPATH', ''))
1317-
13181315
def install_site_py(self):
13191316
"""Make sure there's a site.py in the target dir, if needed"""
13201317

0 commit comments

Comments
 (0)