summaryrefslogtreecommitdiffstats
path: root/Lib/ensurepip
diff options
context:
space:
mode:
authorJoannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com>2019-09-13 16:01:20 (GMT)
committerMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2019-09-13 16:01:20 (GMT)
commit2ccb50cf773881255c5669942a093eb68ad042f6 (patch)
treeb05ba5fc13c91c5c45ad1cb3d35e6dbc2cbc040c /Lib/ensurepip
parentd6a9d17d8b6c68073931dd8ffa213b4ac351a4ab (diff)
downloadcpython-2ccb50cf773881255c5669942a093eb68ad042f6.zip
cpython-2ccb50cf773881255c5669942a093eb68ad042f6.tar.gz
cpython-2ccb50cf773881255c5669942a093eb68ad042f6.tar.bz2
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
Diffstat (limited to 'Lib/ensurepip')
-rw-r--r--Lib/ensurepip/__init__.py11
-rw-r--r--Lib/ensurepip/_bundled/__init__.py0
2 files changed, 7 insertions, 4 deletions
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
index fc0edec..386ed6c 100644
--- a/Lib/ensurepip/__init__.py
+++ b/Lib/ensurepip/__init__.py
@@ -1,8 +1,11 @@
import os
import os.path
-import pkgutil
import sys
import tempfile
+from importlib import resources
+
+from . import _bundled
+
__all__ = ["version", "bootstrap"]
@@ -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)
diff --git a/Lib/ensurepip/_bundled/__init__.py b/Lib/ensurepip/_bundled/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Lib/ensurepip/_bundled/__init__.py