Blame SOURCES/00189-use-rpm-wheels.patch

98d66e
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
98d66e
index 5021ebf..29a7d1b 100644
98d66e
--- a/Lib/ensurepip/__init__.py
98d66e
+++ b/Lib/ensurepip/__init__.py
98d66e
@@ -1,9 +1,10 @@
98d66e
 #!/usr/bin/env python2
98d66e
 from __future__ import print_function
98d66e
 
98d66e
+import distutils.version
98d66e
+import glob
98d66e
 import os
98d66e
 import os.path
98d66e
-import pkgutil
98d66e
 import shutil
98d66e
 import sys
98d66e
 import tempfile
98d66e
@@ -12,9 +13,19 @@ import tempfile
98d66e
 __all__ = ["version", "bootstrap"]
98d66e
 
98d66e
 
98d66e
-_SETUPTOOLS_VERSION = "41.2.0"
98d66e
+_WHEEL_DIR = "/usr/share/python{}-wheels/".format(sys.version_info[0])
98d66e
 
98d66e
-_PIP_VERSION = "19.2.3"
98d66e
+def _get_most_recent_wheel_version(pkg):
98d66e
+    prefix = os.path.join(_WHEEL_DIR, "{}-".format(pkg))
98d66e
+    suffix = "-py2.py3-none-any.whl"
98d66e
+    pattern = "{}*{}".format(prefix, suffix)
98d66e
+    versions = (p[len(prefix):-len(suffix)] for p in glob.glob(pattern))
98d66e
+    return str(max(versions, key=distutils.version.LooseVersion))
98d66e
+
98d66e
+
98d66e
+_SETUPTOOLS_VERSION = _get_most_recent_wheel_version("setuptools")
98d66e
+
98d66e
+_PIP_VERSION = _get_most_recent_wheel_version("pip")
98d66e
 
98d66e
 _PROJECTS = [
98d66e
     ("setuptools", _SETUPTOOLS_VERSION),
98d66e
@@ -28,8 +39,13 @@ def _run_pip(args, additional_paths=None):
98d66e
         sys.path = additional_paths + sys.path
98d66e
 
98d66e
     # Install the bundled software
98d66e
-    import pip._internal
98d66e
-    return pip._internal.main(args)
98d66e
+    try:
98d66e
+        # pip 10
98d66e
+        from pip._internal import main
98d66e
+    except ImportError:
98d66e
+        # pip 9
98d66e
+        from pip import main
98d66e
+    return main(args)
98d66e
 
98d66e
 
98d66e
 def version():
98d66e
@@ -100,12 +116,9 @@ def _bootstrap(root=None, upgrade=False, user=False,
98d66e
         additional_paths = []
98d66e
         for project, version in _PROJECTS:
98d66e
             wheel_name = "{}-{}-py2.py3-none-any.whl".format(project, version)
98d66e
-            whl = pkgutil.get_data(
98d66e
-                "ensurepip",
98d66e
-                "_bundled/{}".format(wheel_name),
98d66e
-            )
98d66e
-            with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
98d66e
-                fp.write(whl)
98d66e
+            with open(os.path.join(_WHEEL_DIR, wheel_name), "rb") as sfp:
98d66e
+                with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
98d66e
+                    fp.write(sfp.read())
98d66e
 
98d66e
             additional_paths.append(os.path.join(tmpdir, wheel_name))
98d66e