## START: Set by rpmautospec
## (rpmautospec version 0.7.3)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 7;
    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

#global commit  f44636f00666b8eb869417960926d01690ff4f42
#global shortcommit #(c=#{commit}; echo ${c:0:7})
#global checkout_date 2023094
%global upstream_version  1.8.0

# setup.py does not list all requirements, and we also unbundle quite a few
# from the externals folder, so we can't only rely on the automatic generator
# here.
# Additionally, requirements.txt seems to be dev requirements, and is not used
# in setup.py for install_requires.

Name:           python-mne

%if "0%{?commit}" != "0"
Version:        %{upstream_version}^%{checkout_date}git%{shortcommit}
%global python_version  %{upstream_version}.dev%{checkout_date}
%else
Version:        %{upstream_version}
%global python_version  %{version}
%endif

Release:        %autorelease
Summary:        Magnetoencephalography (MEG) and Electroencephalography (EEG) data analysis

# Bundled FieldTrip
# https://github.com/fieldtrip/fieldtrip/blob/master/realtime/src/buffer/python/FieldTrip.py
# Not possible to package because it is matlab package with some plugins

# SPDX
License:        BSD-3-Clause
URL:            http://mne.tools/


%if "0%{?commit}" != "0"
Source0:        https://github.com/mne-tools/mne-python/archive/%{commit}/%{name}-%{shortcommit}.tar.gz
%else
Source0:        https://github.com/mne-tools/mne-python/archive/v%{version}/%{name}-%{version}.tar.gz
%endif

#Source1:        https://s3.amazonaws.com/mne-python/datasets/MNE-sample-data-processed.tar.gz

# https://fedoraproject.org/wiki/Changes/EncourageI686LeafRemoval
ExcludeArch:    %{ix86}

# The base package is arched to make it easier for us to detect arch-dependent
# test failures, since the tests will always be run on every platform, and
# easier for us to skip failing tests if necessary, since we can be sure that
# %%ifarch macros work as expected.
#
# Since the package still contains no compiled machine code, we still have no
# debuginfo.
%global debug_package %{nil}

BuildRequires:  python3-devel

%global _description %{expand:
This package is designed for sensor- and source-space analysis of M-EEG data,
including frequency-domain and time-frequency analyses and non-parametric
statistics.}

%description %_description

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

# This package is now arched because some dependencies are not available on
# every architecture.

Provides:       bundled(bootstrap)
Provides:       bundled(js-jquery)
Provides:       bundled(js-jquery-ui)
Provides:       bundled(js-d3)
Provides:       bundled(js-mpld3)
Provides:       bundled(python3-FieldTrip)
BuildRequires:  python3-setuptools
BuildRequires:  python3-numpy
BuildRequires:  python3-scipy

# Test deps
BuildRequires:  python3-pytest
BuildRequires:  python3-pytest-mock
BuildRequires:  python3-pytest-qt
BuildRequires:  python3-pytest-timeout
BuildRequires:  python3-pytest-xdist
BuildRequires:  python3-matplotlib
BuildRequires:  python3-pandas
BuildRequires:  python3-h5py
BuildRequires:  python3-decorator
%ifnarch s390x
# https://bugzilla.redhat.com/show_bug.cgi?id=2116690
BuildRequires:  python3-pymatreader
%endif
BuildRequires:  python3-h5io
BuildRequires:  python3-jinja2
BuildRequires:  python3-scikit-learn
BuildRequires:  python3-Traits
BuildRequires:  python3-tqdm
BuildRequires:  python3-nibabel
%ifnarch s390x
BuildRequires:  python3-pyedflib
%endif
BuildRequires:  python3-nilearn
BuildRequires:  python3-qt5
BuildRequires:  python3-dipy
BuildRequires:  python3-xlrd
BuildRequires:  python3-nitime
BuildRequires:  python3-pooch
BuildRequires:  python3-nbformat
BuildRequires:  python3-vtk
# Makes pytest segfault
# BuildRequires:  python3-mayavi

Requires:       python3-matplotlib
Requires:       python3-decorator
Requires:       python3-h5io
Requires:       python3-six
Requires:       python3-tempita
Requires:       python3-tqdm
%ifnarch s390x
Requires:       python3-pymatreader
%endif
Recommends:     python3-scikit-learn
Recommends:     python3-pandas
Recommends:     python3-patsy
Recommends:     python3-pillow
Recommends:     python3-h5py
Recommends:     python3-statsmodels
Recommends:     python3-Traits

