Merge pull request #6008 from jaraco/bugfix/4106-distutils-option-error-target-prefix-conflict

Prevent distutils option error target prefix conflict
This commit is contained in:
Pradyun Gedam 2019-05-25 13:29:49 -04:00 committed by GitHub
commit 287aa4b7bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

1
news/6008.bugfix Normal file
View File

@ -0,0 +1 @@
Prevent DistutilsOptionError when prefix is indicated in the global environment and `--target` is used.

View File

@ -171,8 +171,9 @@ def distutils_scheme(dist_name, user=False, home=None, root=None,
# or user base for installations during finalize_options()
# ideally, we'd prefer a scheme class that has no side-effects.
assert not (user and prefix), "user={} prefix={}".format(user, prefix)
assert not (home and prefix), "home={} prefix={}".format(home, prefix)
i.user = user or i.user
if user:
if user or home:
i.prefix = ""
i.prefix = prefix or i.prefix
i.home = home or i.home

View File

@ -1503,3 +1503,22 @@ def test_install_conflict_warning_can_be_suppressed(script, data):
'install', '--no-index', pkgB_path, '--no-warn-conflicts'
)
assert "Successfully installed pkgB-2.0" in result2.stdout, str(result2)
def test_target_install_ignores_distutils_config_install_prefix(script):
prefix = script.scratch_path / 'prefix'
distutils_config = Path(os.path.expanduser('~'),
'pydistutils.cfg' if sys.platform == 'win32'
else '.pydistutils.cfg')
distutils_config.write(textwrap.dedent(
'''
[install]
prefix=%s
''' % str(prefix)))
target = script.scratch_path / 'target'
result = script.pip_install_local('simplewheel', '-t', target)
assert (
"Successfully installed simplewheel" in result.stdout and
(target - script.base_path) in result.files_created and
(prefix - script.base_path) not in result.files_created
), str(result)