# From SuperBuild/SuperBuild.cmake, “FSL behavior, pigz support;” this is on by # default upstream, so we leave it on. %bcond fslstyle 1 Name: niimath Version: 1.0.20250529 Release: %autorelease Summary: Clone of fslmaths # The entire source is BSD-2-Clause, except: # License: %{shrink: BSD-2-Clause } URL: https://github.com/rordenlab/niimath Source0: %{url}/archive/v%{version}/niimath-%{version}.tar.gz # Man page hand-written for Fedora in groff_man(7) format based on --help Source1: niimath.1 # No longer require pyproject extra of scikit-build-core # https://github.com/rordenlab/niimath/pull/47 Patch: %{url}/pull/47.patch # For %%py3_shebang_fix in %%prep, before dynamic BuildRequires are ready BuildRequires: python3-devel BuildRequires: gcc-c++ BuildRequires: cmake # Git is required for Superbuild (SuperBuild/SuperBuild.cmake) BuildRequires: git-core BuildRequires: cmake(zlib) %if %{with fslstyle} BuildRequires: pigz Requires: pigz %endif BuildRequires: symlinks # https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval ExcludeArch: %{ix86} %description It is said that imitation is the sincerest form of flattery. This project emulates the popular fslmaths tool. fslmaths is a general image calculator and is not only one of the foundational tools for FSL’s brain imaging pipelines (such as FEAT), but has also been widely adopted by many tools. %package -n python3-niimath Summary: Thin wrapper around niimath binary # This subpackage is pure-Python and does not contain anything derived from any # of the bundled libraries, so only the “main” license applies. License: BSD-2-Clause BuildArch: noarch Requires: niimath = %{version}-%{release} %description -n python3-niimath %{summary}. %prep %autosetup -p1 # Prove we do not install the JavaScript library rm -rv js # https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_shebangs %py3_shebang_fix library/ %generate_buildrequires export SETUPTOOLS_SCM_PRETEND_VERSION='%{version}' %pyproject_buildrequires %build export SETUPTOOLS_SCM_PRETEND_VERSION='%{version}' # https://scikit-build-core.readthedocs.io/en/latest/configuration.html # FSLSTYLE: FSL behavior, pigz support # BUILD_FLAVOR: Choose the flavor of build, options are: all tiny nano. %{pyproject_wheel \ -Ccmake.define.USE_STATIC_RUNTIME:BOOL=OFF \ -Ccmake.define.FSLSTYLE:STRING=all \ -Ccmake.define.ZLIB_IMPLEMENTATION:STRING=System \ -Clogging.level=INFO \ -Ccmake.verbose=true \ -Ccmake.build-type="RelWithDebInfo"} %install %pyproject_install %pyproject_save_files -L niimath # Clean up after the wheel installation, which has everything we need, but not # necessarily where we need it. Replace the binary inside the Python package # with a symbolic link to %%{_bindir}, and make it relative so that it works # both inside the buildroot and in the installed package. mv '%{buildroot}%{python3_sitearch}/niimath/bin/niimath' \ '%{buildroot}%{_bindir}' ln -sv '%{buildroot}%{_bindir}/niimath' \ '%{buildroot}%{python3_sitearch}/niimath/bin/' symlinks -c '%{buildroot}%{python3_sitearch}/niimath/bin/' # Now that we have replaced the binary with a symlink, the Python package is # arch-independent. if [ '%{python3_sitelib}' != '%{python3_sitearch}' ] then install -d '%{buildroot}%{python3_sitelib}' mv %{buildroot}%{python3_sitearch}/niimath* '%{buildroot}%{python3_sitelib}' sed -r -i 's@%{python3_sitearch}@%{python3_sitelib}@' %{pyproject_files} fi install -t '%{buildroot}%{_mandir}/man1' -D -p -m 0644 '%{SOURCE1}' %check %pyproject_check_import %files %license LICENSE %doc README.md # Python demo scripts that wrap the command-line tool, plus a README.md file # describing them. As of this writing, these use the CLI directly rather than # via the Python package wrapper. Demo scripts may have dependencies on # additional Python modules, such as nibabel. %doc library/ %{_bindir}/niimath %{_mandir}/man1/niimath.1* %files -n python3-niimath -f %{pyproject_files} %changelog %autochangelog