1
1
Fork 0
mirror of https://github.com/pypa/pip synced 2023-12-13 21:30:23 +01:00

Merge pull request #9883 from uranusjr/isolated-pip-py36-compat

Fallback to self-invoke via directory on 3.6
This commit is contained in:
Stéphane Bidoul 2021-04-29 09:13:15 +02:00 committed by GitHub
commit 999b121402
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

2
news/9878.bugfix.rst Normal file
View file

@ -0,0 +1,2 @@
Fix Python 3.6 compatibility when a PEP 517 build requirement itself needs to be
built in an isolated environment.

View file

@ -187,9 +187,17 @@ class BuildEnvironment:
prefix.setup = True
if not requirements:
return
with _create_standalone_pip() as standalone_pip:
with contextlib.ExitStack() as ctx:
# TODO: Remove this block when dropping 3.6 support. Python 3.6
# lacks importlib.resources and pep517 has issues loading files in
# a zip, so we fallback to the "old" method by adding the current
# pip directory to the child process's sys.path.
if sys.version_info < (3, 7):
pip_runnable = os.path.dirname(pip_location)
else:
pip_runnable = ctx.enter_context(_create_standalone_pip())
self._install_requirements(
standalone_pip,
pip_runnable,
finder,
requirements,
prefix,
@ -198,14 +206,14 @@ class BuildEnvironment:
@staticmethod
def _install_requirements(
standalone_pip: str,
pip_runnable: str,
finder: "PackageFinder",
requirements: Iterable[str],
prefix: _Prefix,
message: str,
) -> None:
args = [
sys.executable, standalone_pip, 'install',
sys.executable, pip_runnable, 'install',
'--ignore-installed', '--no-user', '--prefix', prefix.path,
'--no-warn-script-location',
] # type: List[str]