Blame 00189-use-rpm-wheels.patch

acc1ca2
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
285f554
From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= <miro@hroncok.cz>
285f554
Date: Wed, 15 Aug 2018 15:36:29 +0200
29530ba
Subject: [PATCH] 00189: Instead of bundled wheels, use our RPM packaged wheels
285f554
285f554
We keep them in /usr/share/python-wheels
acc1ca2
acc1ca2
Downstream only: upstream bundles
acc1ca2
We might eventually pursuit upstream support, but it's low prio
285f554
---
Marcel Plch 1206bb9
 Lib/ensurepip/__init__.py | 33 ++++++++++++++++++++++-----------
Marcel Plch 1206bb9
 1 file changed, 22 insertions(+), 11 deletions(-)
285f554
0b241ab
diff --git a/Lib/ensurepip/__init__.py b/Lib/ensurepip/__init__.py
d3f7caa
index cb2882e336..984e587ea0 100644
0b241ab
--- a/Lib/ensurepip/__init__.py
0b241ab
+++ b/Lib/ensurepip/__init__.py
b89d4ad
@@ -1,3 +1,5 @@
0b241ab
+import distutils.version
0b241ab
+import glob
0b241ab
 import os
0b241ab
 import os.path
0b241ab
 import sys
68997e0
@@ -6,16 +8,28 @@ import tempfile
68997e0
 import subprocess
1a985bb
 from importlib import resources
0b241ab
 
1a985bb
-from . import _bundled
1a985bb
-
0b241ab
 
0b241ab
 
1a985bb
 __all__ = ["version", "bootstrap"]
0b241ab
 
1a985bb
+_WHEEL_DIR = "/usr/share/python-wheels/"
acc1ca2
 
d3f7caa
-_SETUPTOOLS_VERSION = "47.1.0"
088c30c
+_wheels = {}
acc1ca2
 
68997e0
-_PIP_VERSION = "20.2.3"
0b241ab
+def _get_most_recent_wheel_version(pkg):
0b241ab
+    prefix = os.path.join(_WHEEL_DIR, "{}-".format(pkg))
088c30c
+    _wheels[pkg] = {}
088c30c
+    for suffix in "-py2.py3-none-any.whl", "-py3-none-any.whl":
088c30c
+        pattern = "{}*{}".format(prefix, suffix)
088c30c
+        for path in glob.glob(pattern):
088c30c
+            version_str = path[len(prefix):-len(suffix)]
088c30c
+            _wheels[pkg][version_str] = os.path.basename(path)
088c30c
+    return str(max(_wheels[pkg], key=distutils.version.LooseVersion))
0b241ab
+
acc1ca2
+
0b241ab
+_SETUPTOOLS_VERSION = _get_most_recent_wheel_version("setuptools")
acc1ca2
+
0b241ab
+_PIP_VERSION = _get_most_recent_wheel_version("pip")
0b241ab
 
0b241ab
 _PROJECTS = [
efdda00
     ("setuptools", _SETUPTOOLS_VERSION, "py3"),
68997e0
@@ -105,13 +119,10 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
088c30c
         # additional paths that need added to sys.path
0b241ab
         additional_paths = []
efdda00
         for project, version, py_tag in _PROJECTS:
efdda00
-            wheel_name = "{}-{}-{}-none-any.whl".format(project, version, py_tag)
b180b30
-            whl = resources.read_binary(
b180b30
-                _bundled,
b180b30
-                wheel_name,
0b241ab
-            )
0b241ab
-            with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
0b241ab
-                fp.write(whl)
088c30c
+            wheel_name = _wheels[project][version]
0b241ab
+            with open(os.path.join(_WHEEL_DIR, wheel_name), "rb") as sfp:
0b241ab
+                with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
0b241ab
+                    fp.write(sfp.read())
0b241ab
 
0b241ab
             additional_paths.append(os.path.join(tmpdir, wheel_name))
0b241ab