From c88688dc68cac46d16b4f2ed5d73aab8187045ad Mon Sep 17 00:00:00 2001 From: Pavel Simovec Date: Fri, 7 Jun 2024 12:39:54 +0200 Subject: [PATCH] Remove patchelf dependency for RHEL Resolves: RHEL-36336 --- meson_python-remove-patchelf.patch | 39 ++++++++++++++++++++++++++++++ python-meson-python.spec | 19 +++++++++++++-- 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 meson_python-remove-patchelf.patch diff --git a/meson_python-remove-patchelf.patch b/meson_python-remove-patchelf.patch new file mode 100644 index 0000000..39495a0 --- /dev/null +++ b/meson_python-remove-patchelf.patch @@ -0,0 +1,39 @@ +diff --color -ruN a/mesonpy/__init__.py b/mesonpy/__init__.py +--- a/mesonpy/__init__.py 2024-06-05 11:10:53.628398345 +0200 ++++ b/mesonpy/__init__.py 2024-06-05 11:31:13.600792738 +0200 +@@ -410,6 +410,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) + +@@ -1007,9 +1008,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 --color -ruN a/mesonpy/_rpath.py b/mesonpy/_rpath.py +--- a/mesonpy/_rpath.py 2024-06-05 11:10:53.628398345 +0200 ++++ b/mesonpy/_rpath.py 2024-06-05 11:31:18.954861673 +0200 +@@ -17,12 +17,13 @@ + + + if sys.platform == 'linux': +- + 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 index 5811947..ff79d11 100644 --- a/python-meson-python.spec +++ b/python-meson-python.spec @@ -13,6 +13,8 @@ License: MIT URL: https://github.com/mesonbuild/meson-python Source: %{pypi_source meson_python} +Patch2: meson_python-remove-patchelf.patch + BuildArch: noarch BuildRequires: python3-devel @@ -40,8 +42,10 @@ 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 0%{?rhel} == 0 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 @@ -50,8 +54,12 @@ Requires: /usr/bin/patchelf %prep -%autosetup -n meson_python-%{version} - +%setup -n meson_python-%{version} -q +%patch 0 -p1 +%patch 1 -p1 +%if 0%{?rhel} +%patch 2 -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 @@ -84,6 +92,13 @@ ignore="${ignore-} --ignore=tests/test_pep518.py" k="${k-}${k+ and }not test_invalid_build_dir" k="${k-}${k+ and }not test_use_ansi_colors" %endif +%if 0%{?rhel} +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-}"