From 17e0d115e82fd195513b3a41736a13d122a5730b Mon Sep 17 00:00:00 2001
From: Paul Moore
Date: Sun, 25 Mar 2018 18:22:18 +0100
Subject: [PATCH 1/3] Fix for issue 5085 (--user set in config causes pip wheel
to fail)
---
src/pip/_internal/commands/install.py | 5 +++++
src/pip/_internal/operations/prepare.py | 2 +-
tests/data/src/withpyproject/pyproject.toml | 2 ++
tests/data/src/withpyproject/setup.py | 2 ++
tests/functional/test_wheel.py | 12 ++++++++++++
5 files changed, 22 insertions(+), 1 deletion(-)
create mode 100644 tests/data/src/withpyproject/pyproject.toml
create mode 100644 tests/data/src/withpyproject/setup.py
diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py
index c7dfb833dc5..92cb3fa54b6 100644
--- a/src/pip/_internal/commands/install.py
+++ b/src/pip/_internal/commands/install.py
@@ -83,6 +83,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="Do not install to the Python user install directory")
cmd_opts.add_option(
'--root',
dest='root_path',
diff --git a/src/pip/_internal/operations/prepare.py b/src/pip/_internal/operations/prepare.py
index 429b701724d..e2103a2b27b 100644
--- a/src/pip/_internal/operations/prepare.py
+++ b/src/pip/_internal/operations/prepare.py
@@ -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:
diff --git a/tests/data/src/withpyproject/pyproject.toml b/tests/data/src/withpyproject/pyproject.toml
new file mode 100644
index 00000000000..d1e6ae6e564
--- /dev/null
+++ b/tests/data/src/withpyproject/pyproject.toml
@@ -0,0 +1,2 @@
+[build-system]
+requires = ["setuptools", "wheel"]
diff --git a/tests/data/src/withpyproject/setup.py b/tests/data/src/withpyproject/setup.py
new file mode 100644
index 00000000000..326f7fd1e7b
--- /dev/null
+++ b/tests/data/src/withpyproject/setup.py
@@ -0,0 +1,2 @@
+from setuptools import setup
+setup(name='withpyproject', version='0.0.1')
diff --git a/tests/functional/test_wheel.py b/tests/functional/test_wheel.py
index a50811b115f..b83702599e1 100644
--- a/tests/functional/test_wheel.py
+++ b/tests/functional/test_wheel.py
@@ -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
From 87bb4f9c13d5a4f1c5b746670705ae044112f854 Mon Sep 17 00:00:00 2001
From: Paul Moore
Date: Mon, 26 Mar 2018 12:01:27 +0100
Subject: [PATCH 2/3] Hide --no-user option
---
src/pip/_internal/commands/install.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/pip/_internal/commands/install.py b/src/pip/_internal/commands/install.py
index 92cb3fa54b6..a8b4f5c13aa 100644
--- a/src/pip/_internal/commands/install.py
+++ b/src/pip/_internal/commands/install.py
@@ -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
@@ -87,7 +88,7 @@ def __init__(self, *args, **kw):
'--no-user',
dest='use_user_site',
action='store_false',
- help="Do not install to the Python user install directory")
+ help=SUPPRESS_HELP)
cmd_opts.add_option(
'--root',
dest='root_path',
From 54c4456cb7e4801a1a19c2469d78d7c261f7c438 Mon Sep 17 00:00:00 2001
From: Paul Moore
Date: Mon, 26 Mar 2018 12:17:51 +0100
Subject: [PATCH 3/3] Added a news file
---
news/5085.bugfix | 1 +
1 file changed, 1 insertion(+)
create mode 100644 news/5085.bugfix
diff --git a/news/5085.bugfix b/news/5085.bugfix
new file mode 100644
index 00000000000..831cb63b49c
--- /dev/null
+++ b/news/5085.bugfix
@@ -0,0 +1 @@
+Add a ``--no-user`` option and use it when installing build dependencies.
\ No newline at end of file