Skip to content

Commit

Permalink
Merge pull request #6008 from jaraco/bugfix/4106-distutils-option-err…
Browse files Browse the repository at this point in the history
…or-target-prefix-conflict

Prevent distutils option error target prefix conflict
  • Loading branch information
pradyunsg authored May 25, 2019
2 parents 77da032 + da9caa4 commit 287aa4b
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/6008.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevent DistutilsOptionError when prefix is indicated in the global environment and `--target` is used.
3 changes: 2 additions & 1 deletion src/pip/_internal/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 19 additions & 0 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 287aa4b

Please sign in to comment.