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

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