Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent distutils option error target prefix conflict #6008

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -156,8 +156,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 @@ -1473,3 +1473,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)