Avoid needlesly BuildRequiring python3-rich when not running tests and on RHEL

This commit is contained in:
Miro Hrončok 2023-09-26 15:13:08 +02:00
parent 29ac9271ec
commit 6fe5e182cc

View File

@ -23,7 +23,7 @@ BuildRequires: mercurial
BuildRequires: python3dist(pytest)
BuildRequires: python3dist(setuptools) >= 45
# virtualenv omitted, see https://github.com/pypa/setuptools_scm/pull/940
# rich omitted, pulled in as build-backend dependency
# rich omitted, pulled in only with the [rich] extra
%endif
%description
@ -39,15 +39,26 @@ Setuptools_scm handles managing your Python package versions in SCM metadata.
It also handles file finders for the supported SCMs.
%pyproject_extras_subpkg -n python%{python3_pkgversion}-setuptools_scm toml
# We don't package the [rich] extra on RHELs, to avoid pulling rich into the buildroot
%pyproject_extras_subpkg -n python%{python3_pkgversion}-setuptools_scm toml%{!?rhel:,rich}
%prep
%autosetup -p1 -n setuptools-scm-%{version}
# Upstream bogusly declares rich as a build-system dependency,
# but the build works without it.
# We remove it here to simplify the bootstrap loop
# and to avoid the dependency in RHEL builds.
# Upstream issue: https://github.com/pypa/setuptools_scm/issues/941
# Upstream PR: https://github.com/pypa/setuptools_scm/pull/942
# The PR does not apply cleanly to 8.0.3, so we sed it out instead.
# The sed removes the first line with "rich" only:
sed -i '0,/"rich"/{/"rich"/d}' pyproject.toml
%generate_buildrequires
%pyproject_buildrequires
%pyproject_buildrequires %{?with_tests:%{!?rhel:-x rich}}
%build