From c008f65b449d28c8323dbedcf01782d04c22e529 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= Date: Tue, 30 Sep 2025 12:30:19 +0200 Subject: [PATCH] Convert from Fedora for the Python 3.14 stack in RHEL --- Adjust-test-for-python3.14.patch | 22 ++++++++++++ python3.14-pybind11.spec | 60 ++++++++++++++++++++++++-------- 2 files changed, 67 insertions(+), 15 deletions(-) create mode 100644 Adjust-test-for-python3.14.patch diff --git a/Adjust-test-for-python3.14.patch b/Adjust-test-for-python3.14.patch new file mode 100644 index 0000000..fc63e3f --- /dev/null +++ b/Adjust-test-for-python3.14.patch @@ -0,0 +1,22 @@ +From b4aee5b83240e3d14899f7353cb4832f13775be6 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Hrn=C4=8Diar?= +Date: Mon, 3 Nov 2025 15:33:13 +0100 +Subject: [PATCH] Adjust test for python3.14 + +--- + tests/test_operator_overloading.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/test_operator_overloading.py b/tests/test_operator_overloading.py +index b676090..2135d9e 100644 +--- a/tests/test_operator_overloading.py ++++ b/tests/test_operator_overloading.py +@@ -150,4 +150,4 @@ def test_overriding_eq_reset_hash(): + def test_return_set_of_unhashable(): + with pytest.raises(TypeError) as excinfo: + m.get_unhashable_HashMe_set() +- assert str(excinfo.value.__cause__).startswith("unhashable type:") ++ assert "unhashable type" in str(excinfo.value.__cause__) +-- +2.51.1 + diff --git a/python3.14-pybind11.spec b/python3.14-pybind11.spec index b805556..3e32e29 100644 --- a/python3.14-pybind11.spec +++ b/python3.14-pybind11.spec @@ -1,38 +1,53 @@ +%global python3_pkgversion 3.14 + # While the headers are architecture independent, the package must be # built separately on all architectures so that the tests are run # properly. See also # https://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_Header_Only_Libraries %global debug_package %{nil} -# Whether to run the tests, enabled by default -%bcond tests 1 +%ifarch ppc64le +# The tests are not LTO-compatible on power +%global _lto_cflags %{nil} +%endif -Name: pybind11 +# Exclude automatic provides without python3.14 in the name +%global __provides_exclude cmake|pkgconfig + +# Whether to run the tests, enabled by default +%bcond tests 0 + +Name: python%{python3_pkgversion}-pybind11 Version: 2.13.6 Release: %autorelease Summary: Seamless operability between C++11 and Python License: BSD-3-Clause URL: https://github.com/pybind/pybind11 -Source0: https://github.com/pybind/pybind11/archive/v%{version}/%{name}-%{version}.tar.gz +Source0: https://github.com/pybind/pybind11/archive/v%{version}/pybind11-%{version}.tar.gz # Use the `/usr` prefix for the python commands Patch1: pybind11-2.13.6-Use_usr_prefix.patch # Drop cmake and ninja from build-requires Patch2: pybind11-2.13.6-Drop_some_build-requires.patch +# Adjust test for different syntax in python3.14 +# Upstream commit: https://github.com/pybind/pybind11/commit/094343c +Patch3: Adjust-test-for-python3.14.patch # Needed to build the python libraries -BuildRequires: python3-devel +BuildRequires: python%{python3_pkgversion}-devel # Test depdendencies are not exposed %if %{with tests} -BuildRequires: python3-pytest -BuildRequires: python3-numpy -BuildRequires: python3-scipy +BuildRequires: python%{python3_pkgversion}-pytest +BuildRequires: python%{python3_pkgversion}-numpy +BuildRequires: python%{python3_pkgversion}-scipy %endif BuildRequires: eigen3-devel BuildRequires: gcc-c++ BuildRequires: cmake +Requires: %{name}-devel%{?_isa} = %{version}-%{release} + %global base_description \ pybind11 is a lightweight header-only library that exposes C++ types \ in Python and vice versa, mainly to create Python bindings of existing \ @@ -43,6 +58,18 @@ C++ code. %package devel Summary: Development headers for pybind11 + +# This package does not have namespaced file locations, so if we build the +# pybind11-devel subpackage in any other stack as well, the files from these +# packages will conflict. The package name is namespaced so that customers can +# decide which to install, but the packages will conflict with each other. +# Whenever python3.X-pybind11-devel is introduced, it needs to explicitly +# conflict with all the previous python3.X-pybind11-devel packages as well as +# the non-namespaced pybind11-devel package from the main Python stack. +Conflicts: pybind11-devel < %{version}-%{release} +Conflicts: python3.11-pybind11-devel < %{version}-%{release} +Conflicts: python3.12-pybind11-devel < %{version}-%{release} + # https://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_Header_Only_Libraries Provides: %{name}-static = %{version}-%{release} @@ -51,18 +78,18 @@ Provides: %{name}-static = %{version}-%{release} This package contains the development headers for pybind11. -%package -n python3-%{name} +%package -n python%{python3_pkgversion}-%{name} Summary: %{summary} Requires: %{name}-devel%{?_isa} = %{version}-%{release} -%description -n python3-%{name} +%description -n python%{python3_pkgversion}-%{name} %{base_description} This package contains the Python 3 files. %prep -%autosetup -p1 +%autosetup -n pybind11-%{version} -p1 %generate_buildrequires @@ -77,8 +104,11 @@ This package contains the Python 3 files. # https://bugzilla.redhat.com/show_bug.cgi?id=1921199 %cmake \ -DCMAKE_BUILD_TYPE=Debug \ + %{?with_tests:-DPYBIND11_TEST=ON} \ %{!?with_tests:-DPYBIND11_TEST=OFF} \ - -DUSE_PYTHON_INCLUDE_DIR=FALSE + -DUSE_PYTHON_INCLUDE_DIR=FALSE \ + -DPython_EXECUTABLE=/usr/bin/python%{python3_pkgversion} \ + -DPython_INCLUDE_DIR=/usr/include/python%{python3_pkgversion} %cmake_build # Build again with the python build system to get the python files @@ -99,7 +129,7 @@ sed -i '/pybind11\/share/d' %{pyproject_files} %if %{with tests} %check -%ctest +%cmake_build --target check %endif @@ -109,9 +139,9 @@ sed -i '/pybind11\/share/d' %{pyproject_files} %{_includedir}/pybind11/ %{_datadir}/cmake/pybind11/ %{_bindir}/pybind11-config -%{_datadir}/pkgconfig/%{name}.pc +%{_datadir}/pkgconfig/pybind11.pc -%files -n python3-%{name} -f %{pyproject_files} +%files -n python%{python3_pkgversion}-pybind11 -f %{pyproject_files} %changelog