Blame 00189-use-rpm-wheels.patch

0c847d2
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
0c847d2
index 25c5567..2553524 100644
0c847d2
--- a/Lib/ensurepip/__init__.py
0c847d2
+++ b/Lib/ensurepip/__init__.py
0c847d2
@@ -1,16 +1,27 @@
0c847d2
+import distutils.version
0c847d2
+import glob
0c847d2
 import os
0c847d2
 import os.path
0c847d2
-import pkgutil
0c847d2
 import sys
0c847d2
 import tempfile
0c847d2
 
0c847d2
 
0c847d2
 __all__ = ["version", "bootstrap"]
0c847d2
 
0c847d2
+_WHEEL_DIR = "/usr/share/python-wheels/"
0c847d2
 
0c847d2
-_SETUPTOOLS_VERSION = "28.8.0"
0c847d2
 
0c847d2
-_PIP_VERSION = "9.0.1"
0c847d2
+def _get_most_recent_wheel_version(pkg):
0c847d2
+    prefix = os.path.join(_WHEEL_DIR, "{}-".format(pkg))
0c847d2
+    suffix = "-py2.py3-none-any.whl"
0c847d2
+    pattern = "{}*{}".format(prefix, suffix)
0c847d2
+    versions = (p[len(prefix):-len(suffix)] for p in glob.glob(pattern))
0c847d2
+    return str(max(versions, key=distutils.version.LooseVersion))
0c847d2
+
0c847d2
+
0c847d2
+_SETUPTOOLS_VERSION = _get_most_recent_wheel_version("setuptools")
0c847d2
+
0c847d2
+_PIP_VERSION = _get_most_recent_wheel_version("pip")
0c847d2
 
0c847d2
 # pip currently requires ssl support, so we try to provide a nicer
0c847d2
 # error message when that is missing (http://bugs.python.org/issue19744)
0c847d2
@@ -37,8 +48,13 @@ def _run_pip(args, additional_paths=None):
0c847d2
         sys.path = additional_paths + sys.path
0c847d2
 
0c847d2
     # Install the bundled software
0c847d2
-    import pip
0c847d2
-    pip.main(args)
0c847d2
+    try:
0c847d2
+        # pip 10
0c847d2
+        from pip._internal import main
0c847d2
+    except ImportError:
0c847d2
+        # pip 9
0c847d2
+        from pip import main
0c847d2
+    main(args)
0c847d2
 
0c847d2
 
0c847d2
 def version():
0c847d2
@@ -93,12 +109,9 @@ def bootstrap(*, root=None, upgrade=False, user=False,
0c847d2
         additional_paths = []
0c847d2
         for project, version in _PROJECTS:
0c847d2
             wheel_name = "{}-{}-py2.py3-none-any.whl".format(project, version)
0c847d2
-            whl = pkgutil.get_data(
0c847d2
-                "ensurepip",
0c847d2
-                "_bundled/{}".format(wheel_name),
0c847d2
-            )
0c847d2
-            with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
0c847d2
-                fp.write(whl)
0c847d2
+            with open(os.path.join(_WHEEL_DIR, wheel_name), "rb") as sfp:
0c847d2
+                with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
0c847d2
+                    fp.write(sfp.read())
0c847d2
 
0c847d2
             additional_paths.append(os.path.join(tmpdir, wheel_name))
0c847d2