diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py index cb2882e3360..f70e3a17a91 100644 --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -1,13 +1,10 @@ import os import os.path import sys -import runpy import tempfile import subprocess from importlib import resources -from . import _bundled - __all__ = ["version", "bootstrap"] @@ -24,8 +21,8 @@ _PROJECTS = [ def _run_pip(args, additional_paths=None): - # 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 + # Run the bootstrapping in a subprocess to avoid leaking any state that happens + # after pip has executed. Particularly, 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""" @@ -106,12 +103,9 @@ def _bootstrap(*, root=None, upgrade=False, user=False, additional_paths = [] for project, version, py_tag in _PROJECTS: wheel_name = "{}-{}-{}-none-any.whl".format(project, version, py_tag) - whl = resources.read_binary( - _bundled, - wheel_name, - ) + whl = resources.files("ensurepip") / "_bundled" / wheel_name with open(os.path.join(tmpdir, wheel_name), "wb") as fp: - fp.write(whl) + fp.write(whl.read_bytes()) additional_paths.append(os.path.join(tmpdir, wheel_name)) diff --git a/Lib/ensurepip/_bundled/__init__.py b/Lib/ensurepip/_bundled/__init__.py deleted file mode 100644 index e69de29bb2d..00000000000 diff --git a/Misc/NEWS.d/next/Library/2020-10-11-20-23-48.bpo-37449.f-t3V6.rst b/Misc/NEWS.d/next/Library/2020-10-11-20-23-48.bpo-37449.f-t3V6.rst new file mode 100644 index 00000000000..360d301c6c9 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-10-11-20-23-48.bpo-37449.f-t3V6.rst @@ -0,0 +1 @@ +`ensurepip` now uses `importlib.resources.files()` traversable APIs