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

8b629b
From a7146f029f38c7fc25ddfa09529aefbe8035620a 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
---
8b629b
 Lib/ensurepip/__init__.py | 36 ++++++++++++++++++++++++++----------
8b629b
 1 file changed, 26 insertions(+), 10 deletions(-)
70a2d8
70a2d8
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
8b629b
index b291e9a..ed17b22 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
8b629b
@@ -9,8 +10,26 @@ import subprocess
70a2d8
 
70a2d8
 __all__ = ["version", "bootstrap"]
8b629b
 _PACKAGE_NAMES = ('setuptools', 'pip')
60a024
-_SETUPTOOLS_VERSION = "56.0.0"
8b629b
-_PIP_VERSION = "22.0.4"
8b629b
+
70a2d8
+_WHEEL_DIR = "/opt/rh/rh-python38/root/usr/share/python38-wheels/"
8b629b
+
b5669c
+_wheels = {}
60a024
+
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")
8b629b
+
70a2d8
 _PROJECTS = [
b5669c
     ("setuptools", _SETUPTOOLS_VERSION, "py3"),
8b629b
     ("pip", _PIP_VERSION, "py3"),
8b629b
@@ -99,13 +118,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
 
60a024
-- 
8b629b
2.35.1
60a024