Skip to content

bpo-37449: Move ensurepip off of pkgutil and to importlib.resources #15109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Sep 13, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions Lib/ensurepip/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import os
import os.path
import pkgutil
import sys
import tempfile
from importlib import resources
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should get moved up with the other stdlib modules above.


from . import _bundled
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PEP 8 says to sort imports so that stdlib imports com first, then a blank line, then package-local modules.




__all__ = ["version", "bootstrap"]
Expand Down Expand Up @@ -96,9 +99,9 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
additional_paths = []
for project, version in _PROJECTS:
wheel_name = "{}-{}-py2.py3-none-any.whl".format(project, version)
whl = pkgutil.get_data(
"ensurepip",
"_bundled/{}".format(wheel_name),
whl = resources.read_binary(
_bundled,
wheel_name,
)
with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
fp.write(whl)
Expand Down
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
`ensurepip` now uses `importlib.resources.read_binary()` to read data instead of `pkgutil.get_data()`.
Patch by Joannah Nanjekye.