]> git.ipfire.org Git - thirdparty/knot-dns.git/commitdiff
distro/rpm: use modern %pyproject_* macros
authorJakub Ružička <jakub.ruzicka@nic.cz>
Mon, 12 May 2025 11:38:56 +0000 (13:38 +0200)
committerJakub Ružička <jakub.ruzicka@nic.cz>
Tue, 3 Jun 2025 09:52:44 +0000 (11:52 +0200)
Support new %pyproject_* macros where they're supported, otherwise use
older %py3_* macros which work everywhere.

Introduce new %{PYPROJECT} var which is only set on distros supporting
new macros - Fedora >= 40 and EL >= 9.

distro/pkg/rpm/knot.spec

index f1813345fcea6b39802b4449b1213b97b507480d..3643ce5b5603dda17e25be933d21d28835649cd3 100644 (file)
@@ -2,6 +2,13 @@
 %{!?_pkgdocdir: %global _pkgdocdir %{_docdir}/%{name}}
 
 %define GPG_CHECK 0
+%if 0%{?fedora} >= 40 || 0%{?rhel} >= 9
+# use modern %pyproject_* macros on distros which support them
+%define PYPROJECT 1
+%else
+# use older %py3_* macros on older/other distros
+%define PYPROJECT 0
+%endif
 %define BASE_VERSION %(echo "%{version}" | sed 's/^\\([^.]\\+\\.[^.]\\+\\).*/\\1/')
 %define repodir %{_builddir}/%{name}-%{version}
 
@@ -51,7 +58,13 @@ BuildRequires:       pkgconfig(libmaxminddb)
 BuildRequires: pkgconfig(libbpf)
 # Python modules (python3-libknot, knot-exporter) dependencies
 BuildRequires:  python3-devel
+%if 0%{?PYPROJECT}
+BuildRequires:  pyproject-rpm-macros
+BuildRequires:  python3-pip
+BuildRequires:  python3-hatchling
+%else
 BuildRequires:  python3-setuptools
+%endif
 
 # Distro-dependent dependencies
 %if 0%{?suse_version}
@@ -198,11 +211,19 @@ make html
 
 # build python3-libknot
 pushd python/libknot
+%if %{PYPROJECT}
+%pyproject_wheel
+%else
 %py3_build
+%endif
 popd
 # build knot-exporter
 pushd python/knot_exporter
+%if %{PYPROJECT}
+%pyproject_wheel
+%else
 %py3_build
+%endif
 popd
 
 %install
@@ -210,11 +231,19 @@ make install DESTDIR=%{buildroot}
 
 # install python3-libknot
 pushd python/libknot
+%if %{PYPROJECT}
+%pyproject_install
+%else
 %py3_install
+%endif
 popd
 # install knot-exporter
 pushd python/knot_exporter
+%if %{PYPROJECT}
+%pyproject_install
+%else
 %py3_install
+%endif
 popd
 
 # install documentation
@@ -341,11 +370,11 @@ getent passwd knot >/dev/null || \
 %files exporter
 %{_bindir}/knot-exporter
 %{python3_sitelib}/knot_exporter
-%{python3_sitelib}/knot_exporter-*.egg-info
+%{python3_sitelib}/knot_exporter-*-info
 
 %files -n python3-libknot
 %{python3_sitelib}/libknot
-%{python3_sitelib}/libknot-*.egg-info
+%{python3_sitelib}/libknot-*-info
 
 %files libs
 %license COPYING