## START: Set by rpmautospec
## (rpmautospec version 0.3.0)
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 3;
    base_release_number = tonumber(rpm.expand("%{?-b*}%{!?-b:1}"));
    print(release_number + base_release_number - 1);
}%{?-e:.%{-e*}}%{?-s:.%{-s*}}%{!?-n:%{?dist}}
## END: Set by rpmautospec

# make main package noarch to run tests on all arches
# but the package is actually noarch, so don't generate debuginfo
%global debug_package %{nil}

%global desc %{expand: \
Nilearn is a Python module for fast and easy statistical learning on
NeuroImaging data.

It leverages the scikit-learn Python toolbox for multivariate statistics with
applications such as predictive modelling, classification, decoding, or
connectivity analysis.

This work is made available by a community of people, amongst which the INRIA
Parietal Project Team and the scikit-learn folks, in particular P. Gervais, A.
Abraham, V. Michel, A. Gramfort, G. Varoquaux, F. Pedregosa, B. Thirion, M.
Eickenberg, C. F. Gorgolewski, D. Bzdok, L. Esteve and B. Cipollini.

Detailed documentation is available at http://nilearn.github.io/.}

Name:           python-nilearn
Version:        0.10.0
Release:        %autorelease
Summary:        Python module for fast and easy statistical learning on NeuroImaging data

License:        BSD
URL:            https://pypi.python.org/pypi/nilearn
# Use GitHub tar: pypi does not include all test data
Source0:        https://github.com/nilearn/nilearn/archive/%{version}/%{name}-%{version}.tar.gz

# Fix for nibabel 5.x
Patch0:         https://patch-diff.githubusercontent.com/raw/nilearn/nilearn/pull/3458.patch


BuildRequires:  python3-devel
BuildRequires:  %{py3_dist pytest}
BuildRequires:  git-core

Recommends:  %{py3_dist matplotlib}

%description
%{desc}

%package -n python3-nilearn
Summary:        %{summary}
BuildArch:      noarch

%description -n python3-nilearn
%{desc}

%prep
%autosetup -n nilearn-%{version} -S git
# Remove shebangs
find . -name "*py" -exec sed -i '/#!\/usr\/bin\/env python/ d' '{}' \;
# Remove pre-compiled files
find . -name "*pyc" -exec rm -f '{}' \;

# Correct python command
sed -i 's/python/python3/' nilearn/plotting/html_document.py
#sed -i 's/python/python3/' nilearn/plotting/glass_brain_files/generate_json.sh

%generate_buildrequires
%pyproject_buildrequires -r

%build
%pyproject_wheel

# Documentation also fetches imaging data set from online sources, so we cannot
# generate it. We include the link to the documentation in the description.

%install
%pyproject_install
%pyproject_save_files nilearn

%check

# https://github.com/nilearn/nilearn/issues/3232
%ifarch s390x %{power64} %{arm64} %{arm32} %{ix86}
k="${k:-}${k:+ and} not test_load_confounds"
%endif
# test fails on i686
%ifarch s390x %{power64} %{arm64} %{arm32} %{ix86}
k="${k:-}${k:+ and} not test_tfce_smoke"
%endif

%{pytest} -k "${k:-}" nilearn

%files -n python3-nilearn -f %{pyproject_files}
%doc AUTHORS.rst README.rst

%changelog
* Mon Feb 06 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 0.10.0-3
- fix: include patch to fix for python-nibabel 5.x

* Fri Jan 20 2023 Fedora Release Engineering <releng@fedoraproject.org> 0.10.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild

* Fri Jan 06 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 0.10.0-1
- feat: update to 0.10.0 (fixes rhbz#2158756)

* Sun Oct 16 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 0.9.2-2
- fix: disable randomly failing tests (fix rhbz#2126115)

* Sun Oct 09 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 0.9.2-1
- feat: update to 0.9.2 (fixes rh#2126115 fixes rhbz#2121065)

* Fri Jul 22 2022 Fedora Release Engineering <releng@fedoraproject.org> 0.9.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild

* Mon Jul 04 2022 Python Maint <python-maint@redhat.com> 0.9.1-2
- Rebuilt for Python 3.11

* Thu May 05 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 0.9.1-1
- feat: update to 0.9.1

* Fri Apr 29 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 0.9.0-4
- improvement: explicitly mention arm32

* Fri Apr 29 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 0.9.0-3
- fix: also disable failing tests on arm32

* Thu Apr 28 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 0.9.0-2
- fix: disable few failing tests on necessary arches

* Mon Feb 21 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> 0.9.0-1
- feat: update to 0.9.0 (fixes rhbz#2047860)

* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 0.7.1-2
- Rebuilt for Python 3.10

* Sun Mar 28 2021 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.7.1-1
- Update to latest release

* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Sat Nov 28 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.7.0-1
- Update to latest release

* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.6.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Thu Jun 25 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.6.2-3
- Explicitly BR setuptools

* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 0.6.2-2
- Rebuilt for Python 3.9

* Wed Apr 22 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.6.2-1
- Update to 0.6.2

* Thu Feb 13 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.6.1-2
- Remove dummy sklearn requirement from setup.py
- Remove py2 bits from spec

* Sun Feb 02 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.6.1-1
- Update to newest version

* Thu Jan 30 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.5.2-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild

* Mon Aug 19 2019 Miro Hrončok <mhroncok@redhat.com> - 0.5.2-3
- Rebuilt for Python 3.8

* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.5.2-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild

* Mon May 27 2019 Luis Bazan <lbazan@fedoraproject.org> - 0.5.2-1
- Update to 0.5.2

* Sun Apr 14 2019 Manas Mangaonkar <pac23@fedoraproject.org> - 0.5.1-1
- Update to 0.5.1

* Wed Apr 10 2019 Ankur Sinha <ankursinha@fedoraproject.org> - 0.5.0-1
- Update to 0.5.0

* Sat Feb 02 2019 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.2-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_30_Mass_Rebuild

* Fri Nov 09 2018 Ankur Sinha <ankursinha@fedoraproject.org> - 0.4.2-2
- Correct license
- Remvoe shebangs
- Remove pre-compiled files

* Thu Nov 08 2018 Ankur Sinha <ankursinha@fedoraproject.org> - 0.4.2-1
- Initial build