Make build python3-only compatible for distributions that want that

This commit is contained in:
Colin Walters 2018-07-16 21:30:32 +00:00
parent 2a0fd3d7c1
commit c92a606d60
2 changed files with 74 additions and 8 deletions

View File

@ -0,0 +1,61 @@
From 696cad7df63dad0ba89a9f2fdfdd05cdf02c0ada Mon Sep 17 00:00:00 2001
From: Colin Walters <walters@verbum.org>
Date: Mon, 16 Jul 2018 15:05:37 -0400
Subject: [PATCH] build-sys: Use python3 for libdnf by default if available
Probably at some point libdnf will drop py2 support, but the
main reason I'm doing this is avoids a python2 dependency
for rpm-ostree for distributions that don't want that.
---
configure.ac | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/configure.ac b/configure.ac
index 66c4a933..043115a6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -113,6 +113,23 @@ AS_IF([pkg-config --atleast-version=4.13.0.1 rpm], [
AC_PATH_PROG([XSLTPROC], [xsltproc])
+dnl This was painful to figure out; it's sad that Automake's
+dnl python support doesn't do a better job of optionally supporting
+dnl both 2 and 3. Anyways the logic here is: Honor $PYTHON if set
+dnl uncondionally, otherwise try python3 if it appears to be available
+dnl first, then fall back to 2.
+dnl Recommendation is explicit PYTHON=python3 ./configure ...
+AS_IF([test -z "$PYTHON"], [
+ AS_IF([test -x /usr/bin/python3], [
+ AM_PATH_PYTHON([3.6])
+ ], [
+ AM_PATH_PYTHON([2.7])
+ ])
+])
+dnl http://maemo.org/maemo_training_material/maemo4.x/html/maemo_Application_Development_Chinook/Chapter_05_GNU_Autotools.html
+dnl incorrectly says the quoted ']' is @>:@ (...crying...)
+pyver=$($PYTHON -c "import sys; sys.stdout.write(sys.version @<:@ :3 @:>@ )")
+
GLIB_TESTS
LIBGLNX_CONFIGURE
@@ -226,6 +243,10 @@ else
export cmake_args
fi
+case $pyver in
+ 3.*) cmake_args="${cmake_args} -DPYTHON_DESIRED:str=3";;
+esac
+
dnl I picked /usr/libexec/rpm-ostree just because we need an
dnl arbitrary path - we don't actually install there.
(set -euo pipefail; mkdir -p libdnf-build && cd libdnf-build &&
@@ -257,5 +278,6 @@ echo "
introspection: $found_introspection
bubblewrap: $with_bubblewrap
gtk-doc: $enable_gtk_doc
+ python: $PYTHON $pyver
rust: $enable_rust
"
--
2.17.1

View File

@ -14,6 +14,7 @@ Release: 3%{?dist}
# This tarball is generated via "cd packaging && make -f Makefile.dist-packaging dist-snapshot"
# in the upstream git. If rust is enabled, it contains vendored sources.
Source0: rpm-ostree-%{version}.tar.xz
Patch1: 0001-build-sys-Use-python3-for-libdnf-by-default-if-avail.patch
License: LGPLv2+
URL: https://github.com/projectatomic/rpm-ostree
@ -53,12 +54,13 @@ BuildRequires: pkgconfig(librepo)
BuildRequires: cmake
BuildRequires: pkgconfig(expat)
BuildRequires: pkgconfig(check)
BuildRequires: python2-devel
# https://github.com/CentOS/sig-atomic-buildscripts/issues/324
%if (0%{?rhel} != 0 && 0%{?rhel} <= 7)
BuildRequires: python-devel
BuildRequires: python-sphinx
%else
BuildRequires: python2-sphinx
BuildRequires: python3-sphinx
BuildRequires: python3-devel
%endif
%if (0%{?rhel} != 0 && 0%{?rhel} <= 7)
BuildRequires: libsolv-devel
@ -127,7 +129,6 @@ find $RPM_BUILD_ROOT -name '*.la' -delete
# way the same spec file works more easily across multiple versions where e.g. an
# older version might not have a systemd unit file.
cat > autofiles.py <<EOF
#!/usr/bin/python
import os,sys,glob
os.chdir(os.environ['RPM_BUILD_ROOT'])
for line in sys.argv[1:]:
@ -143,7 +144,11 @@ for line in sys.argv[1:]:
else:
sys.stderr.write('{0} did not match any files\n'.format(line))
EOF
python autofiles.py > files \
PYTHON=python3
if ! test -x /usr/bin/python3; then
PYTHON=python2
fi
$PYTHON autofiles.py > files \
'%{_bindir}/*' \
'%{_libdir}/%{name}' \
'%{_mandir}/man*/*' \
@ -154,11 +159,11 @@ python autofiles.py > files \
'%{_datadir}/polkit-1/actions/*.policy' \
'%{_datadir}/dbus-1/system-services'
python autofiles.py > files.lib \
$PYTHON autofiles.py > files.lib \
'%{_libdir}/*.so.*' \
'%{_libdir}/girepository-1.0/*.typelib'
python autofiles.py > files.devel \
$PYTHON autofiles.py > files.devel \
'%{_libdir}/lib*.so' \
'%{_includedir}/*' \
'%{_datadir}/dbus-1/interfaces/org.projectatomic.rpmostree1.xml' \
@ -174,8 +179,8 @@ python autofiles.py > files.devel \
%files devel -f files.devel
%changelog
* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 2018.6-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild
* Mon Jul 16 2018 Colin Walters <walters@verbum.org> - 2018.6-3
- Make build python3-only compatible for distributions that want that
* Fri Jun 29 2018 Jonathan Lebon <jonathan@jlebon.com> - 2018.6-2
- Rebuild for yummy Rusty bitsy