## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## 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

# Sphinx-generated HTML documentation is not suitable for packaging; see
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555 for discussion.
#
# We can generate PDF documentation as substitute.
%bcond doc_pdf 1

%global forgeurl https://github.com/holgern/pyedflib

%global _description %{expand:
pyEDFlib is a python library to read/write EDF+/BDF+ files based on EDFlib.
EDF means European Data Format and was firstly published Kemp1992. 
In 2003, an improved version of the file protocol named EDF+ has 
been published and can be found at Kemp2003.}

Name:           python-pyedflib
Version:        0.1.38
Release:        %autorelease
Summary:        Python library to read/write EDF+/BDF+ files, based on EDFlib
%forgemeta
# The entire source is BSD-3-Clause, except:
#   BSD-2-Clause: pyedflib/_extensions/edf.pxi
License:        BSD-3-Clause AND BSD-2-Clause
URL:            %forgeurl
Source:         %forgesource

# https://bugzilla.redhat.com/show_bug.cgi?id=2027046
ExcludeArch:    s390x

# Uses a forked copy of EDFlib (https://gitlab.com/Teuniz/EDFlib)
# https://github.com/holgern/pyedflib/issues/149
# Version number: pyedflib/_extensions/c/edflib.c, EDFLIB_VERSION
%global edflib_version 1.17
Provides:       bundled(edflib) = %{edflib_version}

%description %_description

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

BuildRequires:  gcc-c++
BuildRequires:  make
BuildRequires:  python3-devel
BuildRequires:  %{py3_dist toml-adapt}
BuildRequires:  %{py3_dist pytest}

%description -n python3-pyedflib %_description

%package doc
Summary:        Documentation and examples for pyedflib
BuildArch:      noarch

%if %{with doc_pdf}
BuildRequires:  make
BuildRequires:  python3-sphinx-latex
BuildRequires:  latexmk
BuildRequires:  python3dist(sphinx)
BuildRequires:  python3dist(matplotlib)
BuildRequires:  python3dist(numpydoc)
%endif

# Required by some demos/examples:
Suggests:       python3dist(matplotlib)
Suggests:       python3dist(scipy)

%description doc
%{summary}.

%prep
%autosetup -p1 -n pyedflib-%{version}
# Avoid “too deeply nested” error generating LaTeX from Sphinx:
# https://github.com/sphinx-doc/sphinx/issues/777
cat >> doc/source/conf.py <<'EOF'
latex_elements = {
  'preamble': r'\usepackage{enumitem}\setlistdepth{99}',
}
EOF

# Remove shebangs from demos. The find-then-modify pattern keeps us from
# discarding mtimes on sources that do not need modification.
find demo -type f -exec \
    gawk '/^#!/ { print FILENAME }; { nextfile }' '{}' '+' |
  xargs -r -t sed -r -i '1{/^#!/d}'

%generate_buildrequires
%pyproject_buildrequires

%build
%pyproject_wheel

%if %{with doc_pdf}
PYTHONPATH="${PWD}/build/lib.%{python3_platform}-cpython-%{python3_version_nodots}" \
    %make_build -C doc latex SPHINXOPTS='%{?_smp_mflags}'
%make_build -C doc/build/latex LATEXMKOPTS='-quiet'
%endif

%install
%pyproject_install
%pyproject_save_files -l pyedflib

%check
%pytest
# Make sure we are still indicating the correct bundled edflib version:
grep -E "^#define[[:blank:]]+EDFLIB_VERSION[[:blank:]]+\($(
  echo '%{edflib_version}' | tr -d '.'
)\)[[:blank:]]*\$" 'pyedflib/_extensions/c/edflib.c'

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

%files doc
%license LICENSE
%if %{with doc_pdf}
%doc doc/build/latex/PyEDFlib.pdf
%endif
%doc demo

%changelog
## START: Generated by rpmautospec
* Wed Aug 07 2024 Packit <hello@packit.dev> - 0.1.38-1
- Update to 0.1.38 upstream release
- Resolves: rhbz#2303552

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

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

* Thu Mar 14 2024 Packit <hello@packit.dev> - 0.1.37-1
- [packit] 0.1.37 upstream release
- Resolves rhbz#2269549

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

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

* Thu Jan 04 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 0.1.36-4
- Assert a license file is automatically handled; don’t package a duplicate

* Fri Nov 10 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.1.36-3
- Patch for Cython 3

* Wed Oct 11 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.1.36-1
- Update to 0.1.36 (close RHBZ#2242645)

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

* Wed Sep 06 2023 Sandro <devel@penguinpee.nl> - 0.1.34-1
- Update to 0.1.34 (RHBZ#2224360)
- Use forge macros
- Drop patch in favor of direct sed edit
- Close RHBZ#2226291

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

* Wed Jun 28 2023 Python Maint <python-maint@redhat.com> - 0.1.33-2
- Rebuilt for Python 3.12

* Tue Jun 27 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 0.1.33-1
- Update to 0.1.33 (close RHBZ#2217530)
- Replace deprecated pyproject_build_lib macro
- Update License to SPDX

* Mon Apr 24 2023 Iztok Fister Jr. <iztokf AT fedoraproject DOT org> - 0.1.32-1
- Update to 0.1.32 (close RHBZ#2187954)

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

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

* Fri Jul 15 2022 Iztok Fister Jr. <iztokf AT fedoraproject DOT org> - 0.1.30-1
- Update to 0.1.30 (close RHBZ#2105939)

* Wed Jun 15 2022 Python Maint <python-maint@redhat.com> - 0.1.29-2
- Rebuilt for Python 3.11

* Mon Jun 13 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 0.1.29-1
- Update to 0.1.29 (close RHBZ#2092244)

* Tue Feb 22 2022 Iztok Fister Jr. <iztokf AT fedoraproject DOT org> - 0.1.28-1
- Update to the latest release

* Mon Jan 31 2022 Iztok Fister Jr. <iztokf AT fedoraproject DOT org> - 0.1.25-1
- Update to the latest release

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

## END: Generated by rpmautospec