Skip to content

Commit b47b2fa

Browse files
authored
Merge pull request #5841 from benoit-pierre/fix_python_src/pip
fix support for invoking pip using `python src/pip ...`
2 parents d490f75 + 464b2f3 commit b47b2fa

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

news/5841.bugfix

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix support for invoking pip using `python src/pip ...`.

src/pip/_internal/build_env.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
from pip._vendor.pkg_resources import Requirement, VersionConflict, WorkingSet
1212

13+
from pip import __file__ as pip_location
1314
from pip._internal.utils.misc import call_subprocess
1415
from pip._internal.utils.temp_dir import TempDirectory
1516
from pip._internal.utils.ui import open_spinner
@@ -103,8 +104,9 @@ def missing_requirements(self, reqs):
103104

104105
def install_requirements(self, finder, requirements, message):
105106
args = [
106-
sys.executable, '-m', 'pip', 'install', '--ignore-installed',
107-
'--no-user', '--prefix', self.path, '--no-warn-script-location',
107+
sys.executable, os.path.dirname(pip_location), 'install',
108+
'--ignore-installed', '--no-user', '--prefix', self.path,
109+
'--no-warn-script-location',
108110
]
109111
if logger.getEffectiveLevel() <= logging.DEBUG:
110112
args.append('-v')

tests/functional/test_install.py

+13
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ def test_pep518_uses_build_env(script, data, common_wheels, command, variant):
3737
)
3838

3939

40+
def test_pep518_build_env_uses_same_pip(script, data, pip_src, common_wheels):
41+
"""Ensure the subprocess call to pip for installing the
42+
build dependencies is using the same version of pip.
43+
"""
44+
with open(script.scratch_path / 'pip.py', 'w') as fp:
45+
fp.write('raise ImportError')
46+
script.run(
47+
'python', pip_src / 'src/pip', 'install', '--no-index',
48+
'-f', common_wheels, '-f', data.packages,
49+
data.src.join("pep518-3.0"),
50+
)
51+
52+
4053
def test_pep518_refuses_invalid_requires(script, data, common_wheels):
4154
result = script.pip(
4255
'install', '-f', common_wheels,

0 commit comments

Comments
 (0)