mirror of
https://github.com/python/cpython.git
synced 2025-11-27 13:45:25 +00:00
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>
This commit is contained in:
parent
67dfa6f2a5
commit
afb2eed72b
3 changed files with 5 additions and 5 deletions
|
|
@ -8,7 +8,6 @@ import tempfile
|
||||||
from importlib import resources
|
from importlib import resources
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
__all__ = ["version", "bootstrap"]
|
__all__ = ["version", "bootstrap"]
|
||||||
_PACKAGE_NAMES = ('setuptools', 'pip')
|
_PACKAGE_NAMES = ('setuptools', 'pip')
|
||||||
_SETUPTOOLS_VERSION = "56.0.0"
|
_SETUPTOOLS_VERSION = "56.0.0"
|
||||||
|
|
@ -79,8 +78,8 @@ _PACKAGES = None
|
||||||
|
|
||||||
|
|
||||||
def _run_pip(args, additional_paths=None):
|
def _run_pip(args, additional_paths=None):
|
||||||
# Run the bootstraping in a subprocess to avoid leaking any state that happens
|
# Run the bootstrapping in a subprocess to avoid leaking any state that happens
|
||||||
# after pip has executed. Particulary, this avoids the case when pip holds onto
|
# 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
|
# the files in *additional_paths*, preventing us to remove them at the end of the
|
||||||
# invocation.
|
# invocation.
|
||||||
code = f"""
|
code = f"""
|
||||||
|
|
@ -164,9 +163,9 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
|
||||||
for name, package in _get_packages().items():
|
for name, package in _get_packages().items():
|
||||||
if package.wheel_name:
|
if package.wheel_name:
|
||||||
# Use bundled wheel package
|
# Use bundled wheel package
|
||||||
from ensurepip import _bundled
|
|
||||||
wheel_name = package.wheel_name
|
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:
|
else:
|
||||||
# Use the wheel package directory
|
# Use the wheel package directory
|
||||||
with open(package.wheel_path, "rb") as fp:
|
with open(package.wheel_path, "rb") as fp:
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1 @@
|
||||||
|
``ensurepip`` now uses ``importlib.resources.files()`` traversable APIs
|
||||||
Loading…
Add table
Add a link
Reference in a new issue