## 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

# Tests are not meant to be run against installed version, says upstream
# (https://github.com/pauldmccarthy/indexed_gzip/issues/13). Still, we manage
# to make it work. Note that some tests are very slow.
%bcond tests 1

%bcond nibabel 1

Name:           python-indexed_gzip
Version:        1.9.4
Release:        %autorelease
Summary:        Fast random access of gzip files in Python

License:        Zlib
URL:            https://github.com/pauldmccarthy/indexed_gzip
Source:         %{pypi_source indexed_gzip}

%global desc %{expand:
The indexed_gzip project is a Python extension which aims to provide a drop-in
replacement for the built-in Python gzip.GzipFile class, the IndexedGzipFile.

indexed_gzip was written to allow fast random access of compressed NIFTI image
files (for which GZIP is the de-facto compression standard), but will work with
any GZIP file. indexed_gzip is easy to use with nibabel.

The standard gzip.GzipFile class exposes a random access-like interface (via
its seek and read methods), but every time you seek to a new point in the
uncompressed data stream, the GzipFile instance has to start decompressing from
the beginning of the file, until it reaches the requested location.

An IndexedGzipFile instance gets around this performance limitation by building
an index, which contains *seek points*, mappings between corresponding
locations in the compressed and uncompressed data streams. Each seek point is
accompanied by a chunk (32KB) of uncompressed data which is used to initialize
the decompression algorithm, allowing us to start reading from any seek point.
If the index is built with a seek point spacing of 1MB, we only have to
decompress (on average) 512KB of data to read from any location in the file.}

%description %{desc}

%package -n python3-indexed-gzip
Summary:        %{summary}
BuildRequires:  python3-devel

BuildRequires:  gcc
BuildRequires:  zlib-devel

%if %{with tests}
# tests_require in setup.py:
BuildRequires:  %{py3_dist pytest}
BuildRequires:  %{py3_dist numpy}
%if %{with nibabel}
BuildRequires:  %{py3_dist nibabel}
%endif
# added downstream to run tests in parallel:
BuildRequires:  %{py3_dist pytest-xdist}
%endif

# The binary subpackage was renamed to match the project canonical name
# (https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_canonical_project_name).
# Ideally, the whole package would be renamed to python-indexed-gzip. This
# provides a clean upgrade path.
%py_provides python3-indexed_gzip
Obsoletes:      python3-indexed_gzip < 1.7.0-4

%description -n python3-indexed-gzip %{desc}

%generate_buildrequires
%pyproject_buildrequires

%prep
%autosetup -n indexed_gzip-%{version} -p1
# Remove shebangs from non-script sources
find indexed_gzip -type f -name '*.py' \
    -exec gawk '/^#!/ { print FILENAME }; { nextfile }' '{}' '+' |
  xargs -r sed -r -i '1{/^#!/d}'
# Make sure Cythonized C source files are not present in the tarball; they must
# be regenerated. Retain “hand-written” C sources.
find indexed_gzip -type f -name '*.pyx' | sed -r 's/\.pyx$/.c/' | xargs -r rm -vf

%build
%pyproject_wheel

%install
%pyproject_install
%pyproject_save_files -l indexed_gzip

%check
%if %{with tests}
%pytest %{buildroot}%{python3_sitearch}/indexed_gzip -n auto -k "${k-}"
%endif

%files -n python3-indexed-gzip -f %{pyproject_files}
%doc README.md

%changelog
## START: Generated by rpmautospec
* Wed Nov 27 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.9.4-1
- Update to 1.9.4 (close RHBZ#2329140)

* Sat Nov 16 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.9.1-1
- Update to 1.9.1 (close RHBZ#2326477)

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

* Sat Jun 08 2024 Python Maint <python-maint@redhat.com> - 1.8.7-5
- Rebuilt for Python 3.13

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

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

* Wed Jan 03 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 1.8.7-2
- Assert that a license file is present in the .dist-info directory

* Thu Nov 09 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.8.7-1
- Update to 1.8.7 (close RHBZ#2248517)

* Wed Oct 18 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.8.5-2
- Stop skipping tests that now work with Python 3.12.0 final

* Wed Aug 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.8.5-1
- Update to 1.8.5 (close RHBZ#2235884)

* Tue Jul 25 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.8.3-2
- Skip a couple of failing nibabel integration tests

* Tue Jul 25 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.8.3-1
- Update to 1.8.3 (close RHBZ#2225478)

* Tue Jul 25 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.1-8
- Revert "Temporarily disable nibabel integration testing"

* Fri Jul 21 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.1-7
- Use the Cython compat package and report Cython 3 issues upstream

* Tue Jul 11 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.1-5
- Patch for Python 3.12 (fix RHBZ#2220277)

* Tue Jul 11 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.1-4
- Temporarily disable nibabel integration testing

* Tue Jul 11 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.1-3
- Conditionalize nibabel integration testing

* Tue Jul 11 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.1-2
- Use new (rpm 4.17.1+) bcond style

* Fri Apr 07 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.1-1
- Update to 1.7.1 (close RHBZ#2183571)

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

* Wed Dec 21 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.0-5
- Rely on PYTEST_XDIST_AUTO_NUM_WORKERS

* Wed Nov 30 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.0-4
- Rename the binary package to match the canonical name

* Wed Nov 30 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.0-3
- Update License to SPDX

* Wed Nov 30 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.0-2
- Drop default -r argument to pyproject_buildrequires

* Tue Sep 13 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.7.0-1
- Update to 1.7.0 (close RHBZ#2126154)

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

* Tue Jul 12 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.13-4
- Run tests in parallel

* Mon Jul 11 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.13-3
- Fix extra newline in description

* Tue Jun 14 2022 Python Maint <python-maint@redhat.com> - 1.6.13-2
- Rebuilt for Python 3.11

* Fri Apr 15 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.13-1
- Update to 1.6.13 (close RHBZ#2075570)

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

* Tue Oct 19 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.4-1
- Update to 1.6.4 (close RHBZ#2015352)

* Tue Sep 14 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.3-1
- Update to 1.6.3 (close RHBZ#2004204)
- Stop using deprecated zero-argument version of pypi_source macro
- Drop BR on pyproject-rpm-macros, since python3-devel now implies it
- Let pyproject-rpm-macros handle the license file
- Preserve mtimes on sources from which no shebang was removed

* Sat Sep 04 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.2-1
- Update to 1.6.2 (close RHBZ#2000944)

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

* Mon Jul 19 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 1.6.1-1
- Update to 1.6.1 (closes RHBZ#1963719)
- Make sure pre-generated Cython C sources really are removed
- Drop %%py_provides, no longer needed after F32
- Use pyproject-rpm-macros
- Run tests, despite https://github.com/pauldmccarthy/indexed_gzip/issues/13

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

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

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

* Sun Jan 10 2021 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 1.4.0-1
- Update to latest release

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

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

* Sat Jul 04 2020 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 1.3.2-1
- Update to new version

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

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

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

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

* Thu Oct 03 2019 Miro Hrončok <mhroncok@redhat.com> - 0.8.10-5
- Rebuilt for Python 3.8.0rc1 (#1748018)

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

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

* Mon May 20 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.8.10-2
- Remove cythonised sources

* Fri May 17 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.8.10-1
- Update to newest release
- rhbz: 1710384

* Wed Apr 10 2019 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.8.8-1
- Update to latest upstream release

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

* Fri Nov 09 2018 Ankur Sinha <ankursinha AT fedoraproject DOT org> - 0.8.7-1
- Initial build

## END: Generated by rpmautospec