]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-41490: Bump vendored pip to version 20.2.3 (#22527)
authorPablo Galindo <Pablogsal@gmail.com>
Sun, 4 Oct 2020 16:45:31 +0000 (17:45 +0100)
committerGitHub <noreply@github.com>
Sun, 4 Oct 2020 16:45:31 +0000 (18:45 +0200)
Lib/ensurepip/__init__.py
Lib/ensurepip/_bundled/pip-20.2.3-py2.py3-none-any.whl [moved from Lib/ensurepip/_bundled/pip-20.1.1-py2.py3-none-any.whl with 54% similarity]

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