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

%global         srcname     pem
%global         forgeurl    https://github.com/hynek/pem
Version:        21.2.0
%global         tag         %{version}
%forgemeta

Name:           python-%{srcname}
Release:        %autorelease
Summary:        Easy PEM file parsing

License:        Apache-2.0
URL:            %forgeurl
Source0:        %forgesource
# Docs use the 'furo' theme, but that isn't packaged for Fedora yet. Switch to
# the already packaged sphinx-rtd-theme instead.
Patch0:         python-pem-doc-theme-fix.patch

BuildArch:      noarch

BuildRequires:  python3-devel
BuildRequires:  pyproject-rpm-macros

%if %{with tests}
BuildRequires:  python3dist(certifi)
BuildRequires:  python3dist(cryptography)
BuildRequires:  python3dist(pretend)
BuildRequires:  python3dist(pytest)
BuildRequires:  python3dist(service-identity)
%endif


%global _description %{expand:
pem is an MIT-licensed Python module for parsing and splitting of PEM files,
i.e. Base64-encoded DER keys and certificates.}

%description %{_description}


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

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

%package -n python3-%{srcname}-doc
Requires:       python3-docs
BuildRequires:  python3-docs
BuildRequires:  python3-pyOpenSSL
BuildRequires:  python3dist(sphinx)
BuildRequires:  python3dist(sphinx-rtd-theme)
BuildRequires:  python3dist(twisted)
Summary:        Documentation for python-%{srcname}

%description -n python3-%{srcname}-doc
Documentation for python-%{srcname}


%prep
%forgesetup
%patch0 -p0

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


%generate_buildrequires
%pyproject_buildrequires -r


%build
%pyproject_wheel


%install
%pyproject_install
%pyproject_save_files pem

# Generate documentation.
PYTHONPATH="%{buildroot}%{python3_sitelib}:${PWD}/docs/" sphinx-build docs html
rm -rf html/.{doctrees,buildinfo}


%if %{with tests}
%check
%pytest
%endif


%files -n python3-%{srcname} -f %{pyproject_files}
%license LICENSE
%doc README.rst CHANGELOG.rst


%files -n python3-%{srcname}-doc
%license LICENSE
%doc README.rst CHANGELOG.rst html


%changelog
* Wed Feb 22 2023 Major Hayden <major@redhat.com> - 21.2.0-7
- Set SPDX license

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

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

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

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

* Thu Sep 09 2021 Major Hayden <major@mhtx.net> - 21.2.0-2
- Move to rpmautospec

* Tue Aug 24 2021 Major Hayden <major@mhtx.net> - 21.2.0-1
- Initial import (#1996868)