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

# Run test suites upstream runs by default. Tests disabled here are
# optional and not run when running `test.py` without any arguments.
# Tests are listed in the order they appear in `test.py`.
# unit tests for pynwb package
%bcond test_pynwb             1
# integration tests
%bcond test_integration       1
# example tests
# Some tests require network, others additional unavailable modules
%bcond test_example           0
# example tests with ros3 streaming
# Internet access required (automatically disabled without it)
%bcond test_example_ros3      0
# backwards compatibility tests
%bcond test_backwards         1
# example tests and validation tests on example NWB files
%bcond test_validate_examples 0
# ros3 streaming tests
# Internet access required (automatically disabled without it)
%bcond test_ros3              0
# tests on pynwb.validate
# some tests fail for unknown reasons (more since 2.7.0)
%bcond test_validation_module 0

Name:           python-pynwb
Version:        2.8.3
Release:        %autorelease
Summary:        Package for working with Neurodata stored in the NWB format

# The entire source is BSD-3-Clause-LBNL, except:
#
# Unlicense:
#   - versioneer.py, a bundled and amalgamated copy of python3dist(versioneer),
#     is not distributed in the binary RPMs, but the _version.py it generates
#     is, and shares the same license
License:        BSD-3-Clause-LBNL AND Unlicense
URL:            https://github.com/NeurodataWithoutBorders/pynwb
# Use the pypi tar because GitHub tar does not include the required git-submodules
Source:         %{pypi_source pynwb}

BuildArch:      noarch

