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

ab10c8
From 2c91575950d4de95d308e30cc4ab20d032b1aceb Mon Sep 17 00:00:00 2001
93a1c0
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
93a1c0
Date: Wed, 15 Aug 2018 15:36:29 +0200
93a1c0
Subject: [PATCH] 00189: Instead of bundled wheels, use our RPM packaged wheels
93a1c0
93a1c0
We keep them in /usr/share/python-wheels
93a1c0
93a1c0
Downstream only: upstream bundles
93a1c0
We might eventually pursuit upstream support, but it's low prio
93a1c0
---
ab10c8
 Lib/ensurepip/__init__.py | 37 ++++++++++++++++++++++++++-----------
ab10c8
 1 file changed, 26 insertions(+), 11 deletions(-)
93a1c0
93a1c0
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
ab10c8
index e510cc7..8de2e55 100644
93a1c0
--- a/Lib/ensurepip/__init__.py
93a1c0
+++ b/Lib/ensurepip/__init__.py
93a1c0
@@ -1,3 +1,5 @@
93a1c0
+import distutils.version
93a1c0
+import glob
93a1c0
 import os
93a1c0
 import os.path
93a1c0
 import sys
ab10c8
@@ -6,13 +8,29 @@ import tempfile
93a1c0
 import subprocess
93a1c0
 from importlib import resources
93a1c0
 
93a1c0
-from . import _bundled
93a1c0
-
93a1c0
 
93a1c0
 
93a1c0
 __all__ = ["version", "bootstrap"]
ab10c8
-_SETUPTOOLS_VERSION = "58.1.0"
ab10c8
-_PIP_VERSION = "22.0.4"
ab10c8
+
93a1c0
+_WHEEL_DIR = "/usr/share/python39-wheels/"
ab10c8
+
93a1c0
+_wheels = {}
ab10c8
+
93a1c0
+def _get_most_recent_wheel_version(pkg):
93a1c0
+    prefix = os.path.join(_WHEEL_DIR, "{}-".format(pkg))
93a1c0
+    _wheels[pkg] = {}
93a1c0
+    for suffix in "-py2.py3-none-any.whl", "-py3-none-any.whl":
93a1c0
+        pattern = "{}*{}".format(prefix, suffix)
93a1c0
+        for path in glob.glob(pattern):
93a1c0
+            version_str = path[len(prefix):-len(suffix)]
93a1c0
+            _wheels[pkg][version_str] = os.path.basename(path)
93a1c0
+    return str(max(_wheels[pkg], key=distutils.version.LooseVersion))
93a1c0
+
93a1c0
+
93a1c0
+_SETUPTOOLS_VERSION = _get_most_recent_wheel_version("setuptools")
93a1c0
+
93a1c0
+_PIP_VERSION = _get_most_recent_wheel_version("pip")
ab10c8
+
93a1c0
 _PROJECTS = [
93a1c0
     ("setuptools", _SETUPTOOLS_VERSION, "py3"),
ab10c8
     ("pip", _PIP_VERSION, "py3"),
ab10c8
@@ -101,13 +119,10 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
93a1c0
         # additional paths that need added to sys.path
93a1c0
         additional_paths = []
93a1c0
         for project, version, py_tag in _PROJECTS:
93a1c0
-            wheel_name = "{}-{}-{}-none-any.whl".format(project, version, py_tag)
93a1c0
-            whl = resources.read_binary(
93a1c0
-                _bundled,
93a1c0
-                wheel_name,
93a1c0
-            )
93a1c0
-            with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
93a1c0
-                fp.write(whl)
93a1c0
+            wheel_name = _wheels[project][version]
93a1c0
+            with open(os.path.join(_WHEEL_DIR, wheel_name), "rb") as sfp:
93a1c0
+                with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
93a1c0
+                    fp.write(sfp.read())
93a1c0
 
93a1c0
             additional_paths.append(os.path.join(tmpdir, wheel_name))
93a1c0
 
ab10c8
-- 
ab10c8
2.35.3
ab10c8