From 412abe2ac15539048f297c631597b16d86729bd3 Mon Sep 17 00:00:00 2001 From: Iryna Shcherbina Date: Aug 15 2017 09:09:05 +0000 Subject: Platform-python bootstrap: step 1 - build without platform_python Changes needed for Platform Python Stack change (https://fedoraproject.org/wiki/Changes/Platform_Python_Stack): - Add platform-python bytecompilation patch: platform-python-bytecompile.patch - Add platform python deps generator patch: platform-python-abi.patch - Add a platform-python subpackage and remove system python related declarations - Build rpm without platform_python for bytecompilation (already set in spec file) When platform-python package is built, switch to `%bcond_without platform_python` to build platform-python-rpm subpackage. --- diff --git a/platform-python-abi.patch b/platform-python-abi.patch new file mode 100644 index 0000000..ba4f757 --- /dev/null +++ b/platform-python-abi.patch @@ -0,0 +1,39 @@ +From fef3b646f3facd26dc04cfccdc27c061cfe0ee37 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Mon, 7 Aug 2017 16:28:59 +0200 +Subject: [PATCH] Generate requires and provides for platform-python(abi) + +See https://fedoraproject.org/wiki/Changes/Platform_Python_Stack +--- + scripts/pythondeps.sh | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/scripts/pythondeps.sh b/scripts/pythondeps.sh +index 10a060aac..a6d97ef4f 100755 +--- a/scripts/pythondeps.sh ++++ b/scripts/pythondeps.sh +@@ -13,8 +13,8 @@ case $1 in + # generating a line of the form + # python(abi) = MAJOR.MINOR + # (Don't match against -config tools e.g. /usr/bin/python2.6-config) +- grep "/usr/bin/python.\..$" \ +- | sed -e "s|.*/usr/bin/python\(.\..\)|python(abi) = \1|" ++ egrep '/usr/(bin/|libexec/platform-)python.\..$' \ ++ | sed -r -e "s@.*/usr/(bin/|libexec/(platform-))python(.\..)@\2python(abi) = \3@" + ;; + -R|--requires) + shift +@@ -23,8 +23,8 @@ case $1 in + # /PATH/OF/BUILDROOT/usr/lib64/pythonMAJOR.MINOR/ + # generating (uniqely) lines of the form: + # python(abi) = MAJOR.MINOR +- grep "/usr/lib[^/]*/python.\../.*" \ +- | sed -e "s|.*/usr/lib[^/]*/python\(.\..\)/.*|python(abi) = \1|g" \ ++ egrep '/usr/lib[^/]*/(platform-|)python.\../.*' \ ++ | sed -r -e "s@.*/usr/lib[^/]*/(platform-|)python(.\..)/.*@\1python(abi) = \2@g" \ + | sort | uniq + ;; + esac +-- +2.13.3 + diff --git a/platform-python-bytecompile.patch b/platform-python-bytecompile.patch new file mode 100644 index 0000000..30483af --- /dev/null +++ b/platform-python-bytecompile.patch @@ -0,0 +1,52 @@ +From cc1a08b4a5222e74cae46ee17d4ef297ed63c2a9 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Miro=20Hron=C4=8Dok?= +Date: Tue, 8 Aug 2017 12:27:48 +0200 +Subject: [PATCH] Bytecompile stuff in /usr/lib*/platform-python with + platform-python + +--- + scripts/brp-python-bytecompile | 14 ++++++++++---- + 1 file changed, 10 insertions(+), 4 deletions(-) + +diff --git a/scripts/brp-python-bytecompile b/scripts/brp-python-bytecompile +index 894fa3459..92460b982 100644 +--- a/scripts/brp-python-bytecompile ++++ b/scripts/brp-python-bytecompile +@@ -57,9 +57,15 @@ EOF + # and below /usr/lib/python3.1/, we're targeting /usr/bin/python3.1 + + shopt -s nullglob +-for python_libdir in `find "$RPM_BUILD_ROOT" -type d|grep -E "/usr/lib(64)?/python[0-9]\.[0-9]$"`; ++for python_libdir in `find "$RPM_BUILD_ROOT" -type d|grep -E "/usr/lib(64)?/(platform-)?python[0-9]\.[0-9]$"`; + do +- python_binary=/usr/bin/$(basename $python_libdir) ++ python_basename=$(basename $python_libdir) ++ if [[ $python_basename == platform* ]]; ++ then ++ python_binary=/usr/libexec/$python_basename ++ else ++ python_binary=/usr/bin/$python_basename ++ fi + real_libdir=${python_libdir/$RPM_BUILD_ROOT/} + echo "Bytecompiling .py files below $python_libdir using $python_binary" + +@@ -88,14 +94,14 @@ if [ ! -x "$default_python" ]; then + fi + + # Generate normal (.pyc) byte-compiled files. +-python_bytecompile "" $default_python "/bin/|/sbin/|/usr/lib(64)?/python[0-9]\.[0-9]|/usr/share/doc" "$RPM_BUILD_ROOT" "$depth" "/" ++python_bytecompile "" $default_python "/bin/|/sbin/|/usr/lib(64)?/(platform-)?python[0-9]\.[0-9]|/usr/share/doc" "$RPM_BUILD_ROOT" "$depth" "/" + if [ $? -ne 0 -a 0$errors_terminate -ne 0 ]; then + # One or more of the files had a syntax error + exit 1 + fi + + # Generate optimized (.pyo) byte-compiled files. +-python_bytecompile "-O" $default_python "/bin/|/sbin/|/usr/lib(64)?/python[0-9]\.[0-9]|/usr/share/doc" "$RPM_BUILD_ROOT" "$depth" "/" ++python_bytecompile "-O" $default_python "/bin/|/sbin/|/usr/lib(64)?/(platform-)?python[0-9]\.[0-9]|/usr/share/doc" "$RPM_BUILD_ROOT" "$depth" "/" + if [ $? -ne 0 -a 0$errors_terminate -ne 0 ]; then + # One or more of the files had a syntax error + exit 1 +-- +2.13.3 + diff --git a/rpm.spec b/rpm.spec index c90f848..ba2e3ed 100644 --- a/rpm.spec +++ b/rpm.spec @@ -15,6 +15,16 @@ # build with new db format %bcond_with ndb +# which python subpackages to build (default: all) +# so it can be built in different modules with different subpackages +%bcond_without python2 +%bcond_without python3 +# Note that the rpm package with Patch908 applied has to be in +# the buildroot before platform_python enabled build happens. +# Hence platform_python is disbaled for this build, because this +# is the first build with Patch908 (to be removed in the second build). +%bcond_with platform_python + %define rpmhome /usr/lib/rpm %global rpmver 4.13.90 @@ -29,7 +39,7 @@ Summary: The RPM package management system Name: rpm Version: %{rpmver} -Release: %{?snapver:0.%{snapver}.}3%{?dist} +Release: %{?snapver:0.%{snapver}.}4%{?dist} Group: System Environment/Base Url: http://www.rpm.org/ Source0: http://ftp.rpm.org/releases/%{srcdir}/%{name}-%{srcver}.tar.bz2 @@ -64,6 +74,13 @@ Patch906: rpm-4.7.1-geode-i686.patch # Probably to be upstreamed in slightly different form Patch907: rpm-4.13.90-ldflags.patch +# Use platform-python for bytecompilation in /usr/lib*/platform-python +Patch908: platform-python-bytecompile.patch + +# This patch is currently not part of any built RPM, however, to be +# consistent with python-rpm-generators, we are adding it anyway. +Patch909: platform-python-abi.patch + # Partially GPL/LGPL dual-licensed and some bits with BSD # SourceLicense: (GPLv2+ and LGPLv2+ with exceptions) and BSD License: GPLv2+ @@ -212,6 +229,7 @@ Requires: rpm-build-libs%{_isa} = %{version}-%{release} %description sign This package contains support for digitally signing RPM packages. +%if %{with python2} %package -n python2-%{name} Summary: Python 2 bindings for apps which will manipulate RPM packages Group: Development/Libraries @@ -228,13 +246,14 @@ supplied by RPM Package Manager libraries. This package should be installed if you want to develop Python 2 programs that will manipulate RPM packages and databases. +%endif # with python2 +%if %{with python3} %package -n python3-%{name} Summary: Python 3 bindings for apps which will manipulate RPM packages Group: Development/Libraries BuildRequires: python3-devel %{?python_provide:%python_provide python3-%{name}} -%{?system_python_abi} Requires: %{name}-libs%{?_isa} = %{version}-%{release} Provides: %{name}-python3 = %{version}-%{release} Obsoletes: %{name}-python3 < %{version}-%{release} @@ -246,6 +265,20 @@ supplied by RPM Package Manager libraries. This package should be installed if you want to develop Python 3 programs that will manipulate RPM packages and databases. +%endif # with python3 + +%if %{with platform_python} +%package -n platform-python-%{name} +Summary: Platform Python bindings for apps which will manipulate RPM packages +Group: Development/Libraries +BuildRequires: platform-python-devel +Requires: %{name}-libs%{?_isa} = %{version}-%{release} + +%description -n platform-python-%{name} +The platform-python-rpm package contains a module that permits applications +written in the Python programming language to use the interface +supplied by RPM Package Manager libraries. +%endif # with platform_python %package apidocs Summary: API documentation for RPM libraries @@ -358,13 +391,31 @@ done; --enable-python \ --with-crypto=openssl + +%if %{with platform_python} +# Copy the directory so python3 and platform_python do not share it, +# as they may have the same version and the filenames could collide. +# Do it before `make` to avoid having anything built in there. +cp -a python platform_python +%endif # with platform_python + make %{?_smp_mflags} pushd python +%if %{with python2} %{__python2} setup.py build +%endif # with python2 +%if %{with python3} %{__python3} setup.py build +%endif # with python3 popd +%if %{with platform_python} +pushd platform_python +%{__platform_python} setup.py build +popd +%endif # with platform_python + %install rm -rf $RPM_BUILD_ROOT @@ -373,10 +424,20 @@ make DESTDIR="$RPM_BUILD_ROOT" install # We need to build with --enable-python for the self-test suite, but we # actually package the bindings built with setup.py (#531543#c26) pushd python +%if %{with python2} %{__python2} setup.py install --skip-build --root $RPM_BUILD_ROOT +%endif # with python2 +%if %{with python3} %{__python3} setup.py install --skip-build --root $RPM_BUILD_ROOT +%endif # with python3 popd +%if %{with platform_python} +pushd platform_python +%{__platform_python} setup.py install --skip-build --root $RPM_BUILD_ROOT +popd +%endif # with platform_python + # Save list of packages through cron mkdir -p ${RPM_BUILD_ROOT}%{_sysconfdir}/cron.daily @@ -547,13 +608,24 @@ exit 0 %{_bindir}/rpmsign %{_mandir}/man8/rpmsign.8* +%if %{with python2} %files -n python2-%{name} -%{python_sitearch}/%{name}/ -%{python_sitearch}/%{name}-%{version}*.egg-info +%{python2_sitearch}/%{name}/ +%{python2_sitearch}/%{name}-%{version}*.egg-info +%endif # with python2 + +%if %{with python3} %files -n python3-%{name} %{python3_sitearch}/%{name}/ %{python3_sitearch}/%{name}-%{version}*.egg-info +%endif # with python3 + +%if %{with platform_python} +%files -n platform-python-%{name} +%{platform_python_sitearch}/%{name}/ +%{platform_python_sitearch}/%{name}-%{version}*.egg-info +%endif # with platform_python %files devel %{_mandir}/man8/rpmgraph.8* @@ -571,6 +643,13 @@ exit 0 %doc doc/librpm/html/* %changelog +* Mon Aug 14 2017 Miro HronĨok - 4.13.90-0.git14000.4 +- Add platform-python bytecompilation patch: platform-python-bytecompile.patch +- Add platform python deps generator patch: platform-python-abi.patch +- Add a platform-python subpackage and remove system python related declarations +- Build rpm without platform_python for bytecompilation + (https://fedoraproject.org/wiki/Changes/Platform_Python_Stack) + * Mon Aug 14 2017 Panu Matilainen - 4.13.90-0.git14000.3 - Disable macro argument quoting as a band-aid to #1481025