Skip to content

Commit

Permalink
Merge pull request #5116 from pfmoore/issue5085
Browse files Browse the repository at this point in the history
Fix for issue 5085 (--user set in config causes pip wheel to fail)
  • Loading branch information
pfmoore authored Mar 26, 2018
2 parents eb62a44 + 54c4456 commit d6e050a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 1 deletion.
1 change: 1 addition & 0 deletions news/5085.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add a ``--no-user`` option and use it when installing build dependencies.
6 changes: 6 additions & 0 deletions src/pip/_internal/commands/install.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import operator
import os
import shutil
from optparse import SUPPRESS_HELP

from pip._internal import cmdoptions
from pip._internal.basecommand import RequirementCommand
Expand Down Expand Up @@ -83,6 +84,11 @@ def __init__(self, *args, **kw):
"platform. Typically ~/.local/, or %APPDATA%\\Python on "
"Windows. (See the Python documentation for site.USER_BASE "
"for full details.)")
cmd_opts.add_option(
'--no-user',
dest='use_user_site',
action='store_false',
help=SUPPRESS_HELP)
cmd_opts.add_option(
'--root',
dest='root_path',
Expand Down
2 changes: 1 addition & 1 deletion src/pip/_internal/operations/prepare.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def _install_build_reqs(finder, prefix, build_requirements):
]
args = [
sys.executable, '-m', 'pip', 'install', '--ignore-installed',
'--prefix', prefix,
'--no-user', '--prefix', prefix,
] + list(urls)

with open_spinner("Installing build dependencies") as spinner:
Expand Down
2 changes: 2 additions & 0 deletions tests/data/src/withpyproject/pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build-system]
requires = ["setuptools", "wheel"]
2 changes: 2 additions & 0 deletions tests/data/src/withpyproject/setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from setuptools import setup
setup(name='withpyproject', version='0.0.1')
12 changes: 12 additions & 0 deletions tests/functional/test_wheel.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,3 +236,15 @@ def test_pip_wheel_with_pep518_build_reqs_no_isolation(script, data):
assert wheel_file_path in result.files_created, result.stdout
assert "Successfully built pep518" in result.stdout, result.stdout
assert "Installing build dependencies" not in result.stdout, result.stdout


def test_pip_wheel_with_user_set_in_config(script, data):
script.pip('install', 'wheel')
script.pip('download', 'setuptools', 'wheel', '-d', data.packages)
config_file = script.scratch_path / 'pip.conf'
script.environ['PIP_CONFIG_FILE'] = str(config_file)
config_file.write("[install]\nuser = true")
result = script.pip(
'wheel', data.src / 'withpyproject',
)
assert "Successfully built withpyproject" in result.stdout, result.stdout

0 comments on commit d6e050a

Please sign in to comment.