Skip to content

Commit be13cf9

Browse files
authored
Merge pull request #7258 from takluyver/use-user-site-int
Allow for use_user_site being set to an integer
2 parents ab91924 + f92efc0 commit be13cf9

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

news/284c23de-df0b-4aaa-8454-4569829768fc.trivial

Whitespace-only changes.

src/pip/_internal/commands/install.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,13 @@ def decide_user_install(
616616
If use_user_site is None, the default behaviour depends on the environment,
617617
which is provided by the other arguments.
618618
"""
619-
if use_user_site is False:
619+
# In some cases (config from tox), use_user_site can be set to an integer
620+
# rather than a bool, which 'use_user_site is False' wouldn't catch.
621+
if (use_user_site is not None) and (not use_user_site):
620622
logger.debug("Non-user install by explicit request")
621623
return False
622624

623-
if use_user_site is True:
625+
if use_user_site:
624626
if prefix_path:
625627
raise CommandError(
626628
"Can not combine '--user' and '--prefix' as they imply "

tests/functional/test_install.py

+14
Original file line numberDiff line numberDiff line change
@@ -1586,6 +1586,20 @@ def test_target_install_ignores_distutils_config_install_prefix(script):
15861586
assert relative_script_base not in result.files_created
15871587

15881588

1589+
def test_user_config_accepted(script):
1590+
# user set in the config file is parsed as 0/1 instead of True/False.
1591+
# Check that this doesn't cause a problem.
1592+
config_file = script.scratch_path / 'pip.conf'
1593+
script.environ['PIP_CONFIG_FILE'] = str(config_file)
1594+
config_file.write_text("[install]\nuser = true")
1595+
result = script.pip_install_local('simplewheel')
1596+
1597+
assert "Successfully installed simplewheel" in result.stdout
1598+
1599+
relative_user = os.path.relpath(script.user_site_path, script.base_path)
1600+
assert join(relative_user, 'simplewheel') in result.files_created
1601+
1602+
15891603
@pytest.mark.network
15901604
@pytest.mark.skipif("sys.platform != 'win32'")
15911605
@pytest.mark.parametrize('pip_name', [

0 commit comments

Comments
 (0)