Blob Blame History Raw
# 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_without tests

%global srcname 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.}


Name:           python-%{srcname}
Version:        1.6.4
Release:        1%{?dist}
Summary:        Fast random access of gzip files in Python

License:        zlib
URL:            https://github.com/pauldmccarthy/%{srcname}
Source0:        %{pypi_source %{srcname}}

%description
%{desc}

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

BuildRequires:  gcc
BuildRequires:  zlib-devel
BuildRequires:  %{py3_dist Cython}

%if %{with tests}
# tests_require in setup.py:
BuildRequires:  %{py3_dist pytest}
BuildRequires:  %{py3_dist numpy}
BuildRequires:  %{py3_dist nibabel}
BuildRequires:  %{py3_dist coverage}
BuildRequires:  %{py3_dist pytest-cov}
%endif

%description -n python3-%{srcname}
%{desc}

%generate_buildrequires
%pyproject_buildrequires -r

%prep
%autosetup -n %{srcname}-%{version}
# Remove shebangs from non-script sources
find %{srcname} -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 %{srcname} -type f -name '*.pyx' | sed -r 's/\.pyx$/.c/' | xargs -r rm -vf

%build
%pyproject_wheel

%install
%pyproject_install
%pyproject_save_files %{srcname}

%check
%if %{with tests}
%pytest %{buildroot}%{python3_sitearch}/%{srcname}/
%endif

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

%changelog
* 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