%global desc %{expand:
PyNWB is a Python package for working with NWB files. It provides a high-level
API for efficiently working with Neurodata stored in the NWB format.
https://pynwb.readthedocs.io/en/latest/}

%description %{desc}

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

BuildRequires:  python3-devel
BuildRequires:  python3-pytest
# Required for tests, not listed in requirements*.txt
BuildRequires:  python3-matplotlib

%description -n python3-pynwb %{desc}

%prep
%autosetup -n pynwb-%{version} -p1

# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters
sed -r -i 's@"coverage", "run", "-p"@"%{python3}"@' \
    tests/validation/test_validate.py

sed -r -i 's/==.*//' requirements.txt | tee requirements-unpinned.txt
#sed -i -e "s/h5py>.*'/h5py'/" -e "s/numpy>.*'/numpy'/" -e "s/pandas>.*'/pandas'/" setup.py

# TODO: Why does this happen? It seems like it is an issue with our test
# environment rather than a real bug.
#
# AssertionError: "<frozen runpy>:128:
#     RuntimeWarning: 'pyn[151 chars]ur\n" != ''
# - <frozen runpy>:128: RuntimeWarning: 'pynwb.validate' found in sys.modules
#     after import of package 'pynwb', but prior to execution of
#     'pynwb.validate'; this may result in unpredictable behaviour
sed -r -i '1{s/^/from unittest import skip\n/}' \
    tests/validation/test_validate.py
for n in \
    test_validate_file_cached \
    test_validate_file_cached_extension \
    test_validate_file_cached_extension_pass_ns \
    test_validate_file_cached_ignore \
    test_validate_file_list_namespaces_core \
    test_validate_file_list_namespaces_extension
do
  sed -r -i \
      "s/^([[:blank:]]*)(def $n\()/\1@skip('Re-import issues')\n\1\2/" \
      tests/validation/test_validate.py
done

%generate_buildrequires
%pyproject_buildrequires requirements-unpinned.txt

%build
%pyproject_wheel

%install
%pyproject_install
%pyproject_save_files pynwb

%check
# Generate test files
%{py3_test_envvars} %{python3} src/pynwb/testing/make_test_files.py
# See skips added in %%prep.
%{py3_test_envvars} %{python3} test.py \
%if %{with test_backwards}
    --backwards \
%endif
%if %{with test_example}
    --example \
%endif
%if %{with test_example_ros3}
    --example-ros3 \
%endif
%if %{with test_integration}
    --integration \
%endif
%if %{with test_pynwb}
    --pynwb \
%endif
%if %{with test_ros3}
    --ros3 \
%endif
%if %{with test_validate_examples}
    --validate-examples \
%endif
%if %{with test_validation_module}
    --validation-module \
%endif
    --verbose

%files -n python3-pynwb -f %{pyproject_files}
%license license.txt
%doc README.rst

%changelog
## START: Generated by rpmautospec
* Fri Dec 13 2024 Sandro <devel@penguinpee.nl> - 2.8.3-1
- Update to 2.8.3
- Close RHBZ#2332199 (NumPy 2.x)

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

* Mon Jun 17 2024 Python Maint <python-maint@redhat.com> - 2.7.0-3
- Rebuilt for Python 3.13

* Mon May 13 2024 Sandro <devel@penguinpee.nl> - 2.7.0-2
- Add Packit config

* Mon May 13 2024 Sandro <devel@penguinpee.nl> - 2.7.0-1
- Update to 2.7.0
- Works with pytest >= 8 (RHBZ#2275107)

* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 2.5.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

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

* Mon Oct 16 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.5.0-3
- Use %%{py3_test_envvars} to set up test environment

* Thu Oct 05 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.5.0-2
- Patch for python-hdmf 3.10.0 compatibility

* Thu Oct 05 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.5.0-1
- Update to 2.5.0

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

* Sun Jul 16 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.3.3-1
- Update to 2.3.3 (fix RHBZ#2220438)
- Update License to SPDX

* Thu Jul 13 2023 Python Maint <python-maint@redhat.com> - 2.1.0-3
- Rebuilt for Python 3.12

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

* Mon Aug 15 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 2.1.0-1
- feat: update to 2.1.0 (fixes rhbz#2113648)

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

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

* Sun Jan 16 2022 Ankur Sinha (Ankur Sinha Gmail) <sanjay.ankur@gmail.com> - 2.0.0-6
- feat: clean up spec file
- move to pyproject macros
- unpin dep versions

* Fri Aug 27 2021 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 2.0.0-4
- Also disable test on ppc64le where it fails too

* Fri Aug 27 2021 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 2.0.0-3
- Disable failing test on F34 only

* Fri Aug 27 2021 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 2.0.0-2
- Disable tests that fails on s390x

* Mon Aug 16 2021 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 2.0.0-1
- Update to latest release

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

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

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

* Sat Aug 22 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 1.4.0-1
- Update to 1.4.0

* Sun Aug 09 2020 Luis Bazan <lbazan@fedoraproject.org> - 1.3.3-1
- New upstream version

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

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

* Sun Feb 16 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 1.2.1-1
- Update to new release

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

* Thu Jan  9 2020 Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> - 1.1.2-2
- Remove dependency on unittest2 (#1789200)

* Fri Oct 25 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 1.1.2-1
- Update to 1.1.2

* Tue Sep 24 2019 Luis Bazan <lbazan@fedoraproject.org> - 1.1.0-2
- disable test

* Mon Sep 23 2019 Luis Bazan <lbazan@fedoraproject.org> - 1.1.0-1
- New upstream version

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

* Thu Jul 25 2019 Luis Bazan <lbazan@fedoraproject.org> - 1.0.3-1
- New upstream version

* Mon Apr 22 2019 Luis Bazan <lbazan@fedoraproject.org> - 1.0.2-1
- New upstream version

* Mon Apr 15 2019 Luis Bazan <lbazan@fedoraproject.org> - 1.0.1-2
- remove py2

* Mon Apr 15 2019 Luis Bazan <lbazan@fedoraproject.org> - 1.0.1-1
- New upstream version

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

* Mon Nov 26 2018 Luis Bazan <lbazan@fedoraproject.org> - 0.6.1-3
- Add buildrequires
- Enable tests (thanks Ankur)

* Mon Nov 26 2018 Luis Bazan <lbazan@fedoraproject.org> - 0.6.1-2
- Fix comment 2 in BZ 1651365

* Mon Nov 26 2018 Luis Bazan <lbazan@fedoraproject.org> - 0.6.1-1
- New upstream


## END: Generated by rpmautospec