Skip to content

Commit 2ccb50c

Browse files
nanjekyejoannahmiss-islington
authored andcommitted
bpo-37449: Move ensurepip off of pkgutil and to importlib.resources (GH-15109)
Move ensurepip off of pkgutil and to importlib.resources. https://bugs.python.org/issue37449
1 parent d6a9d17 commit 2ccb50c

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

Lib/ensurepip/__init__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import os
22
import os.path
3-
import pkgutil
43
import sys
54
import tempfile
5+
from importlib import resources
6+
7+
from . import _bundled
8+
69

710

811
__all__ = ["version", "bootstrap"]
@@ -96,9 +99,9 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
9699
additional_paths = []
97100
for project, version in _PROJECTS:
98101
wheel_name = "{}-{}-py2.py3-none-any.whl".format(project, version)
99-
whl = pkgutil.get_data(
100-
"ensurepip",
101-
"_bundled/{}".format(wheel_name),
102+
whl = resources.read_binary(
103+
_bundled,
104+
wheel_name,
102105
)
103106
with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
104107
fp.write(whl)

Lib/ensurepip/_bundled/__init__.py

Whitespace-only changes.
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
`ensurepip` now uses `importlib.resources.read_binary()` to read data instead of `pkgutil.get_data()`.
2+
Patch by Joannah Nanjekye.

0 commit comments

Comments
 (0)