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

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