Add a provisional RPM Declarative Buildsystem (RPM 4.20+)
This commit is contained in:
parent
bc3d8013a4
commit
e7b37d02f8
72
README.md
72
README.md
@ -386,6 +386,78 @@ These arguments are still required:
|
||||
Multiple subpackages are generated when multiple names are provided.
|
||||
|
||||
|
||||
Provisional: Declarative Buildsystem (RPM 4.20+)
|
||||
------------------------------------------------
|
||||
|
||||
It is possible to reduce some of the spec boilerplate by using the provided
|
||||
pyproject [declarative buildsystem].
|
||||
This option is only available with RPM 4.20+ (e.g. in Fedora 41+).
|
||||
The declarative buildsystem is **provisional** and the behavior might change.
|
||||
Please subscribe to Fedora's [python-devel list] if you use the feature.
|
||||
|
||||
To enable the pyproject declarative buildsystem, use the following:
|
||||
|
||||
BuildSystem: pyproject
|
||||
BuildOption(install): <options for %%pyproject_save_files>
|
||||
|
||||
That way, RPM will automatically fill-in the `%prep`, `%generate_buildrequires`,
|
||||
`%build`, `%install`, and `%check` sections the following defaults:
|
||||
|
||||
%prep
|
||||
%autosetup -p1 -C
|
||||
|
||||
%generate_buildrequires
|
||||
%pyproject_buildrequires
|
||||
|
||||
%build
|
||||
%pyproject_wheel
|
||||
|
||||
%install
|
||||
%pyproject_install
|
||||
%pyproject_save_files <options from BuildOption(install)>
|
||||
|
||||
%check
|
||||
%pyproject_check_import
|
||||
|
||||
To pass options to the individual macros, use `BuildOption` (see the [documentation of declarative buildsystems][declarative buildsystem]).
|
||||
|
||||
# pass options for %%pyproject_save_files (mandatory when not overriding %%install)
|
||||
BuildOption(install): -l _module +auto
|
||||
|
||||
# replace the default options for %%autosetup
|
||||
BuildOption(prep): -S git_am -C
|
||||
|
||||
# pass options to %%pyproject_buildrequires
|
||||
BuildOption(generate_buildrequires): docs-requirements.txt -t
|
||||
|
||||
# pass options to %%pyproject_wheel
|
||||
BuildOption(build): -C--global-option=--no-cython-compile
|
||||
|
||||
# pass options to %%pyproject_check_import
|
||||
BuildOption(check): -e '*.test*'
|
||||
|
||||
Alternatively, you can supply your own sections to override the automatic ones:
|
||||
|
||||
BuildOption(generate_buildrequires): -w
|
||||
...
|
||||
%build
|
||||
# do nothing, the wheel was built in %%generate_buildrequires
|
||||
|
||||
You can append to end of the automatic sections:
|
||||
|
||||
%check -a
|
||||
# run %%pytest after %%pyproject_check_import
|
||||
%pytest
|
||||
|
||||
Or prepend to the beginning of them:
|
||||
|
||||
%prep -p
|
||||
# run %%gpgverify before %%autosetup
|
||||
%gpgverify -k2 -s1 -d0
|
||||
|
||||
[declarative buildsystem]: https://rpm-software-management.github.io/rpm/manual/buildsystem.html
|
||||
|
||||
|
||||
Limitations
|
||||
-----------
|
||||
|
||||
|
@ -5,3 +5,13 @@
|
||||
# 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:C:) echo 'pyproject-rpm-macros' && exit 0
|
||||
|
||||
|
||||
# Declarative buildsystem, requires RPM 4.20+ to work
|
||||
# https://rpm-software-management.github.io/rpm/manual/buildsystem.html
|
||||
# This is the minimal implementation to be in the srpm package,
|
||||
# as required even before the BuildRequires are installed
|
||||
%buildsystem_pyproject_conf() %nil
|
||||
%buildsystem_pyproject_generate_buildrequires() %pyproject_buildrequires %*
|
||||
%buildsystem_pyproject_build() %nil
|
||||
%buildsystem_pyproject_install() %nil
|
||||
|
@ -221,3 +221,13 @@ PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_
|
||||
HOSTNAME="rpmbuild" \\
|
||||
%{__python3} -m tox --current-env -q --recreate -e "%{-e:%{-e*}}%{!-e:%{toxenv}}" %{?*}
|
||||
}
|
||||
|
||||
|
||||
# Declarative buildsystem, requires RPM 4.20+ to work
|
||||
# https://rpm-software-management.github.io/rpm/manual/buildsystem.html
|
||||
%buildsystem_pyproject_conf() %nil
|
||||
%buildsystem_pyproject_generate_buildrequires() %pyproject_buildrequires %*
|
||||
%buildsystem_pyproject_build() %pyproject_wheel %*
|
||||
%buildsystem_pyproject_install() %["%{shrink:%*}" == "" ? "%{error:BuildOption(install) is mandatory with pyproject BuildSystem.}" : "%pyproject_install \
|
||||
%pyproject_save_files %*"]
|
||||
%buildsystem_pyproject_check() %pyproject_check_import %*
|
||||
|
@ -13,8 +13,8 @@ License: MIT
|
||||
# Increment Y and reset Z when new macros or features are added
|
||||
# Increment Z when this is a bugfix or a cosmetic change
|
||||
# Dropping support for EOL Fedoras is *not* considered a breaking change
|
||||
Version: 1.13.0
|
||||
Release: 2%{?dist}
|
||||
Version: 1.14.0
|
||||
Release: 1%{?dist}
|
||||
|
||||
# Macro files
|
||||
Source001: macros.pyproject
|
||||
@ -172,6 +172,9 @@ export HOSTNAME="rpmbuild" # to speedup tox in network-less mock, see rhbz#1856
|
||||
|
||||
|
||||
%changelog
|
||||
* Tue Jul 23 2024 Miro Hrončok <mhroncok@redhat.com> - 1.14.0-1
|
||||
- Add a provisional RPM Declarative Buildsystem (RPM 4.20+)
|
||||
|
||||
* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.13.0-2
|
||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild
|
||||
|
||||
|
51
tests/python-pello.spec
Normal file
51
tests/python-pello.spec
Normal file
@ -0,0 +1,51 @@
|
||||
Name: python-pello
|
||||
Version: 1.0.4
|
||||
Release: 0%{?dist}
|
||||
Summary: Example Python library
|
||||
|
||||
License: MIT-0
|
||||
URL: https://github.com/fedora-python/Pello
|
||||
Source: %{url}/archive/v%{version}/Pello-%{version}.tar.gz
|
||||
|
||||
BuildArch: noarch
|
||||
|
||||
# we use this specfile for 2 different tests, this bcond controls it
|
||||
# a build --with options tests custom BuildOptions(generate_buildrequires)
|
||||
%bcond options 0
|
||||
|
||||
# unfortunately, the following is not even parsable on RPM < 4.20
|
||||
%if v"0%{?rpmversion}" >= v"4.19.90"
|
||||
BuildSystem: pyproject
|
||||
BuildOption(install): -l pello
|
||||
%if %{with options}
|
||||
BuildOption(generate_buildrequires): -t
|
||||
%endif
|
||||
%endif
|
||||
|
||||
%description
|
||||
We use this specfile to test the declarative buildsystem.
|
||||
On older RPM version the build succeeds but builds nothing.
|
||||
|
||||
Note that due to the "automagic" it's a bit challenging to actually assert
|
||||
anything here. Manually inspecting the logs and results when doing changes
|
||||
to the declarative buildsystem is still advised.
|
||||
|
||||
|
||||
%package -n python3-pello
|
||||
Summary: %{summary}
|
||||
|
||||
%description -n python3-pello
|
||||
...
|
||||
|
||||
|
||||
%if %{with options} && v"0%{?rpmversion}" >= v"4.19.90"
|
||||
%check -a
|
||||
%tox
|
||||
%endif
|
||||
|
||||
|
||||
%if v"0%{?rpmversion}" >= v"4.19.90"
|
||||
%files -n python3-pello -f %{pyproject_files}
|
||||
%doc README.md
|
||||
%{_bindir}/pello_greeting
|
||||
%endif
|
@ -91,6 +91,12 @@
|
||||
- virtualenv:
|
||||
dir: .
|
||||
run: ./mocktest.sh python-virtualenv
|
||||
- pello:
|
||||
dir: .
|
||||
run: ./mocktest.sh python-pello
|
||||
- pello_with_options:
|
||||
dir: .
|
||||
run: ./mocktest.sh python-pello --with options
|
||||
- escape_paths:
|
||||
dir: .
|
||||
run: ./mocktest.sh escape_paths
|
||||
|
Loading…
Reference in New Issue
Block a user