Use RPM packaged wheels

This commit is contained in:
Miro Hrončok 2018-08-21 12:10:46 +02:00
parent 5af0686d52
commit 5b97503dda
2 changed files with 107 additions and 1 deletions

71
189-use-rpm-wheels.patch Normal file
View File

@ -0,0 +1,71 @@
diff --git a/lib-python/2.7/ensurepip/__init__.py b/lib-python/2.7/ensurepip/__init__.py
index c2abed8..bd1aa79 100644
--- a/lib-python/2.7/ensurepip/__init__.py
+++ b/lib-python/2.7/ensurepip/__init__.py
@@ -1,9 +1,10 @@
#!/usr/bin/env python2
from __future__ import print_function
+import distutils.version
+import glob
import os
import os.path
-import pkgutil
import shutil
import sys
import tempfile
@@ -11,10 +12,20 @@ import tempfile
__all__ = ["version", "bootstrap"]
+_WHEEL_DIR = "/usr/share/python-wheels/"
-_SETUPTOOLS_VERSION = "28.8.0"
-_PIP_VERSION = "9.0.1"
+def _get_most_recent_wheel_version(pkg):
+ prefix = os.path.join(_WHEEL_DIR, "{}-".format(pkg))
+ suffix = "-py2.py3-none-any.whl"
+ pattern = "{}*{}".format(prefix, suffix)
+ versions = (p[len(prefix):-len(suffix)] for p in glob.glob(pattern))
+ return str(max(versions, key=distutils.version.LooseVersion))
+
+
+_SETUPTOOLS_VERSION = _get_most_recent_wheel_version("setuptools")
+
+_PIP_VERSION = _get_most_recent_wheel_version("pip")
_PROJECTS = [
("setuptools", _SETUPTOOLS_VERSION),
@@ -28,8 +39,13 @@ def _run_pip(args, additional_paths=None):
sys.path = additional_paths + sys.path
# Install the bundled software
- import pip
- pip.main(args)
+ try:
+ # pip 10
+ from pip._internal import main
+ except ImportError:
+ # pip 9
+ from pip import main
+ main(args)
def version():
@@ -85,12 +101,9 @@ def bootstrap(root=None, upgrade=False, user=False,
additional_paths = []
for project, version in _PROJECTS:
wheel_name = "{}-{}-py2.py3-none-any.whl".format(project, version)
- whl = pkgutil.get_data(
- "ensurepip",
- "_bundled/{}".format(wheel_name),
- )
- with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
- fp.write(whl)
+ with open(os.path.join(_WHEEL_DIR, wheel_name), "rb") as sfp:
+ with open(os.path.join(tmpdir, wheel_name), "wb") as fp:
+ fp.write(sfp.read())
additional_paths.append(os.path.join(tmpdir, wheel_name))

View File

@ -18,6 +18,10 @@ ExcludeArch: aarch64 %{power64}
# High-level configuration of the build:
# Whether to use RPM build wheels from the python-{pip,setuptools}-wheel package
# Uses upstream bundled prebuilt wheels otherwise
%bcond_without rpmwheels
# PyPy consists of an implementation of an interpreter (with JIT compilation)
# for the full Python language written in a high-level language, leaving many
# of the implementation details as "pluggable" policies.
@ -163,6 +167,11 @@ Patch1: 007-remove-startup-message.patch
# https://fedoraproject.org/wiki/Changes/Replace_glibc_libcrypt_with_libxcrypt
Patch2: 009-add-libxcrypt-support.patch
# Instead of bundled wheels, use our RPM packaged wheels from
# /usr/share/python-wheels
# We conditionally apply this, but we use autosetup, so we use Source here
Source189: 189-use-rpm-wheels.patch
# Build-time requirements:
# pypy's can be rebuilt using itself, rather than with CPython; doing so
@ -226,6 +235,14 @@ BuildRequires: execstack
BuildRequires: emacs
%endif
# For %%autosetup -S git
BuildRequires: %{_bindir}/git
%if %{with rpmwheels}
BuildRequires: python-setuptools-wheel
BuildRequires: python-pip-wheel
%endif
# Metadata for the core package (the JIT build):
Requires: %{name}-libs%{?_isa} = %{version}-%{release}
Provides: %{ver_name} = %{version}-%{release}
@ -255,6 +272,14 @@ Summary: Run-time libraries used by PyPy implementations of Python
Requires: emacs-filesystem >= %{_emacs_version}
%endif
%if %{with rpmwheels}
Requires: python-setuptools-wheel
Requires: python-pip-wheel
%else
Provides: bundled(python3-pip) = 9.0.1
Provides: bundled(python3-setuptools) = 28.8.0
%endif
Provides: %{ver_name}-libs = %{version}-%{release}
Provides: %{ver_name}-libs%{_isa} = %{version}-%{release}
%description libs
@ -285,7 +310,14 @@ Build of PyPy with support for micro-threads for massive concurrency
%prep
%autosetup -p1 -n %{src_name}
%autosetup -n %{src_name} -p1 -S git
%if %{with rpmwheels}
%apply_patch -m %(basename %{SOURCE189}) %{SOURCE189}
rm lib-python/2.7/ensurepip/_bundled/*.whl
rmdir lib-python/2.7/ensurepip/_bundled
%endif
# Replace /usr/local/bin/python shebangs with /usr/bin/python:
find -name "*.py" -exec \
sed \
@ -768,6 +800,9 @@ CheckPyPy %{name}-c-stackless
%changelog
* Tue Aug 21 2018 Miro Hrončok <mhroncok@redhat.com> - 6.0.0-3
- Use RPM packaged wheels
* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 6.0.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild