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