From 464b2f30a8eccb7c28287a25ca699a4ce8887984 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Tue, 2 Oct 2018 12:00:19 +0200 Subject: [PATCH] fix support for invoking pip using `python src/pip ...` Ensure the subprocess call to pip for installing the PEP 518 build dependencies is using the same version of pip. --- news/5841.bugfix | 1 + src/pip/_internal/build_env.py | 6 ++++-- tests/functional/test_install.py | 13 +++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 news/5841.bugfix diff --git a/news/5841.bugfix b/news/5841.bugfix new file mode 100644 index 00000000000..ba6f9b28248 --- /dev/null +++ b/news/5841.bugfix @@ -0,0 +1 @@ +Fix support for invoking pip using `python src/pip ...`. diff --git a/src/pip/_internal/build_env.py b/src/pip/_internal/build_env.py index 673409d2645..1f48e33e924 100644 --- a/src/pip/_internal/build_env.py +++ b/src/pip/_internal/build_env.py @@ -9,6 +9,7 @@ from pip._vendor.pkg_resources import Requirement, VersionConflict, WorkingSet +from pip import __file__ as pip_location from pip._internal.utils.misc import call_subprocess from pip._internal.utils.temp_dir import TempDirectory from pip._internal.utils.ui import open_spinner @@ -93,8 +94,9 @@ def missing_requirements(self, reqs): def install_requirements(self, finder, requirements, message): args = [ - sys.executable, '-m', 'pip', 'install', '--ignore-installed', - '--no-user', '--prefix', self.path, '--no-warn-script-location', + sys.executable, os.path.dirname(pip_location), 'install', + '--ignore-installed', '--no-user', '--prefix', self.path, + '--no-warn-script-location', ] if logger.getEffectiveLevel() <= logging.DEBUG: args.append('-v') diff --git a/tests/functional/test_install.py b/tests/functional/test_install.py index 1be8e10e392..58743cd46f0 100644 --- a/tests/functional/test_install.py +++ b/tests/functional/test_install.py @@ -38,6 +38,19 @@ def test_pep518_uses_build_env(script, data, common_wheels, command, variant): ) +def test_pep518_build_env_uses_same_pip(script, data, pip_src, common_wheels): + """Ensure the subprocess call to pip for installing the + build dependencies is using the same version of pip. + """ + with open(script.scratch_path / 'pip.py', 'w') as fp: + fp.write('raise ImportError') + script.run( + 'python', pip_src / 'src/pip', 'install', '--no-index', + '-f', common_wheels, '-f', data.packages, + data.src.join("pep518-3.0"), + ) + + def test_pep518_refuses_invalid_requires(script, data, common_wheels): result = script.pip( 'install', '-f', common_wheels,