Skip to content

Commit

Permalink
[3.9] bpo-41490: Bump vendored pip to version 20.2.3 (pythonGH-22527). (
Browse files Browse the repository at this point in the history
pythonGH-22544)

(cherry picked from commit 2cc6dc9)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
  • Loading branch information
pablogsal authored and ambv committed Oct 4, 2020
1 parent c26a666 commit 168a838
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
31 changes: 14 additions & 17 deletions Lib/ensurepip/__init__.py
Expand Up @@ -3,6 +3,7 @@
import sys
import runpy
import tempfile
import subprocess
from importlib import resources

from . import _bundled
Expand All @@ -14,7 +15,7 @@

_SETUPTOOLS_VERSION = "49.2.1"

_PIP_VERSION = "20.2.1"
_PIP_VERSION = "20.2.3"

_PROJECTS = [
("setuptools", _SETUPTOOLS_VERSION, "py3"),
Expand All @@ -23,22 +24,18 @@


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():
Expand Down
Binary file not shown.

0 comments on commit 168a838

Please sign in to comment.