%global pypi_name cortech # Upstream's only tag is v0.1 (the project is young and moves in master); # package the tip, as the rest of the SimNIBS-adjacent stack here does. %global commit 55d39c98ee4b20f3c8fbd9fbf978f3437f854b8e %global shortcommit %(c=%{commit}; echo ${c:0:7}) %global date 20260828 Name: python-%{pypi_name} Version: 0.1 Release: 1.%{date}git%{shortcommit}%{?dist} Summary: Tools for cortical layer placement and analysis License: GPL-3.0-only URL: https://github.com/simnibs/cortech Source0: %{url}/archive/%{commit}/%{pypi_name}-%{shortcommit}.tar.gz # Build against Fedora's CGAL 6 instead of conan's: meson's dependency('cgal') # is a pkg-config lookup and CGAL ships only a CMake config; CGAL's exact # number types need gmp and mpfr linked explicitly or the extensions fail at # import with "undefined symbol: __gmpz_divexact_ui"; and CGAL 6 moved # border.h and dropped the top-level Polygon_mesh_processing aliases. # See docs/upstream/cortech-cgal6.md. Patch0: cortech-cgal6-system-build.patch BuildRequires: gcc-c++ BuildRequires: python3-devel BuildRequires: python3-Cython BuildRequires: python3-numpy BuildRequires: pyproject-rpm-macros # meson-python is the build backend (pyproject.toml build-system). BuildRequires: python3-meson-python BuildRequires: meson BuildRequires: ninja-build # conanfile.txt asks conan for cgal/6.2; Fedora ships CGAL 6.2.1, so build # against the system copy and do not fetch anything. CGAL is header-only but # pulls in these at compile time. BuildRequires: CGAL-devel BuildRequires: boost-devel BuildRequires: gmp-devel BuildRequires: mpfr-devel BuildRequires: eigen3-devel # pyvista is an optional upstream dependency ([project.optional-dependencies] # vtk), needed only by cortech.visualization. Pulled in at build time so the # import check covers that module too rather than excusing it. BuildRequires: python3-pyvista %global _description %{expand: cortech places and analyses cortical layers: equivolume and equidistant layer construction between the white and pial surfaces, surface geometry and curvature, Laplace solutions across the cortical ribbon, and the mesh conversions those need. It is developed alongside SimNIBS, whose layered-surface workflow uses it.} %description %_description %package -n python3-%{pypi_name} Summary: %{summary} # cortech.visualization imports pyvista, which upstream marks optional # ([project.optional-dependencies] vtk). Recommend rather than require it, so # the layer and geometry work does not drag VTK in for people who never plot; # the build does require it, so %%check still exercises that module. Recommends: python3-pyvista %description -n python3-%{pypi_name} %_description %prep %autosetup -p1 -n %{pypi_name}-%{commit} # conan is not used: CGAL comes from CGAL-devel, via Patch0 (meson asks for the # CMake package rather than a pkg-config file that CGAL does not ship). test -f meson.build %generate_buildrequires # -p: meson-python cannot produce metadata before the build, so read the # runtime dependencies from pyproject.toml's [project] table instead. %pyproject_buildrequires -p %build # CGAL's headers include unqualified, and Fedora installs Eigen # under %%{_includedir}/eigen3, so CGAL/Dimension.h cannot find it without help. # CGAL's own CMake target would add this via CGAL::Eigen3_support; meson asks # only for the base package, so pass it here. export CXXFLAGS="%{optflags} -I%{_includedir}/eigen3" export CFLAGS="%{optflags} -I%{_includedir}/eigen3" %pyproject_wheel %install %pyproject_install %pyproject_save_files %{pypi_name} %check # numba is unusable on f45 (no released numba supports Python 3.15), and # importing cortech imports it. Byte-compile there instead of skipping the # check altogether; see python-numba.spec for the full explanation. %if 0%{?fedora} >= 45 test -d %{buildroot}%{python3_sitearch}/%{pypi_name} %{python3} -m compileall -q %{buildroot}%{python3_sitearch}/%{pypi_name} > /dev/null echo "NOTE: import check skipped on f45+ until numba supports Python 3.15" %else %pyproject_check_import %endif %files -n python3-%{pypi_name} -f %{pyproject_files} %license LICENSE %doc README.md %changelog * Sat Sep 26 2026 Morgan Hough - 0.1-1.20260828git55d39c9 - Initial package. Recommended by simnibs for the layered-surface workflow. Built against Fedora's CGAL 6.2.1 rather than the cgal/6.2 that upstream's conanfile.txt would fetch.