bpo-41490: Bump vendored pip to version 20.2.3 (#22527)

This commit is contained in:
Pablo Galindo 2020-10-04 17:45:31 +01:00 committed by GitHub
parent a619af43cc
commit 2cc6dc9896
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 17 deletions

View File

@ -3,6 +3,7 @@ import os.path
import sys import sys
import runpy import runpy
import tempfile import tempfile
import subprocess
from importlib import resources from importlib import resources
from . import _bundled from . import _bundled
@ -14,7 +15,7 @@ __all__ = ["version", "bootstrap"]
_SETUPTOOLS_VERSION = "47.1.0" _SETUPTOOLS_VERSION = "47.1.0"
_PIP_VERSION = "20.1.1" _PIP_VERSION = "20.2.3"
_PROJECTS = [ _PROJECTS = [
("setuptools", _SETUPTOOLS_VERSION, "py3"), ("setuptools", _SETUPTOOLS_VERSION, "py3"),
@ -23,22 +24,18 @@ _PROJECTS = [
def _run_pip(args, additional_paths=None): def _run_pip(args, additional_paths=None):
# Add our bundled software to the sys.path so we can import it # Run the bootstraping in a subprocess to avoid leaking any state that happens
if additional_paths is not None: # after pip has executed. Particulary, this avoids the case when pip holds onto
sys.path = additional_paths + sys.path # the files in *additional_paths*, preventing us to remove them at the end of the
# invocation.
# Invoke pip as if it's the main module, and catch the exit. code = f"""
backup_argv = sys.argv[:] import runpy
sys.argv[1:] = args import sys
try: sys.path = {additional_paths or []} + sys.path
# run_module() alters sys.modules and sys.argv, but restores them at exit sys.argv[1:] = {args}
runpy.run_module("pip", run_name="__main__", alter_sys=True) runpy.run_module("pip", run_name="__main__", alter_sys=True)
except SystemExit as exc: """
return exc.code return subprocess.run([sys.executable, "-c", code], check=True).returncode
finally:
sys.argv[:] = backup_argv
raise SystemError("pip did not exit, this should never happen")
def version(): def version():