## START: Set by rpmautospec
## (rpmautospec version 0.6.0)
## RPMAUTOSPEC: autorelease, autochangelog
%define autorelease(e:s:pb:n) %{?-p:0.}%{lua:
    release_number = 3;
    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 srcname pypdf
%global forgeurl https://github.com/py-pdf/pypdf

Name:           python-%{srcname}
Version:        4.2.0
Release:        %autorelease
Summary:        Pure-Python PDF library

License:        BSD-3-Clause
URL:            https://pypdf.readthedocs.io
# PyPI tarball doesn't include tests
Source:         %{forgeurl}/archive/%{version}/%{srcname}-%{version}.tar.gz

BuildArch:      noarch
BuildRequires:  python3-devel
BuildRequires:  python3-docs
BuildRequires:  sed

%global _description %{expand:
pypdf is a free and open-source pure-python PDF library capable of splitting,
merging, cropping, and transforming the pages of PDF files. It can also add
custom data, viewing options, and passwords to PDF files. pypdf can retrieve
text and metadata from PDFs as well.}

%description %_description

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

%description -n python3-pypdf %_description

%pyproject_extras_subpkg -n python3-pypdf crypto,full,image

%package        doc
Summary:        Documentation for %{name}
Requires:       python3-docs

%description    doc
This package provides additional documentation for %{name}.

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

# Fix test dependencies
sed -i tox.ini \
  -e 's/pycryptodome/pycryptodomex/' \
  -e '/pytest-socket/d'

# Use local intersphinx inventory
sed -r \
    -e 's|https://docs.python.org/\{python_version\}|%{_docdir}/python3-docs/html|' \
    -i docs/conf.py

%generate_buildrequires
%pyproject_buildrequires -t -x crypto,docs,full,image

%build
%pyproject_wheel

# Build docs
sphinx-build-3 docs html
rm -rf html/{.buildinfo,.doctrees}

%install
%pyproject_install
%pyproject_save_files %{srcname}

%check
%tox

%files -n python3-%{srcname} -f %{pyproject_files}
# https://lists.fedoraproject.org/archives/list/python-devel@lists.fedoraproject.org/thread/4Y2VRLVAR3DJXBSFVDYJMU3G4ZNPGEU6/
%license LICENSE
%doc README.md CHANGELOG.md CONTRIBUTORS.md

%files doc
%license LICENSE
%doc html

%changelog
## START: Generated by rpmautospec
* Fri Jul 19 2024 Fedora Release Engineering <releng@fedoraproject.org> - 4.2.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild

* Sun Jun 09 2024 Python Maint <python-maint@redhat.com> - 4.2.0-2
- Rebuilt for Python 3.13

* Tue Jun 04 2024 Davide Cavalca <dcavalca@fedoraproject.org> - 4.2.0-1
- Initial import; Fixes: RHBZ#2279080
## END: Generated by rpmautospec