Skip to content

Commit

Permalink
fix support for invoking pip using python src/pip ...
Browse files Browse the repository at this point in the history
Ensure the subprocess call to pip for installing the PEP 518
build dependencies is using the same version of pip.
  • Loading branch information
benoit-pierre committed Oct 2, 2018
1 parent b6bbabe commit 464b2f3
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
1 change: 1 addition & 0 deletions news/5841.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix support for invoking pip using `python src/pip ...`.
6 changes: 4 additions & 2 deletions src/pip/_internal/build_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
13 changes: 13 additions & 0 deletions tests/functional/test_install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 464b2f3

Please sign in to comment.