churchyard / rpms / python38

Forked from rpms/python38 a year ago
Clone
0b241a
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
0b241a
index 4748ba4..fc02255 100644
0b241a
--- a/Lib/ensurepip/__init__.py
0b241a
+++ b/Lib/ensurepip/__init__.py
0b241a
@@ -1,16 +1,27 @@
0b241a
+import distutils.version
0b241a
+import glob
0b241a
 import os
0b241a
 import os.path
0b241a
-import pkgutil
0b241a
 import sys
0b241a
 import tempfile
0b241a
 
0b241a
 
0b241a
 __all__ = ["version", "bootstrap"]
0b241a
 
0b241a
+_WHEEL_DIR = "/usr/share/python-wheels/"
0b241a
 
1385d6
-_SETUPTOOLS_VERSION = "40.6.2"
0b241a
 
1385d6
-_PIP_VERSION = "18.1"
0b241a
+def _get_most_recent_wheel_version(pkg):
0b241a
+    prefix = os.path.join(_WHEEL_DIR, "{}-".format(pkg))
0b241a
+    suffix = "-py2.py3-none-any.whl"
0b241a
+    pattern = "{}*{}".format(prefix, suffix)
0b241a
+    versions = (p[len(prefix):-len(suffix)] for p in glob.glob(pattern))
0b241a
+    return str(max(versions, key=distutils.version.LooseVersion))
0b241a
+
0b241a
+
0b241a
+_SETUPTOOLS_VERSION = _get_most_recent_wheel_version("setuptools")
0b241a
+
0b241a
+_PIP_VERSION = _get_most_recent_wheel_version("pip")
0b241a
 
0b241a
 _PROJECTS = [
0b241a
     ("setuptools", _SETUPTOOLS_VERSION),
0b241a
@@ -94,12 +105,9 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
0b241a
         additional_paths = []
0b241a
         for project, version in _PROJECTS:
0b241a
             wheel_name = "{}-{}-py2.py3-none-any.whl".format(project, version)
0b241a
-            whl = pkgutil.get_data(
0b241a
-                "ensurepip",
0b241a
-                "_bundled/{}".format(wheel_name),
0b241a
-            )
0b241a
-            with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
0b241a
-                fp.write(whl)
0b241a
+            with open(os.path.join(_WHEEL_DIR, wheel_name), "rb") as sfp:
0b241a
+                with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
0b241a
+                    fp.write(sfp.read())
0b241a
 
0b241a
             additional_paths.append(os.path.join(tmpdir, wheel_name))
0b241a