diff options
author | wim glenn <wim.glenn@gmail.com> | 2021-06-07 02:14:47 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-07 02:14:47 (GMT) |
commit | afb2eed72b32a35b4726ff35f92e4fbf54926046 (patch) | |
tree | 0e6b4a154015fb49faa967c20720bffee71be114 /Lib/ensurepip | |
parent | 67dfa6f2a508c325715625fe442f2ce20270a8b3 (diff) | |
download | cpython-afb2eed72b32a35b4726ff35f92e4fbf54926046.zip cpython-afb2eed72b32a35b4726ff35f92e4fbf54926046.tar.gz cpython-afb2eed72b32a35b4726ff35f92e4fbf54926046.tar.bz2 |
bpo-37449: ensurepip uses importlib.resources.files() traversable APIs (#22659)
* `ensurepip` now uses `importlib.resources.files()` traversable APIs
* Update Lib/ensurepip/__init__.py
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
* Update Misc/NEWS.d/next/Library/2020-10-11-20-23-48.bpo-37449.f-t3V6.rst
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Co-authored-by: Jason R. Coombs <jaraco@jaraco.com>
Diffstat (limited to 'Lib/ensurepip')
-rw-r--r-- | Lib/ensurepip/__init__.py | 9 | ||||
-rw-r--r-- | Lib/ensurepip/_bundled/__init__.py | 0 |
2 files changed, 4 insertions, 5 deletions
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py index 4c606b9..834fc6b 100644 --- a/Lib/ensurepip/__init__.py +++ b/Lib/ensurepip/__init__.py @@ -8,7 +8,6 @@ import tempfile from importlib import resources - __all__ = ["version", "bootstrap"] _PACKAGE_NAMES = ('setuptools', 'pip') _SETUPTOOLS_VERSION = "56.0.0" @@ -79,8 +78,8 @@ _PACKAGES = None 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""" @@ -164,9 +163,9 @@ def _bootstrap(*, root=None, upgrade=False, user=False, for name, package in _get_packages().items(): if package.wheel_name: # Use bundled wheel package - from ensurepip import _bundled wheel_name = package.wheel_name - whl = resources.read_binary(_bundled, wheel_name) + wheel_path = resources.files("ensurepip") / "_bundled" / wheel_name + whl = wheel_path.read_bytes() else: # Use the wheel package directory with open(package.wheel_path, "rb") as fp: diff --git a/Lib/ensurepip/_bundled/__init__.py b/Lib/ensurepip/_bundled/__init__.py deleted file mode 100644 index e69de29..0000000 --- a/Lib/ensurepip/_bundled/__init__.py +++ /dev/null |