Enable bootstrapping macros

Since rpmautospec has a circular dependency chain with several other
packages, this patch adds the ability to build with `--with bootstrap` to
temporarily disable some functionality (pytest-xdist, manpage
generation).

On RHEL, it will skip pytest-xdist entirely, since that dependency
provides no value beyond quicker test runs.

For good measure, it also adds a `--without tests` option to speed up
packaging attempts.

Signed-off-by: Stephen Gallagher <sgallagh@redhat.com>
epel9
Stephen Gallagher 1 month ago
parent e8793b0ab2
commit d0c93ba765

@ -6,12 +6,16 @@
]
%endif
# The pytest-xdist package is not available when bootstrapping or for EL builds other than EPEL
%if ! 0%{?rhel} || 0%{?epel}
%bcond xdist 1
%else
%bcond xdist 0
%endif
# Set this to 1 when bootstrapping
%bcond bootstrap 0
%bcond tests 1
# While bootstrapping, ignore manpages
%bcond manpages %{without bootstrap}
# The pytest-xdist package is not available when bootstrapping or on RHEL
%bcond xdist %[%{without bootstrap} && %{undefined rhel}]
# Package the placeholder rpm-macros (moved to redhat-rpm-config in F40)
%if ! (0%{?fedora} >= 40 || 0%{?rhel} >= 10)
@ -20,6 +24,9 @@
%bcond rpmmacropkg 0
%endif
%if %{with bootstrap}
%bcond poetry 0
%else
%if ! 0%{?fedora}%{?rhel} || 0%{?fedora} || 0%{?epel} >= 9
%bcond poetry 1
# Appease old Poetry versions (<1.2.0a2)
@ -31,12 +38,18 @@
%else
%bcond poetry 0
%endif
%endif
%global srcname rpmautospec
Name: python-%{srcname}
Version: 0.7.1
%if %{with bootstrap}
Release: 0%{?dist}
%else
Release: %autorelease
%endif
Summary: Package and CLI tool to generate release fields and changelogs
License: MIT
URL: https://github.com/fedora-infra/%{srcname}
@ -53,17 +66,25 @@ BuildRequires: glibc-langpack-de
BuildRequires: glibc-langpack-en
BuildRequires: python3-devel >= 3.9.0
# Needed to build man pages
%if %{with manpages}
BuildRequires: python3dist(click-man)
%endif
%if %{with tests}
# The dependencies needed for testing dont get auto-generated.
BuildRequires: python3dist(pytest)
%if %{with xdist}
BuildRequires: python3dist(pytest-xdist)
%endif
%endif
BuildRequires: python3dist(pyyaml)
BuildRequires: sed
%if %{without poetry}
BuildRequires: python3dist(babel)
BuildRequires: python3dist(click)
BuildRequires: python3dist(click-plugins)
BuildRequires: python3dist(pygit2)
BuildRequires: python3dist(rpm)
BuildRequires: python3dist(rpmautospec-core)
@ -136,10 +157,12 @@ cat << EOF > %{pyproject_files}
EOF
%endif
%if %{with manpages}
# Man pages
PYTHONPATH=%{buildroot}%{python3_sitelib} click-man rpmautospec
install -m755 -d %{buildroot}%{_mandir}/man1
install -m644 man/*.1 %{buildroot}%{_mandir}/man1
%endif
# RPM macros
%if %{with rpmmacropkg}
@ -166,17 +189,28 @@ for shell_path in \
done
%check
# Always run the import checks, even when other tests are disabled
%if %{with poetry}
%pyproject_check_import
%else
%py3_check_import rpmautospec rpmautospec.cli
%endif
%if %{with tests}
%pytest -v \
%if %{with xdist}
--numprocesses=auto
%endif
%endif
%files -n python3-%{srcname} -f %{pyproject_files}
%doc README.rst
%files -n %{srcname}
%{_bindir}/rpmautospec
%if %{with manpages}
%{_mandir}/man1/rpmautospec*.1*
%endif
%dir %{bash_completions_dir}
%{bash_completions_dir}/rpmautospec
%dir %{fish_completions_dir}
@ -190,4 +224,10 @@ done
%endif
%changelog
%if %{undefined autochangelog}
* Thu Jan 01 1970 Anonymous Fedora Packager <devel@lists.fedoraproject.org> - %{version}-%{release}
- Bootstrap build of rpmautospec
%else
%autochangelog
%endif

Loading…
Cancel
Save