Blob Blame History Raw
%bcond tests 1

%global forgeurl https://github.com/nipy/nipy
%global version 0.6.0
# Use either tag or commit
%global tag %{version}
#%%global commit e5e063b09d094ff79d2089261828fd2b2c843ab6
%forgemeta

# Lower build type safety to level 1 to avoid `-Wint-conversion` turning
# into an error
%global build_type_safety_c 1

Name:           python-nipy
Version:        %forgeversion
Release:        %autorelease
Epoch:          1
Summary:        Neuroimaging in Python FMRI analysis package

License:        BSD-3-Clause
URL:            https://nipy.org/nipy
Source0:        %forgesource

# Man pages hand-written for Fedora in groff_man(7) format based on --help
Source10:       nipy_3dto4d.1
Source11:       nipy_4d_realign.1
Source12:       nipy_4dto3d.1
Source13:       nipy_diagnose.1
Source14:       nipy_tsdiffana.1

# Improve const-correctness in C code
# https://github.com/nipy/nipy/pull/545
Patch:          https://github.com/nipy/nipy/pull/545.patch

# Drop i686 (leaf package)
# https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval
ExcludeArch:    %{ix86}

BuildRequires:  python3-devel
BuildRequires:  gcc
BuildRequires:  pkgconfig(flexiblas)

%if %{with tests}
BuildRequires:  nipy-data
%endif

%global _docdir_fmt %{name}

%global common_description %{expand:
Neuroimaging tools for Python.

The aim of NIPY is to produce a platform-independent Python environment for the
analysis of functional brain imaging data using an open development model.

In NIPY we aim to:

• Provide an open source, mixed language scientific programming environment
  suitable for rapid development.
• Create software components in this environment to make it easy to develop
  tools for MRI, EEG, PET and other modalities.
• Create and maintain a wide base of developers to contribute to this platform.
• Maintain and develop this framework as a single, easily installable bundle.}

%description %{common_description}


%package -n python3-nipy
Summary:        %{summary}

# Optional extra provides `matplotlib`
# Adds various plotting functionality, but not an “official” dependency
Recommends:     python3dist(nipy+optional)

Suggests:       nipy-data

# The nipy.algorithms.statistics.models subpackage was forked from an
# undetermined version of scipy.stats.models in commit 55a9162 on 2011-09-13;
# before this, the upstream version was monkey-patched via
# nipy.fixes.scipy.stats.models.
Provides:       bundled(python3dist(scipy))

%description -n python3-nipy %{common_description}


%pyproject_extras_subpkg -n python3-nipy optional


%package doc
Summary:        Documentation and examples for python-nipy

BuildArch:      noarch

Requires:       nipy-data
Requires:       (python3-nipy = %{?epoch:%{epoch}:}%{version}-%{release} if python3-nipy)

%description doc
%{summary}.


%prep
%forgeautosetup -p1

# Remove bundled lapack_lite:
rm -rvf lib/lapack_lite/
sed -r -i 's/^.*lapack_lite/# &/' lib/meson.build
sed -r -i 's/^#(external *= *)(False|0)/\1True/' setup.cfg

# Remove ninja from build requirements
# See https://github.com/nipy/nipy/pull/551 for discussion
sed -r -i '/ninja/d' pyproject.toml

# It looks like fff/fff_python_wrapper is a part of nipy rather than a bundled
# exgternal library.

# https://docs.fedoraproject.org/en-US/packaging-guidelines/BLAS_LAPACK/
sed -r -i 's/openblas/flexiblas/' nipy/labs/meson.build

# Remove pre-generated Cython C sources (there should not be any):
grep -FrlI 'Generated by Cython' . | xargs -r rm -vf

%py3_shebang_fix nipy examples

cp -p nipy/algorithms/statistics/models/LICENSE.txt scipy-LICENSE.txt

# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters
sed -i '/pytest-cov/d' pyproject.toml

# Remove VCS artifact
rm -vf examples/.gitignore


%generate_buildrequires
%pyproject_buildrequires -w -x optional%{?with_tests:,test}


%build
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files nipy

install -t '%{buildroot}%{_mandir}/man1' -m 0644 -p -D \
    '%{SOURCE10}' '%{SOURCE11}' '%{SOURCE12}' '%{SOURCE13}' '%{SOURCE14}'


%check
%pyproject_check_import -e '*.test*'
%if %{with tests}
# The docstring says: “fixme : this one often fails. I don't really see why”
k="${k-}${k+ and }not test_gmm_bf"
# Below tests fail since 0.6.0
# https://github.com/nipy/nipy/issues/562
# some are globs for multiple tests
k="${k-}${k+ and }not test_em"
k="${k-}${k+ and }not test_imm"
k="${k-}${k+ and }not test_pproba"

# See: .github/workflows/test.yml
mkdir -p for_testing
cd for_testing
%pytest -v --doctest-plus --ignore-glob='__config__.py' -k "${k-}" --pyargs nipy
%endif


%files -n python3-nipy -f %{pyproject_files}
%license LICENSE
%license scipy-LICENSE.txt

%{_bindir}/nipy_3dto4d
%{_bindir}/nipy_4d_realign
%{_bindir}/nipy_4dto3d
%{_bindir}/nipy_diagnose
%{_bindir}/nipy_tsdiffana

%{_mandir}/man1/nipy_3dto4d.1*
%{_mandir}/man1/nipy_4d_realign.1*
%{_mandir}/man1/nipy_4dto3d.1*
%{_mandir}/man1/nipy_diagnose.1*
%{_mandir}/man1/nipy_tsdiffana.1*


%files doc
%license LICENSE
%license scipy-LICENSE.txt

%doc AUTHOR
%doc Changelog
%doc README.rst
%doc THANKS

%doc examples/


%changelog
%autochangelog