Skip to content

Commit 670c30f

Browse files
hroncokfrenzymadness
authored andcommitted
00189: Instead of bundled wheels, use our RPM packaged wheels
We keep them in /usr/share/python-wheels Downstream only: upstream bundles We might eventually pursuit upstream support, but it's low prio
1 parent 8c760d7 commit 670c30f

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

Lib/ensurepip/__init__.py

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import distutils.version
2+
import glob
13
import os
24
import os.path
35
import sys
@@ -6,13 +8,29 @@
68
import subprocess
79
from importlib import resources
810

9-
from . import _bundled
10-
1111

1212

1313
__all__ = ["version", "bootstrap"]
14-
_SETUPTOOLS_VERSION = "58.1.0"
15-
_PIP_VERSION = "23.0.1"
14+
15+
_WHEEL_DIR = "/usr/share/python-wheels/"
16+
17+
_wheels = {}
18+
19+
def _get_most_recent_wheel_version(pkg):
20+
prefix = os.path.join(_WHEEL_DIR, "{}-".format(pkg))
21+
_wheels[pkg] = {}
22+
for suffix in "-py2.py3-none-any.whl", "-py3-none-any.whl":
23+
pattern = "{}*{}".format(prefix, suffix)
24+
for path in glob.glob(pattern):
25+
version_str = path[len(prefix):-len(suffix)]
26+
_wheels[pkg][version_str] = os.path.basename(path)
27+
return str(max(_wheels[pkg], key=distutils.version.LooseVersion))
28+
29+
30+
_SETUPTOOLS_VERSION = _get_most_recent_wheel_version("setuptools")
31+
32+
_PIP_VERSION = _get_most_recent_wheel_version("pip")
33+
1634
_PROJECTS = [
1735
("setuptools", _SETUPTOOLS_VERSION, "py3"),
1836
("pip", _PIP_VERSION, "py3"),
@@ -106,13 +124,10 @@ def _bootstrap(*, root=None, upgrade=False, user=False,
106124
# additional paths that need added to sys.path
107125
additional_paths = []
108126
for project, version, py_tag in _PROJECTS:
109-
wheel_name = "{}-{}-{}-none-any.whl".format(project, version, py_tag)
110-
whl = resources.read_binary(
111-
_bundled,
112-
wheel_name,
113-
)
114-
with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
115-
fp.write(whl)
127+
wheel_name = _wheels[project][version]
128+
with open(os.path.join(_WHEEL_DIR, wheel_name), "rb") as sfp:
129+
with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
130+
fp.write(sfp.read())
116131

117132
additional_paths.append(os.path.join(tmpdir, wheel_name))
118133

0 commit comments

Comments
 (0)