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

b5669c
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
70a2d8
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
70a2d8
Date: Wed, 15 Aug 2018 15:36:29 +0200
70a2d8
Subject: [PATCH] 00189: Instead of bundled wheels, use our RPM packaged wheels
70a2d8
70a2d8
We keep them in /usr/share/python-wheels
b5669c
b5669c
Downstream only: upstream bundles
b5669c
We might eventually pursuit upstream support, but it's low prio
70a2d8
---
b5669c
 Lib/ensurepip/__init__.py | 32 ++++++++++++++++++++++----------
b5669c
 1 file changed, 22 insertions(+), 10 deletions(-)
70a2d8
70a2d8
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
b5669c
index 9415fd73b8..f58dab1800 100644
70a2d8
--- a/Lib/ensurepip/__init__.py
70a2d8
+++ b/Lib/ensurepip/__init__.py
b5669c
@@ -1,6 +1,7 @@
70a2d8
+import distutils.version
70a2d8
+import glob
70a2d8
 import os
70a2d8
 import os.path
70a2d8
-import pkgutil
70a2d8
 import sys
b5669c
 import runpy
70a2d8
 import tempfile
b5669c
@@ -8,10 +9,24 @@ import tempfile
70a2d8
 
70a2d8
 __all__ = ["version", "bootstrap"]
70a2d8
 
70a2d8
+_WHEEL_DIR = "/opt/rh/rh-python38/root/usr/share/python38-wheels/"
70a2d8
 
b5669c
-_SETUPTOOLS_VERSION = "49.2.1"
b5669c
+_wheels = {}
70a2d8
 
b5669c
-_PIP_VERSION = "20.2.1"
70a2d8
+def _get_most_recent_wheel_version(pkg):
70a2d8
+    prefix = os.path.join(_WHEEL_DIR, "{}-".format(pkg))
b5669c
+    _wheels[pkg] = {}
b5669c
+    for suffix in "-py2.py3-none-any.whl", "-py3-none-any.whl":
b5669c
+        pattern = "{}*{}".format(prefix, suffix)
b5669c
+        for path in glob.glob(pattern):
b5669c
+            version_str = path[len(prefix):-len(suffix)]
b5669c
+            _wheels[pkg][version_str] = os.path.basename(path)
b5669c
+    return str(max(_wheels[pkg], key=distutils.version.LooseVersion))
70a2d8
+
70a2d8
+
70a2d8
+_SETUPTOOLS_VERSION = _get_most_recent_wheel_version("setuptools")
70a2d8
+
70a2d8
+_PIP_VERSION = _get_most_recent_wheel_version("pip")
70a2d8
 
70a2d8
 _PROJECTS = [
b5669c
     ("setuptools", _SETUPTOOLS_VERSION, "py3"),
b5669c
@@ -105,13 +120,10 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
b5669c
         # additional paths that need added to sys.path
70a2d8
         additional_paths = []
b5669c
         for project, version, py_tag in _PROJECTS:
b5669c
-            wheel_name = "{}-{}-{}-none-any.whl".format(project, version, py_tag)
70a2d8
-            whl = pkgutil.get_data(
70a2d8
-                "ensurepip",
70a2d8
-                "_bundled/{}".format(wheel_name),
70a2d8
-            )
70a2d8
-            with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
70a2d8
-                fp.write(whl)
b5669c
+            wheel_name = _wheels[project][version]
70a2d8
+            with open(os.path.join(_WHEEL_DIR, wheel_name), "rb") as sfp:
70a2d8
+                with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
70a2d8
+                    fp.write(sfp.read())
70a2d8
 
70a2d8
             additional_paths.append(os.path.join(tmpdir, wheel_name))
70a2d8