8000 [3.8] bpo-41490: Bump vendored pip to version 20.2.3 (GH-22527). (GH-… · python/cpython@28cd96f · GitHub
[go: up one dir, main page]

Skip to content

Commit 28cd96f

Browse files
authored
[3.8] bpo-41490: Bump vendored pip to version 20.2.3 (GH-22527). (GH-22545)
(cherry picked from commit 2cc6dc9) Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
1 parent c5f1212 commit 28cd96f

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

Lib/ensurepip/__init__.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,15 @@
44
import sys
55
import runpy
66
import tempfile
7+
import subprocess
78

89

910
__all__ = ["version", "bootstrap"]
1011

1112

1213
_SETUPTOOLS_VERSION = "49.2.1"
1314

14-
_PIP_VERSION = "20.2.1"
15+
_PIP_VERSION = "20.2.3"
1516

1617
_PROJECTS = [
1718
("setuptools", _SETUPTOOLS_VERSION, "py3"),
@@ -20,22 +21,18 @@
2021

2122

2223
def _run_pip(args, additional_paths=None):
23-
# Add our bundled software to the sys.path so we can import it
24-
if additional_paths is not None:
25-
sys.path = additional_paths + sys.path
26-
27-
# Invoke pip as if it's the main module, and catch the exit.
28-
backup_argv = sys.argv[:]
29-
sys.argv[1:] = args
30-
try:
31-
# run_module() alters sys.modules and sys.argv, but restores them at exit
32-
runpy.run_module("pip", run_name="__main__", alter_sys=True)
33-
except SystemExit as exc:
34-
return exc.code
35-
finally:
36-
sys.argv[:] = backup_argv
37-
38-
raise SystemError("pip did not exit, this should never happen")
24+
# Run the bootstraping in a subprocess to avoid leaking any state that happens
25+
# after pip has executed. Particulary, this avoids the case when pip holds onto
26+
# the files in *additional_paths*, preventing us to remove them at the end of the
27+
# invocation.
28+
code = f"""
29+
import runpy
30+
import sys
31+
sys.path = {additional_paths or []} + sys.path
32+
sys.argv[1:] = {args}
33+
runpy.run_module("pip", run_name="__main__", alter_sys=True)
34+
"""
35+
return subprocess.run([sys.executable, "-c", code], check=True).returncode
3936

4037

4138
def version():
Binary file not shown.

0 commit comments

Comments
 (0)
0