aboutsummaryrefslogtreecommitdiffstats
path: root/rpm
diff options
context:
space:
mode:
authorBrian Behlendorf <[email protected]>2018-10-31 09:22:59 -0700
committerBrian Behlendorf <[email protected]>2019-01-06 10:39:41 -0800
commit6e72a5b9b61066146deafda39ab8158c559f5f15 (patch)
tree9439fbf7ba661e5d12fec2699a3d9c554791cc3b /rpm
parent4b1c4062d050e2cfa609e1040384d1f3b5f04f52 (diff)
pyzfs: python3 support (build system)
Almost all of the Python code in the respository has been updated to be compatibile with Python 2.6, Python 3.4, or newer. The only exceptions are arc_summery3.py which requires Python 3, and pyzfs which requires at least Python 2.7. This allows us to maintain a single version of the code and support most default versions of python. This change does the following: * Sets the default shebang for all Python scripts to python3. If only Python 2 is available, then at install time scripts which are compatible with Python 2 will have their shebangs replaced with /usr/bin/python. This is done for compatibility until Python 2 goes end of life. Since only the installed versions are changed this means Python 3 must be installed on the system for test-runner when testing in-tree. * Added --with-python=<2|3|3.4,etc> configure option which sets the PYTHON environment variable to target a specific python version. By default the newest installed version of Python will be used or the preferred distribution version when creating pacakges. * Fixed --enable-pyzfs configure checks so they are run when --enable-pyzfs=check and --enable-pyzfs=yes. * Enabled pyzfs for Python 3.4 and newer, which is now supported. * Renamed pyzfs package to python<VERSION>-pyzfs and updated to install in the appropriate site location. For example, when building with --with-python=3.4 a python34-pyzfs will be created which installs in /usr/lib/python3.4/site-packages/. * Renamed the following python scripts according to the Fedora guidance for packaging utilities in /bin - dbufstat.py -> dbufstat - arcstat.py -> arcstat - arc_summary.py -> arc_summary - arc_summary3.py -> arc_summary3 * Updated python-cffi package name. On CentOS 6, CentOS 7, and Amazon Linux it's called python-cffi, not python2-cffi. For Python3 it's called python3-cffi or python3x-cffi. * Install one version of arc_summary. Depending on the version of Python available install either arc_summary2 or arc_summary3 as arc_summary. The user output is only slightly different. Reviewed-by: John Ramsden <[email protected]> Reviewed-by: Neal Gompa <[email protected]> Reviewed-by: loli10K <[email protected]> Signed-off-by: Brian Behlendorf <[email protected]> Closes #8096
Diffstat (limited to 'rpm')
-rw-r--r--rpm/generic/zfs.spec.in79
1 files changed, 56 insertions, 23 deletions
diff --git a/rpm/generic/zfs.spec.in b/rpm/generic/zfs.spec.in
index 55edbc83f..533792989 100644
--- a/rpm/generic/zfs.spec.in
+++ b/rpm/generic/zfs.spec.in
@@ -53,16 +53,6 @@
%bcond_with asan
%bcond_with systemd
-# Python permits the !/usr/bin/python shebang for scripts that are cross
-# compatible between python2 and python3, but Fedora 28 does not. Fedora
-# wants us to choose python3 for cross-compatible scripts. Since we want
-# to support python2 and python3 users, exclude our scripts from Fedora 28's
-# RPM build check, so that we don't get a bunch of build warnings.
-#
-# Details: https://github.com/zfsonlinux/zfs/issues/7360
-#
-%global __brp_mangle_shebangs_exclude_from arc_summary.py|arcstat.py|dbufstat.py|test-runner.py|zts-report.py
-
# Generic enable switch for systemd
%if %{with systemd}
%define _systemd 1
@@ -85,6 +75,32 @@
%define _systemd 1
%endif
+# When not specified default to distribution provided version. This
+# is normally Python 3, but for RHEL <= 7 only Python 2 is provided.
+%if %{undefined __use_python}
+%if 0%{?rhel} && 0%{?rhel} <= 7
+%define __python /usr/bin/python2
+%define __python_pkg_version 2
+%define __python_cffi_pkg python-cffi
+%else
+%define __python /usr/bin/python3
+%define __python_pkg_version 3
+%define __python_cffi_pkg python3-cffi
+%endif
+%else
+%define __python %{__use_python}
+%define __python_pkg_version %{__use_python_pkg_version}
+%define __python_cffi_pkg python%{__python_pkg_version}-cffi
+%endif
+
+# By default python-pyzfs is enabled, with the exception of
+# RHEL 6 which by default uses Python 2.6 which is too old.
+%if 0%{?rhel} == 6
+%bcond_with pyzfs
+%else
+%bcond_without pyzfs
+%endif
+
Name: @PACKAGE@
Version: @VERSION@
Release: @RELEASE@%{?dist}
@@ -135,7 +151,7 @@ Requires: util-linux
Requires: sysstat
%description
-This package contains the ZFS command line utilities.
+This package contains the core ZFS command line utilities.
%package -n libzpool2
Summary: Native ZFS pool library for Linux
@@ -219,6 +235,7 @@ Requires: acl
Requires: sudo
Requires: sysstat
Requires: libaio
+Requires: python%{__python_pkg_version}
%if 0%{?rhel}%{?fedora}%{?suse_version}
BuildRequires: libaio-devel
%endif
@@ -240,23 +257,23 @@ Requires: grep
This package contains a dracut module used to construct an initramfs
image which is ZFS aware.
-%if 0%{?_pyzfs}
-%package -n pyzfs
-Summary: Python wrapper for libzfs_core
+%if %{with pyzfs}
+%package -n python%{__python_pkg_version}-pyzfs
+Summary: Python %{python_version} wrapper for libzfs_core
Group: Development/Languages/Python
License: Apache-2.0
BuildArch: noarch
Requires: libzfs2 = %{version}
Requires: libnvpair1 = %{version}
Requires: libffi
-Requires: python >= 2.7
-Requires: python-cffi
+Requires: python%{__python_pkg_version}
+Requires: %{__python_cffi_pkg}
%if 0%{?rhel}%{?fedora}%{?suse_version}
-BuildRequires: python-devel
+BuildRequires: python%{__python_pkg_version}-devel
BuildRequires: libffi-devel
%endif
-%description -n pyzfs
+%description -n python%{__python_pkg_version}-pyzfs
This package provides a python wrapper for the libzfs_core C library.
%endif
@@ -299,6 +316,12 @@ image which is ZFS aware.
%define systemd --enable-sysvinit --disable-systemd
%endif
+%if %{with pyzfs}
+ %define pyzfs --enable-pyzfs
+%else
+ %define pyzfs --disable-pyzfs
+%endif
+
%setup -q
%build
@@ -307,11 +330,13 @@ image which is ZFS aware.
--with-udevdir=%{_udevdir} \
--with-udevruledir=%{_udevruledir} \
--with-dracutdir=%{_dracutdir} \
+ --with-python=%{__python} \
--disable-static \
%{debug} \
%{debuginfo} \
%{asan} \
- %{systemd}
+ %{systemd}\
+ %{pyzfs}
make %{?_smp_mflags}
%install
@@ -379,12 +404,20 @@ systemctl --system daemon-reload >/dev/null || true
%endif
%files
+# Core utilities
%{_sbindir}/*
-%{_bindir}/*
-%{_libexecdir}/%{name}
+%{_bindir}/raidz_test
+%{_bindir}/zgenhostid
+# Optional Python 2/3 scripts
+%{_bindir}/arc_summary
+%{_bindir}/arcstat
+%{_bindir}/dbufstat
+# Man pages
%{_mandir}/man1/*
%{_mandir}/man5/*
%{_mandir}/man8/*
+# Configuration files and scripts
+%{_libexecdir}/%{name}
%{_udevdir}/vdev_id
%{_udevdir}/zvol_id
%{_udevdir}/rules.d/*
@@ -426,8 +459,8 @@ systemctl --system daemon-reload >/dev/null || true
%doc contrib/dracut/README.dracut.markdown
%{_dracutdir}/modules.d/*
-%if 0%{?_pyzfs}
-%files -n pyzfs
+%if %{with pyzfs}
+%files -n python%{__python_pkg_version}-pyzfs
%doc contrib/pyzfs/README
%doc contrib/pyzfs/LICENSE
%defattr(-,root,root,-)