# Sphinx-generated HTML documentation is not suitable for packaging; see
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555 for discussion.
#
# We can generate PDF documentation as a substitute.
%bcond doc 1
Name: python-nifti-mrs
Version: 1.1.1
Release: %autorelease
Summary: Software tools for the NIfTI-MRS data format
# The entire package is BSD-3-Clause, except the generated
# %%{python3_sitelib}/nifti_mrs/_version.py in python3-nifti-mrs, which is
# Unlicense because it is generated by Versioneer (python-versioneer).
License: BSD-3-Clause
URL: https://github.com/wtclarke/nifti_mrs_tools
# The GitHub archive contains API documentation and a changelog file, which the
# PyPI sdists lack.
Source: %{url}/archive/%{version}/nifti_mrs_tools-%{version}.tar.gz
# Man pages hand-written for Fedora in groff_man(7) format based on --help
Source10: mrs_tools.1
Source11: mrs_tools-conjugate.1
Source12: mrs_tools-info.1
Source13: mrs_tools-merge.1
Source14: mrs_tools-reorder.1
Source15: mrs_tools-reshape.1
Source16: mrs_tools-split.1
Source17: mrs_tools-vis.1
# The base package is arched due to endian-dependent test failures, but the
# binary packages are noarch and contain no compiled code.
%global debug_package %{nil}
BuildRequires: python3-devel
BuildRequires: %{py3_dist pytest}
%if %{with doc}
BuildRequires: make
BuildRequires: python3-sphinx-latex
BuildRequires: latexmk
%endif
%global common_description %{expand:
This package contains python-based tools for representing, validating, and
manipulating the NIfTI-MRS format. NIfTI-MRS is a standardized format for
storing Magnetic Resonance Spectroscopy data.
These tools are used extensively in the spec2nii format conversion program and
the FSL-MRS analysis software. However, this library can also be used as a
stand-alone set of tools.
If you use these tools please cite: Clarke, WT, Bell, TK, Emir, UE, et al.
NIfTI-MRS: A standard data format for magnetic resonance spectroscopy. Magn
Reson Med. 2022; 88: 2358- 2370. doi:10.1002/mrm.29418}
%description %{common_description}
%package -n python3-nifti-mrs
Summary: %{summary}
# The entire package is BSD-3-Clause, except the generated
# %%{python3_sitelib}/nifti_mrs/_version.py in python3-nifti-mrs, which is
# Unlicense because it is generated by Versioneer (python-versioneer).
License: BSD-3-Clause AND Unlicense
BuildArch: noarch
%description -n python3-nifti-mrs %{common_description}
%package -n mrs_tools
Summary: NIfTI-MRS (Magnetic Resonance Spectroscopy) tools
BuildArch: noarch
Requires: python3-nifti-mrs = %{version}-%{release}
%py_provides python3-mrs-tools
%description -n mrs_tools %{common_description}
# We don’t generate a metapackage for the “VIS” extra because it requires
# fsl-mrs, which (1) is not packaged, (2) is not on PyPI, (3) is non-free
# (non-commercial use only).
%if %{with doc}
%package doc
Summary: Documentation for python-nifti-mrs
BuildArch: noarch
%description doc %{common_description}
%endif
%prep
%autosetup -n nifti_mrs_tools-%{version}
%generate_buildrequires
%pyproject_buildrequires
%build
%pyproject_wheel
%if %{with doc}
PYTHONPATH="${PWD}/src" %make_build -C apidoc latex \
SPHINXOPTS='-j%{?_smp_build_ncpus}'
%make_build -C apidoc/_build/latex LATEXMKOPTS='-quiet'
%endif
%install
%pyproject_install
%pyproject_save_files -l nifti_mrs mrs_tools
install -t '%{buildroot}%{_mandir}/man1' -D -p -m 0644 \
'%{SOURCE10}' '%{SOURCE11}' '%{SOURCE12}' '%{SOURCE13}' '%{SOURCE14}' \
'%{SOURCE15}' '%{SOURCE16}' '%{SOURCE17}'
%check
%ifarch s390x
# Tests fail when file endianness does not match host endianness
# https://github.com/wtclarke/nifti_mrs_tools/issues/16
# Nevertheless, the software may still be useful on this architecture for
# processing big-endian NIfTI files, so we skip the tests rather than adding
# ExcludeArch.
k="${k-}${k+ and }not test_nifti_mrs_save"
k="${k-}${k+ and }not test_merge"
k="${k-}${k+ and }not test_split"
k="${k-}${k+ and }not test_reorder"
k="${k-}${k+ and }not test_reshape"
k="${k-}${k+ and }not test_conjugate"
%endif
%pytest -k "${k-}" -v
%files -n python3-nifti-mrs -f %{pyproject_files}
%if %{without doc}
%doc CHANGELOG.md
%doc README.md
%endif
%exclude %{python3_sitelib}/mrs_tools/
%files -n mrs_tools
%{python3_sitelib}/mrs_tools/
%{_bindir}/mrs_tools
%{_mandir}/man1/mrs_tools*.1*
%if %{with doc}
%files doc
%license LICENSE
%doc CHANGELOG.md
%doc README.md
%doc apidoc/_build/latex/nifti-mrs.pdf
%endif
%changelog
%autochangelog