From 9b1359cb07fde965d620f8f3b94af39930eab890 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Fri, 17 Nov 2023 17:12:58 +0100 Subject: [PATCH] Make it build on older EL releases Signed-off-by: Nils Philippsen --- python-rpmautospec-core.spec | 48 ++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/python-rpmautospec-core.spec b/python-rpmautospec-core.spec index 8551fd8..354eeeb 100644 --- a/python-rpmautospec-core.spec +++ b/python-rpmautospec-core.spec @@ -1,3 +1,15 @@ +%if ! 0%{?rhel} || 0%{?rhel} >= 10 +%bcond_without testcoverage +%bcond_with compatbuild +%else +%bcond_with testcoverage +%bcond_without compatbuild +%endif + +%if 0%{undefined pyproject_files} +%global pyproject_files %{_builddir}/%{name}-%{version}-%{release}.%{_arch}-pyproject-files +%endif + %global srcname rpmautospec_core %global canonicalname %{py_dist_name %{srcname}} @@ -13,11 +25,17 @@ BuildArch: noarch BuildRequires: python3-devel >= 3.6.0 # The dependencies needed for testing don’t get auto-generated. BuildRequires: python3dist(pytest) +%if %{with testcoverage} BuildRequires: python3dist(pytest-cov) +%endif BuildRequires: sed +%if %{without compatbuild} %generate_buildrequires %pyproject_buildrequires +%else +BuildRequires: python3dist(setuptools) +%endif %global _description %{expand: This package contains minimum functionality to determine if an RPM spec file @@ -27,26 +45,56 @@ uses rpmautospec features.} %package -n python3-%{canonicalname} Summary: %{summary} +%if %{with compatbuild} +%py_provides python3-%{canonicalname} +%endif %description -n python3-%{canonicalname} %_description %prep %autosetup -n %{srcname}-%{version} +%if %{without testcoverage} +cat << PYTESTINI > pytest.ini +[pytest] +addopts = +PYTESTINI +%endif + +%if %{with compatbuild} +cat << SETUPPY > setup.py +from setuptools import setup + +setup(name="%{canonicalname}", version="%{version}") +SETUPPY +%endif + %build +%if %{without compatbuild} %pyproject_wheel +%else +%py3_build +%endif %install +%if %{without compatbuild} %pyproject_install %pyproject_save_files %{srcname} # Work around poetry not listing license files as such in package metadata. sed -i -e 's|^\(.*/LICENSE\)|%%license \1|g' %{pyproject_files} +%else +%py3_install +echo '%{python3_sitelib}/%{srcname}*' > %{pyproject_files} +%endif %check %pytest %files -n python3-%{canonicalname} -f %{pyproject_files} %doc README.md +%if %{with compatbuild} +%license LICENSE +%endif %changelog %autochangelog