Convert from Fedora for the Python 3.14 stack in RHEL

Fedora contributions by:
    Benjamin A. Beasley <code@musicinmybrain.net>
    Karolina Surma <ksurma@redhat.com>
    Lukáš Zachar <lzachar@redhat.com>
    Miro Hrončok <miro@hroncok.cz>
    Pavel Simovec <psimovec@redhat.com>
    Yaakov Selkowitz <yselkowi@redhat.com>
This commit is contained in:
Tomáš Hrnčiar 2025-09-30 11:57:50 +02:00 committed by Lumir Balhar
parent 893d8876b0
commit 532509588e

View File

@ -1,3 +1,5 @@
%global python3_pkgversion 3.14
%bcond tests 1
# The python-pytest-mock and wheel dependencies are unwanted on RHEL;
# we can omit them and still run most of the tests.
@ -10,7 +12,7 @@
# ship a full-featured package.
%bcond patchelf %{expr:%{undefined rhel} || %{defined epel}}
Name: python-meson-python
Name: python%{python3_pkgversion}-meson-python
Summary: Meson Python build backend (PEP 517)
Version: 0.18.0
Release: %autorelease
@ -24,21 +26,33 @@ Source: %{pypi_source meson_python}
# functionality), controlled by the patchelf build conditional
Patch100: meson-python-0.18.0-remove-patchelf.patch
BuildSystem: pyproject
BuildOption(generate_buildrequires): -p %{?with_tests:-x test}
# LICENSE duplicates LICENSES/MIT.txt, which is handled automatically.
BuildOption(install): -l mesonpy
BuildArch: noarch
BuildRequires: python%{python3_pkgversion}-setuptools
# for %%pyproject_buildrequires -p
BuildRequires: pyproject-rpm-macros >= 1.15.1
BuildRequires: ninja-build
Requires: ninja-build
%if %{with tests}
BuildRequires: gcc
BuildRequires: git-core
%endif
# When patchelf is not in the PATH, mesonpy.get_requires_for_build_wheel() adds
# https://pypi.org/project/patchelf/ to the dependencies. We always want to use
# the system patchelf.
%if %{with patchelf}
BuildRequires: /usr/bin/patchelf
Requires: /usr/bin/patchelf
%endif
BuildRequires: /usr/bin/meson
Requires: /usr/bin/meson
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_provides_for_importable_modules
%py_provides python3-mesonpy
%global common_description %{expand:
meson-python is a Python build backend built on top of the Meson build system.
It enables to use Meson for the configuration and build steps of Python
@ -51,23 +65,6 @@ documentation for more details.}
%description %{common_description}
%package -n python3-meson-python
Summary: %{summary}
# When patchelf is not in the PATH, mesonpy.get_requires_for_build_wheel() adds
# https://pypi.org/project/patchelf/ to the dependencies. We always want to use
# the system patchelf.
%if %{with patchelf}
BuildRequires: /usr/bin/patchelf
Requires: /usr/bin/patchelf
%endif
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_provides_for_importable_modules
%py_provides python3-mesonpy
%description -n python3-meson-python %{common_description}
%prep
# We need “-S git” because test_reproducible uses “meson dist,” which only
# works in a git or mercurial repo.
@ -79,6 +76,9 @@ Requires: /usr/bin/patchelf
# build: used only by skipped PEP 518 test
# pytest-cov: https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters
sed -r -i "s/^ '(build|pytest-cov)/#&/" pyproject.toml
# RHEL: we want to use system meson
# It is installed for a different Python version and invoked via subprocess.
sed -r -i "s/^ 'meson >=/#&/" pyproject.toml
%if %{without pytest_mock}
sed -r -i "s/^ '(pytest-mock)/#&/" pyproject.toml
%endif
@ -86,8 +86,21 @@ sed -r -i "s/^ '(pytest-mock)/#&/" pyproject.toml
sed -r -i "s/^ '(wheel)/#&/" pyproject.toml
%endif
%generate_buildrequires
%pyproject_buildrequires -p %{?with_tests:-x test}
%check -a
%build
%pyproject_wheel
%install
%pyproject_install
# LICENSE duplicates LICENSES/MIT.txt, which is handled automatically.
%pyproject_save_files -l mesonpy
%check
%if %{with tests}
# Note: tests are *not* safe for parallel execution with pytest-xdist.
@ -112,10 +125,12 @@ k="${k-}${k+ and }not test_uneeded_rpath"
%endif
%pytest ${ignore-} -k "${k-}"
%else
%pyproject_check_import
%endif
%files -n python3-meson-python -f %{pyproject_files}
%files -n python%{python3_pkgversion}-meson-python -f %{pyproject_files}
%doc CHANGELOG.rst
%doc README.rst