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