## START: Set by rpmautospec ## (rpmautospec version 0.6.0) ## RPMAUTOSPEC: autorelease, autochangelog %define autorelease(e:s:pb:n) %{?-p:0.}%{lua: release_number = 3; base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}")); print(release_number + base_release_number - 1); }%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}} ## END: Set by rpmautospec %bcond test_example 1 Name: python-cmake-build-extension Version: 0.6.0 Release: %autorelease Summary: Setuptools extension to build and package CMake projects # The entire source is MIT, except example/bindings_swig/numpy.i, which is # BSD-3-Clause, and test_example/bindings_swig/numpy.i, which is also # BSD-3-Clause but does not contribute to any of the binary RPMs. License: MIT AND BSD-3-Clause URL: https://github.com/diegoferigo/cmake-build-extension Source: %{pypi_source cmake_build_extension} BuildArch: noarch BuildRequires: python3-devel BuildRequires: cmake BuildRequires: ninja-build %if %{with test_example} BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: swig # Even though pybind11 and eigen3 are header-only, we don’t need to BR: # pybind11-static nor eigen3-static, because nothing we install is built with # them; they are only used for test-building the example. BuildRequires: cmake(pybind11) BuildRequires: cmake(Eigen3) BuildRequires: python3dist(pytest) %endif %global common_description %{expand: This project aims to simplify the integration of C++ projects based on CMake with Python packaging tools. CMake provides out-of-the-box support to either SWIG and pybind11, that are two among the most used projects to create Python bindings from C++ sources. If you have any experience with these hybrid projects, you know the challenges to make packaging right! This project takes inspiration from pre-existing examples (pybind/cmake_example, among many others) and provides a simple, flexible, and reusable setuptools extension with the following features: • Bridge between CMake projects and Python packaging. • Configure and build the CMake project from setup.py. • Install the CMake project in the resulting Python package. • Allow passing custom CMake options. • Allow creating a top-level __init__.py. • Expose C++ executables to the Python environment. • Provide a context manager to import reliably CPython modules on all major OSs. • Disable the C++ extension in editable installations (requiring to manually call CMake to install the C++ project).} %description %{common_description} %package -n python3-cmake-build-extension Summary: %{summary} # Since this subpackage does not contain the example project, it has no # BSD-3-Clause licensed sources. License: MIT Requires: cmake Requires: ninja-build %description -n python3-cmake-build-extension %{common_description} %package -n python3-cmake-build-extension-doc Summary: Documentation and examples for cmake-build-extension Requires: python3-cmake-build-extension = %{version}-%{release} %description -n python3-cmake-build-extension-doc %{common_description} %prep %autosetup -n cmake_build_extension-%{version} -p1 # We use the system cmake and ninja-build packages in lieu of the PyPI “cmake” # and “ninja” distributions, respectively. sed -r -i '/^[[:blank:]]*\b(cmake|ninja)\b[[:blank:]]*$/d' setup.cfg %if %{with test_example} # Keep the original example/ “clean” so we can install it as documentation; # make a copy to test-build. cp -rp example test_example %endif %generate_buildrequires %pyproject_buildrequires %if %{with test_example} ( cd test_example >/dev/null # For an unknown reason, “-x test” does not generate the appropriate BR’s # here. Furthermore, python3dist(pytest-icdiff) is not packaged, so we would # have to patch it out anyway. We just use manual BR’s for the example’s # tests instead. %pyproject_buildrequires ) | grep -Ev 'cmake-build-extension' %endif %build %pyproject_wheel %install %pyproject_install %pyproject_save_files -l cmake_build_extension %check # We choose to do an import “smoke test” even when we are test-building the # example. %pyproject_check_import %if %{with test_example} # Build the example project and run its tests (but do not install any compiled # extensions as part of our RPM!) pushd test_example >/dev/null export PYTHONPATH='%{buildroot}%{python3_sitelib}' %pyproject_wheel BLIB="${PWD}/build/lib.%{python3_platform}-cpython-%{python3_version_nodots}" export PYTHONPATH="${PYTHONPATH}:${BLIB}" export PATH="${PATH}:${BLIB}/mymath_pybind11/bin:${BLIB}/mymath_swig/bin" %pytest popd >/dev/null %endif %files -n python3-cmake-build-extension -f %{pyproject_files} %files -n python3-cmake-build-extension-doc %doc README.md %doc example/ %changelog ## START: Generated by rpmautospec * Fri Jul 19 2024 Fedora Release Engineering - 0.6.0-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild * Sat Jun 08 2024 Python Maint - 0.6.0-2 - Rebuilt for Python 3.13 * Tue May 21 2024 Benjamin A. Beasley - 0.6.0-1 - Update to 0.6.0 * Fri Jan 26 2024 Fedora Release Engineering - 0.5.1-14 - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild * Mon Jan 22 2024 Fedora Release Engineering - 0.5.1-13 - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild * Sun Dec 17 2023 Benjamin A. Beasley - 0.5.1-12 - Assert that %%pyproject_files contains a license file * Fri Jul 21 2023 Fedora Release Engineering - 0.5.1-11 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild * Fri Jul 07 2023 Benjamin A. Beasley - 0.5.1-10 - Use new (rpm 4.17.1+) bcond style * Thu Jun 15 2023 Python Maint - 0.5.1-9 - Rebuilt for Python 3.12 * Wed Mar 08 2023 Benjamin A. Beasley - 0.5.1-7 - Simplify path-building for test execution * Fri Jan 20 2023 Fedora Release Engineering - 0.5.1-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild * Fri Oct 21 2022 Benjamin A. Beasley - 0.5.1-5 - Update License to SPDX * Fri Jul 22 2022 Fedora Release Engineering - 0.5.1-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild * Thu Jul 07 2022 Benjamin A. Beasley - 0.5.1-3 - Fix extra newline in description * Mon Jun 13 2022 Python Maint - 0.5.1-2 - Rebuilt for Python 3.11 * Wed Jun 01 2022 Benjamin A. Beasley - 0.5.1-1 - Update to 0.5.1 * Tue May 31 2022 Benjamin A. Beasley - 0.5.0-1 - Initial package (close RHBZ#2085825) ## END: Generated by rpmautospec