# Should be included by the dep generator as they're mentioned in setup.py
# Requires:       python3-numpy
# Requires:       python3-scipy

%description -n python3-mne %_description

%prep
%if "0%{?commit}" != "0"
%autosetup -n mne-python-%{commit} -p1
%else
%autosetup -n mne-python-%{version} -p1
%endif

# fix non-executable scripts
sed -i -e '1{\@^#!/usr/bin/env python@d}' mne/commands/*.py
sed -i -e '1{\@^#!/usr/bin/env python@d}' mne/datasets/hf_sef/hf_sef.py
sed -i -e '1{\@^#!/usr/bin/env python@d}' mne/stats/cluster_level.py

# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters
sed -r -i 's/--cov[^[:blank:]]+//g' pyproject.toml


%generate_buildrequires
export SETUPTOOLS_SCM_PRETEND_VERSION='%{python_version}'
%pyproject_buildrequires

#cp -p %{SOURCE1} .
#python -c "import mne; mne.datasets.sample.data_path(verbose=True, download=False)"

%build
export SETUPTOOLS_SCM_PRETEND_VERSION='%{python_version}'
%pyproject_wheel

%install
export SETUPTOOLS_SCM_PRETEND_VERSION='%{python_version}'
%pyproject_install
%pyproject_save_files -l mne

%check
export SETUPTOOLS_SCM_PRETEND_VERSION='%{python_version}'
export MNE_SKIP_TESTING_DATASET_TESTS=true
export MNE_SKIP_NETWORK_TESTS=1
export MNE_DONTWRITE_HOME=true
export MNE_FORCE_SERIAL=true

# Deselected tests require additional data or don't work in mock
# Two deselected for sklearn warnings
ignore="${ignore-} --ignore=mne/datasets/tests/test_datasets.py"
ignore="${ignore-} --ignore=mne/utils/tests/test_numerics.py"
# Tools directory ignored as it contains tests for upstream release process

# required for some tests
mkdir subjects

# Hangs:
k="${k-}${k+ and }not test_thresholds[NumPy]"
# FileNotFoundError (file 'test_eyelink.asc' not in repo):
k="${k-}${k+ and }not test_annotations_without_offset"
%ifarch s390x || ppc64le
# Test fails on s390x and ppc64le.
k="${k-}${k+ and }not test_spectrum_complex[welch-False]"
%endif
# Fails with Python 3.13 (upstream tests with 3.12 still)
# https://github.com/mne-tools/mne-python/issues/13013
%if "%{python3_version}" >= "3.13"
k="${k-}${k+ and }not mne.utils.docs.copy_doc"
k="${k-}${k+ and }not mne.utils.docs.copy_function_doc_to_method_doc"
k="${k-}${k+ and }not test_copy_function_doc_to_method_doc"
%endif
# Fails on F40 (didn't investigate)
# Failed: DID NOT WARN. No warnings of type (<class 'RuntimeWarning'>,) were emitted.
# The list of emitted warnings is: [].
%if "%{fedora}" <= "40"
k="${k-}${k+ and }not test_brainvision_data_software_filters_latin1_global_units"
k="${k-}${k+ and }not test_brainvision_vectorized_data"
k="${k-}${k+ and }not test_ica_simple[fastica]"
k="${k-}${k+ and }not test_fit_sphere_to_headshape"
k="${k-}${k+ and }not test_compute_whitener_rank"
%endif
# Test segfaults intermittently
k="${k-}${k+ and }not test_plotting_scalebars[matplotlib]"


# https://github.com/mne-tools/mne-python/blob/v1.0.3/tools/github_actions_test.sh#L7
# skip tests that require network
m='not (slowtest or pgtest)'

# Erroring on DeprecationWarnings makes sense upstream, but is probably too
# strict for distribution packaging.
%pytest -v -m "${m}" ${ignore-} -k "${k-}" -W 'ignore::DeprecationWarning'


%files -n python3-mne -f %{pyproject_files}
%doc README.rst examples
%{_bindir}/mne

%changelog
## START: Generated by rpmautospec
* Thu Aug 22 2024 Packit <hello@packit.dev> - 1.8.0-1
- Update to 1.8.0 upstream release
- Resolves: rhbz#2292547

* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.6.1-7
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Fri Feb 16 2024 Sandro <devel@penguinpee.nl> - 1.6.1-6
- Apply upstream patch fixing failig tests

* Wed Jan 24 2024 Sandro <devel@penguinpee.nl> - 1.6.1-5
- Skip failing test on s390x and ppc64le

* Wed Jan 24 2024 Sandro <devel@penguinpee.nl> - 1.6.1-4
- Migrate to SPDX license

* Wed Jan 24 2024 Sandro <devel@penguinpee.nl> - 1.6.1-3
- Skip failing test

* Wed Jan 24 2024 Sandro <devel@penguinpee.nl> - 1.6.1-2
- Drop patches (merged upstream)

* Wed Jan 24 2024 Packit <hello@packit.dev> - 1.6.1-1
- [packit] 1.6.1 upstream release
- Resolves rhbz#2250903

* Mon Jan 22 2024 Fedora Release Engineering <releng@fedoraproject.org> - 1.5.1-10
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

* Wed Jan 03 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.5.1-9
- Assert that the .dist-info directory contains a license file

* Fri Oct 20 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.5.1-8
- Remove default “-r” from %%pyproject_buildrequires

* Fri Oct 20 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.5.1-7
- Do not error on DeprecationWarnings at all

* Fri Oct 20 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.5.1-6
- Ignore SciPy using deprecated API

* Fri Oct 20 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.5.1-5
- Patch out coverage analysis

* Fri Oct 20 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.5.1-4
- Fix bug with clip box setting

* Wed Oct 18 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.5.1-3
- Skip test_thresholds[NumPy] because it hangs

* Wed Oct 18 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.5.1-1
- Update to 1.5.1 (close RHBZ#2238003)

* Tue Oct 17 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.5.0^2023094gitf44636f-2
- Exporting PYTHONPATH is redundant with %%pytest macro

* Mon Sep 04 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 1.5.0^2023094gitf44636f-1
- feat: fix build using snapshot (fixes rhbz#2220333, rhbz#2203048)

* Tue Aug 29 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 1.5.0-2
- chore: add packit conf

* Tue Aug 29 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 1.5.0-1
- feat: update to 1.5.0 (fixes rhbz#2203048)

* Sun Jul 23 2023 Python Maint <python-maint@redhat.com> - 1.3.1-4
- Rebuilt for Python 3.12

* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 1.3.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Wed Jul 19 2023 Python Maint <python-maint@redhat.com> - 1.3.1-2
- Rebuilt for Python 3.12

* Mon Feb 27 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 1.3.1-1
- feat: update to 1.3.1 (fixes rhbz#2173212)

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

* Thu Jan 12 2023 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 1.3.0-1
- feat: update to 1.3.0 (fixes rhbz#2142239)

* Sat Nov 26 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.2.1-3
- Work around no pymatreader on s390x

* Fri Oct 28 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.2.1-2
- Backport upstream patch for ppc64le/aarch64 test failures

* Fri Oct 28 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.2.1-1
- Update to 1.2.1 (close RHBZ#2136474)

* Sun Oct 16 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 1.2.0-1
- feat: update to 1.2.0 (fixes rhbz#2115503)

* Mon Aug 01 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.0.3-3
- Make base package arched
- This allows arch-conditional BR’s and ensures tests run on all arches
- Document and skip a few arch-dependent failing tests

* Wed Jul 27 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 1.0.3-2
- feat: ExcludeArch ix86

* Mon Jul 25 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 1.0.3-1
- feat: update to 1.0.3 (fixes rhbz#2066625)

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

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

* Fri Jan 21 2022 Fedora Release Engineering <releng@fedoraproject.org> - 0.24.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild

* Sun Jan 16 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 0.24.1-3
- fix: exclude pyedflib on s390x

* Sun Jan 16 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 0.24.1-2
- chore: minor fixes
- add more BRs
- re-remove externals

* Sun Jan 16 2022 Vanessa_kris <vanessaigwe1@gmail.com> - 0.24.1-1
- update to latest release v0.24.1

* Mon Sep 13 2021 Aniket Pradhan <major AT fedoraproject DOT org> - 0.23.4-2
- Added unbundled dep (tqdm) to requires
- Added a test dependency

* Sat Sep 11 2021 Aniket Pradhan <major AT fedoraproject DOT org> - 0.23.4-1
- Update to v0.23.4
- Fix test tolerances for ARM arch

* Mon Aug 30 2021 Miro Hrončok <mhroncok@redhat.com> - 0.23.3-1
- Update to 0.23.3
- Remove unused dependency on funcsigs
- Fixes: rhbz#1945960
- Fixes: rhbz#1914283

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

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

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

* Wed Dec 30 2020 Aniket Pradhan <major AT fedoraproject DOT org> - 0.22.0-1
- Update to v0.22.0
- Fix tests for s390x arch

* Sat Nov 07 2020 Aniket Pradhan <major AT fedoraproject DOT org> - 0.21.2-1
- Update to v0.21.2
- enable test: mne/preprocessing/tests/test_xdawn.py. Fixed upstream

* Sat Nov 07 2020 Aniket Pradhan <major AT fedoraproject DOT org> - 0.21.1-1
- Update to v0.21.1
- Fix tqdm imports
- Temporarily disable test: mne/preprocessing/tests/test_xdawn.py

* Sat Aug 01 2020 Fedora Release Engineering <releng@fedoraproject.org> - 0.20.7-3
- Second attempt - Rebuilt for
  https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

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

* Sun Jun 21 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.20.7-1
- Update to 0.20.7

* Tue Jun 02 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.20.4-2
- Deselect failing tests: test_scalar, test_get_coef
- https://github.com/mne-tools/mne-python/issues/7860

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

* Sat Apr 04 2020 Aniket Pradhan <major AT fedoraproject DOT org> - 0.20.4-1
- Update to v0.20.4
- Fix dependencies (removed jdcal, added tqdm and others)
- Deselected tests that require additional data

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

* Mon Nov 11 2019 Aniket Pradhan <major AT fedoraproject DOT org> - 0.19.1-1
- Update to v0.19.1

* Thu Oct 10 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.19.0-1
- Update to new upstream release

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

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

* Tue May 28 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.18.1-1
- Update to 0.18.1 (rbhz 1695469)
- Use dep generator
- Remove bundled doccer
- Remove missing AUTHORS file

* Fri Feb 22 2019 Manas Mangaonkar <pac23 AT fedoraproject DOT org> - 0.17.1-1
- Update to latest release

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

* Tue Nov 20 2018 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.17-1
- Update to latest release
- Use system funcsigs and pymatreader

* Wed Oct 17 2018 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 0.13.1-9
- Subpackage python2-mne has been removed
  See https://fedoraproject.org/wiki/Changes/Mass_Python_2_Package_Removal

* Sat Jul 14 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.13.1-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Tue Jun 19 2018 Miro Hrončok <mhroncok@redhat.com> - 0.13.1-7
- Rebuilt for Python 3.7

* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.13.1-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Thu Jan 25 2018 Iryna Shcherbina <ishcherb@redhat.com> - 0.13.1-5
- Update Python 2 dependency declarations to new packaging standards
  (See https://fedoraproject.org/wiki/FinalizingFedoraSwitchtoPython3)

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.13.1-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.13.1-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Mon Dec 19 2016 Miro Hrončok <mhroncok@redhat.com> - 0.13.1-2
- Rebuild for Python 3.6

* Tue Nov 29 2016 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.13.1-1
- Update to 0.13.1

* Mon Sep 26 2016 Dominik Mierzejewski <rpm@greysector.net> - 0.10-8
- rebuilt for matplotlib-2.0.0

* Tue Jul 19 2016 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.10-7
- https://fedoraproject.org/wiki/Changes/Automatic_Provides_for_Python_RPM_Packages

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.10-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Sun Nov 29 2015 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.10-5
- Rebuild for fixed scipy

* Wed Nov 11 2015 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.10-4
- Fix non-executable-script

* Mon Nov 09 2015 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.10-3
- Fix unbundling jdcal

* Sun Nov 08 2015 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.10-2
- /usr/bin/mne uses python3
- fix dependencies around Traits (add py3 version)
- unbundle jdcal/six/decorator/tempita/h5io
- add Provides: bundled(pythonX-FieldTrip)
- More better Summary

* Fri Oct 30 2015 Igor Gnatenko <i.gnatenko.brain@gmail.com> - 0.10-1
- Initial package

## END: Generated by rpmautospec