Skip to content

Commit afb2eed

Browse files
wimglennjaraco
andauthored
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 <[email protected]> * Update Misc/NEWS.d/next/Library/2020-10-11-20-23-48.bpo-37449.f-t3V6.rst Co-authored-by: Jason R. Coombs <[email protected]> Co-authored-by: Jason R. Coombs <[email protected]>
1 parent 67dfa6f commit afb2eed

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

Lib/ensurepip/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from importlib import resources
99

1010

11-
1211
__all__ = ["version", "bootstrap"]
1312
_PACKAGE_NAMES = ('setuptools', 'pip')
1413
_SETUPTOOLS_VERSION = "56.0.0"
@@ -79,8 +78,8 @@ def _get_packages():
7978

8079

8180
def _run_pip(args, additional_paths=None):
82-
# Run the bootstraping in a subprocess to avoid leaking any state that happens
83-
# after pip has executed. Particulary, this avoids the case when pip holds onto
81+
# Run the bootstrapping in a subprocess to avoid leaking any state that happens
82+
# after pip has executed. Particularly, this avoids the case when pip holds onto
8483
# the files in *additional_paths*, preventing us to remove them at the end of the
8584
# invocation.
8685
code = f"""
@@ -164,9 +163,9 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
164163
for name, package in _get_packages().items():
165164
if package.wheel_name:
166165
# Use bundled wheel package
167-
from ensurepip import _bundled
168166
wheel_name = package.wheel_name
169-
whl = resources.read_binary(_bundled, wheel_name)
167+
wheel_path = resources.files("ensurepip") / "_bundled" / wheel_name
168+
whl = wheel_path.read_bytes()
170169
else:
171170
# Use the wheel package directory
172171
with open(package.wheel_path, "rb") as fp:

Lib/ensurepip/_bundled/__init__.py

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
``ensurepip`` now uses ``importlib.resources.files()`` traversable APIs

0 commit comments

Comments
 (0)