%global pypi_name cortech # Package the v0.1 tag, NOT master. This matters: cortech's 2026-06-04 # "refactor of Surface class" made Surface.__init__ assert that the # triangulation is a manifold (CGAL's is_polygon_soup_a_polygon_mesh), and # SimNIBS 4.6.0 predates that. SimNIBS calls cortech.Surface() on the skin # surface it extracts from a head mesh, and the ernie example subject's skin # does not satisfy the new check, so with master every TMS simulation dies at # coil positioning with # AssertionError: Triangulation does not define a manifold surface. # v0.1 (2025-09-10) is the release contemporaneous with SimNIBS 4.6.0 and # provides every API it uses: Cortex, Hemisphere, Sphere, Surface, # Surface.from_file and Surface.from_gifti. %global commit fdfe97f7fbeb056a35bf2c3bdae355f6793a6095 %global shortcommit %(c=%{commit}; echo ${c:0:7}) %global date 20250910 Name: python-%{pypi_name} Version: 0.1 Release: 2%{?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, and CGAL's exact # number types need gmp and mpfr linked explicitly or the extensions fail at # import with "undefined symbol: __gmpz_divexact_ui". 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-2 - Package the v0.1 tag instead of a master snapshot. cortech master added a manifold assertion to Surface.__init__ on 2026-06-04, which SimNIBS 4.6.0 predates; with master every TMS simulation on the ernie example subject fails at coil positioning with "Triangulation does not define a manifold surface". v0.1 is the release contemporaneous with SimNIBS 4.6.0 and has every API it uses. v0.1 also needs neither the CGAL 6 border.h move nor the extract_boundary_cycles namespace fix, so the patch shrinks to the CGAL detection and gmp/mpfr linking. * 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.