From 6f76c81d3e5ede686d0c2117e1eeb78293f0cb73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= Date: Tue, 30 Sep 2025 11:16:39 +0200 Subject: [PATCH] RHEL: Import from Fedora --- .gitignore | 8 ++ README.md | 3 + meson-python-0.18.0-remove-patchelf.patch | 37 +++++++ python-meson-python.spec | 124 ++++++++++++++++++++++ sources | 1 + 5 files changed, 173 insertions(+) create mode 100644 README.md create mode 100644 meson-python-0.18.0-remove-patchelf.patch create mode 100644 python-meson-python.spec create mode 100644 sources diff --git a/.gitignore b/.gitignore index e69de29..10181ed 100644 --- a/.gitignore +++ b/.gitignore @@ -0,0 +1,8 @@ +/meson_python-0.13.1.tar.gz +/meson_python-0.13.2.tar.gz +/meson_python-0.14.0.tar.gz +/meson_python-0.15.0.tar.gz +/meson_python-0.16.0.tar.gz +/meson_python-0.17.0.tar.gz +/meson_python-0.17.1.tar.gz +/meson_python-0.18.0.tar.gz diff --git a/README.md b/README.md new file mode 100644 index 0000000..e61d876 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# python-meson-python + +The python-meson-python package diff --git a/meson-python-0.18.0-remove-patchelf.patch b/meson-python-0.18.0-remove-patchelf.patch new file mode 100644 index 0000000..824b8d0 --- /dev/null +++ b/meson-python-0.18.0-remove-patchelf.patch @@ -0,0 +1,37 @@ +diff -Naur meson_python-0.18.0-original/mesonpy/__init__.py meson_python-0.18.0/mesonpy/__init__.py +--- meson_python-0.18.0-original/mesonpy/__init__.py 2025-05-05 06:07:43.000000000 -0400 ++++ meson_python-0.18.0/mesonpy/__init__.py 2025-05-05 08:19:01.630322169 -0400 +@@ -438,6 +438,7 @@ + # directory, in the form of a relative RPATH entry. meson-python + # relocates the shared libraries to the $project.mesonpy.libs + # folder. Rewrite the RPATH to point to that folder instead. ++ assert False, "Patchelf is not allowed to run on RHEL" + libspath = os.path.relpath(self._libs_dir, destination.parent) + mesonpy._rpath.fix_rpath(origin, libspath) + +@@ -1166,9 +1167,6 @@ + if os.environ.get('NINJA') is None and _env_ninja_command() is None: + dependencies.append(f'ninja >= {_NINJA_REQUIRED_VERSION}') + +- if sys.platform.startswith('linux') and not shutil.which('patchelf'): +- dependencies.append('patchelf >= 0.11.0') +- + return dependencies + + +diff -Naur meson_python-0.18.0-original/mesonpy/_rpath.py meson_python-0.18.0/mesonpy/_rpath.py +--- meson_python-0.18.0-original/mesonpy/_rpath.py 2025-05-05 06:07:43.000000000 -0400 ++++ meson_python-0.18.0/mesonpy/_rpath.py 2025-05-05 08:20:15.209296624 -0400 +@@ -73,10 +73,12 @@ + # Assume that any other platform uses ELF binaries. + + def _get_rpath(filepath: Path) -> List[str]: ++ assert False, "Patchelf is not allowed to run on RHEL" + r = subprocess.run(['patchelf', '--print-rpath', os.fspath(filepath)], capture_output=True, text=True) + return r.stdout.strip().split(':') + + def _set_rpath(filepath: Path, rpath: Iterable[str]) -> None: ++ assert False, "Patchelf is not allowed to run on RHEL" + subprocess.run(['patchelf','--set-rpath', ':'.join(rpath), os.fspath(filepath)], check=True) + + def fix_rpath(filepath: Path, libs_relative_path: str) -> None: diff --git a/python-meson-python.spec b/python-meson-python.spec new file mode 100644 index 0000000..9142e0a --- /dev/null +++ b/python-meson-python.spec @@ -0,0 +1,124 @@ +%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. +%bcond pytest_mock %{undefined rhel} +%bcond wheel %{undefined rhel} +# RHEL will not have patchelf (which is used for adjusting RPATH in shared +# libraries bundled in wheels); that is OK because the package is +# buildroot-only there and the packages built with python-meson-python will not +# bundle shared libraries. In Fedora and EPEL, we must depend on patchelf to +# ship a full-featured package. +%bcond patchelf %{expr:%{undefined rhel} || %{defined epel}} + +Name: python-meson-python +Summary: Meson Python build backend (PEP 517) +Version: 0.18.0 +Release: %autorelease + +# SPDX +License: MIT +URL: https://github.com/mesonbuild/meson-python +Source: %{pypi_source meson_python} + +# Downstream-only patch to remove the patchelf dependency (and corresponding +# 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 + +# for %%pyproject_buildrequires -p +BuildRequires: pyproject-rpm-macros >= 1.15.1 + +%if %{with tests} +BuildRequires: gcc +BuildRequires: git-core +%endif + +%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 +packages. Meson is an open source build system meant to be both extremely fast, +and, even more importantly, as user friendly as possible. meson-python is best +suited for building Python packages containing extension modules implemented in +languages such as C, C++, Cython, Fortran, Pythran, or Rust. Consult the +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. +%autosetup -n meson_python-%{version} -N -S git +%autopatch -M 99 -p1 +%if %{without patchelf} +%patch 100 -p1 +%endif +# 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 +%if %{without pytest_mock} +sed -r -i "s/^ '(pytest-mock)/#&/" pyproject.toml +%endif +%if %{without wheel} +sed -r -i "s/^ '(wheel)/#&/" pyproject.toml +%endif + + +%check -a +%if %{with tests} +# Note: tests are *not* safe for parallel execution with pytest-xdist. + +# PEP 518 tests require network access. +ignore="${ignore-} --ignore=tests/test_pep518.py" + +%if %{without pytest_mock} +k="${k-}${k+ and }not test_invalid_build_dir" +k="${k-}${k+ and }not test_use_ansi_escapes" +%endif +%if %{without wheel} +ignore="${ignore-} --ignore=tests/test_editable.py" +ignore="${ignore-} --ignore=tests/test_wheel.py" +ignore="${ignore-} --ignore=tests/test_wheelfile.py" +%endif +%if %{without patchelf} +k="${k-}${k+ and }not test_contents" +k="${k-}${k+ and }not test_local_lib" +k="${k-}${k+ and }not test_rpath" +k="${k-}${k+ and }not test_get_requires_for_build_wheel" +k="${k-}${k+ and }not test_uneeded_rpath" +%endif + +%pytest ${ignore-} -k "${k-}" +%endif + + +%files -n python3-meson-python -f %{pyproject_files} +%doc CHANGELOG.rst +%doc README.rst + + +%changelog +%autochangelog diff --git a/sources b/sources new file mode 100644 index 0000000..fa6a83f --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (meson_python-0.18.0.tar.gz) = dea156e85746acf3139bef9c1ac3f9f91f473a4162f3835cb942e28d94fd7afdad469e08f6ec2b15d2ea3a96ce071aae5d8de856334b2dbcb8b89a21ce561d17