Add pyproject-srpm-macros with a minimal %pyproject_buildrequires macro

pyproject-srpm-macros is intended to be installed in the default buildroot.

That way, no explicit BuildRequires for pyproject-rpm-macros are required,
as long as %pyproject_buildrequires is used in %generate_buildrequires.

When only pyproject-srpm-macros is installed, the minimal implementation of
%pyproject_buildrequires generates a dependency on pyproject-rpm-macros.
When pyproject-rpm-macros is installed, it overrides the implementation
of %pyproject_buildrequires with the full one.

Note that in Fedora, pyproject-rpm-macros is required by python3-devel,
but not in RHEL.
This allows us to keep pyproject-rpm-macros in the RHEL CRB repository.
This commit is contained in:
Miro Hrončok 2023-01-06 13:41:07 +01:00
parent 05aaf0674a
commit a4d05ba2c2
4 changed files with 36 additions and 5 deletions

View File

@ -0,0 +1,7 @@
# This file is called macros.aaa-pyproject-srpm
# to sort alphabetically before macros.pyproject.
# When this file is installed but macros.pyproject is not
# this macro will cause the package with the real macro to be installed.
# When macros.pyproject is installed, it overrides this macro.
# Note: This needs to maintain the same set of options as the real macro.
%pyproject_buildrequires(rRxtNwe:) echo 'pyproject-rpm-macros' && exit 0

View File

@ -124,6 +124,7 @@ fi
%toxenv %{default_toxenv} %toxenv %{default_toxenv}
# Note: Keep the options in sync with this macro from macros.aaa-pyproject-srpm
%pyproject_buildrequires(rRxtNwe:) %{expand:\\\ %pyproject_buildrequires(rRxtNwe:) %{expand:\\\
%_set_pytest_addopts %_set_pytest_addopts
# The _auto_set_build_flags feature does not do this in %%generate_buildrequires section, # The _auto_set_build_flags feature does not do this in %%generate_buildrequires section,
@ -144,7 +145,7 @@ fi
%{-w:%{error:The -N and -w options are mutually exclusive}} %{-w:%{error:The -N and -w options are mutually exclusive}}
} }
%{-e:%{expand:%global toxenv %(%{__python3} -s %{_rpmconfigdir}/redhat/pyproject_construct_toxenv.py %{?**})}} %{-e:%{expand:%global toxenv %(%{__python3} -s %{_rpmconfigdir}/redhat/pyproject_construct_toxenv.py %{?**})}}
echo 'pyproject-rpm-macros' # we already have this installed, but this way, it's repoqueryable echo 'pyproject-rpm-macros' # first stdout line matches the implementation in macros.aaa-pyproject-srpm
echo 'python%{python3_pkgversion}-devel' echo 'python%{python3_pkgversion}-devel'
echo 'python%{python3_pkgversion}dist(pip) >= 19' echo 'python%{python3_pkgversion}dist(pip) >= 19'
echo 'python%{python3_pkgversion}dist(packaging)' echo 'python%{python3_pkgversion}dist(packaging)'

View File

@ -10,11 +10,12 @@ License: MIT
# Increment Y and reset Z when new macros or features are added # Increment Y and reset Z when new macros or features are added
# Increment Z when this is a bugfix or a cosmetic change # Increment Z when this is a bugfix or a cosmetic change
# Dropping support for EOL Fedoras is *not* considered a breaking change # Dropping support for EOL Fedoras is *not* considered a breaking change
Version: 1.5.1 Version: 1.6.0
Release: 2%{?dist} Release: 1%{?dist}
# Macro files # Macro files
Source001: macros.pyproject Source001: macros.pyproject
Source002: macros.aaa-pyproject-srpm
# Implementation files # Implementation files
Source101: pyproject_buildrequires.py Source101: pyproject_buildrequires.py
@ -62,6 +63,7 @@ BuildRequires: python3-rpm-macros
Requires: python-rpm-macros Requires: python-rpm-macros
Requires: python-srpm-macros Requires: python-srpm-macros
Requires: python3-rpm-macros Requires: python3-rpm-macros
Requires: (pyproject-srpm-macros = %{?epoch:%{epoch}:}%{version}-%{release} if pyproject-srpm-macros)
# We use the following tools outside of coreutils # We use the following tools outside of coreutils
Requires: /usr/bin/find Requires: /usr/bin/find
@ -82,6 +84,17 @@ These macros replace %%py3_build and %%py3_install,
which only work with setup.py. which only work with setup.py.
%package -n pyproject-srpm-macros
Summary: Minimal implementation of %%pyproject_buildrequires
Requires: (pyproject-rpm-macros = %{?epoch:%{epoch}:}%{version}-%{release} if pyproject-rpm-macros)
%description -n pyproject-srpm-macros
This package contains a minimal implementation of %%pyproject_buildrequires.
When used in %%generate_buildrequires, it will generate BuildRequires
for pyproject-rpm-macros. When both packages are installed, the full version
takes precedence.
%prep %prep
# Not strictly necessary but allows working on file names instead # Not strictly necessary but allows working on file names instead
# of source numbers in install section # of source numbers in install section
@ -95,6 +108,7 @@ cp -p %{sources} .
mkdir -p %{buildroot}%{_rpmmacrodir} mkdir -p %{buildroot}%{_rpmmacrodir}
mkdir -p %{buildroot}%{_rpmconfigdir}/redhat mkdir -p %{buildroot}%{_rpmconfigdir}/redhat
install -pm 644 macros.pyproject %{buildroot}%{_rpmmacrodir}/ install -pm 644 macros.pyproject %{buildroot}%{_rpmmacrodir}/
install -pm 644 macros.aaa-pyproject-srpm %{buildroot}%{_rpmmacrodir}/
install -pm 644 pyproject_buildrequires.py %{buildroot}%{_rpmconfigdir}/redhat/ install -pm 644 pyproject_buildrequires.py %{buildroot}%{_rpmconfigdir}/redhat/
install -pm 644 pyproject_convert.py %{buildroot}%{_rpmconfigdir}/redhat/ install -pm 644 pyproject_convert.py %{buildroot}%{_rpmconfigdir}/redhat/
install -pm 644 pyproject_save_files.py %{buildroot}%{_rpmconfigdir}/redhat/ install -pm 644 pyproject_save_files.py %{buildroot}%{_rpmconfigdir}/redhat/
@ -126,7 +140,15 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
%doc README.md %doc README.md
%license LICENSE %license LICENSE
%files -n pyproject-srpm-macros
%{_rpmmacrodir}/macros.aaa-pyproject-srpm
%license LICENSE
%changelog %changelog
* Fri Jan 20 2023 Miro Hrončok <miro@hroncok.cz> - 1.6.0-1
- Add pyproject-srpm-macros with a minimal %%pyproject_buildrequires macro
* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.1-2 * Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

View File

@ -8,12 +8,13 @@ URL: https://entrypoints.readthedocs.io/
Source0: %{pypi_source} Source0: %{pypi_source}
BuildArch: noarch BuildArch: noarch
BuildRequires: pyproject-rpm-macros
BuildRequires: python3-devel
%description %description
This package contains one .py module This package contains one .py module
Building this tests the flit build backend. Building this tests the flit build backend.
This package also has no explicit BuildRequires for python or the macros,
testing the minimal implementation of %%pyproject_buildrequires
from pyproject-srpm-macros.
%package -n python3-%{pypi_name} %package -n python3-%{pypi_name}