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

Name:           python-%{pypi_name}
Version:        2.6.0
Release:        %autorelease
Summary:        Simple ASN.1 encoder and decoder for Python

License:        MIT
URL:            https://github.com/andrivet/python-asn1
Source:         %{pypi_source}

BuildArch:      noarch
BuildRequires:  python3-devel
BuildRequires:  sed

BuildRequires:  python3dist(pytest)
BuildRequires:  python3dist(sphinx)
BuildRequires:  python3dist(sphinx-rtd-theme)

%global _description %{expand:
Python-ASN1 is a simple ASN.1 encoder and decoder for Python with support for
BER (parser) and DER (parser and generator) encoding (except indefinite
lengths).}

%description %_description

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

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

%package        doc
Summary:        Documentation for %{name}

%description    doc
This package contains additional documentation and examples for %{name}.

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

# Drop unnecessary dependency
sed -i '/enum-compat/d' requirements.txt
sed -i 's/install_requires = .*/install_requires = []/' setup.py

# Fix permissions
chmod -x examples/dump.py

%generate_buildrequires
%pyproject_buildrequires

%build
%pyproject_wheel

# generate html docs
PYTHONPATH="${PWD}" sphinx-build-3 docs html
rm -r html/.{doctrees,buildinfo}

%install
%pyproject_install
%pyproject_save_files %{pypi_name}

%check
%pytest tests

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

%files doc
%license LICENSE
%doc examples html

%changelog
* Fri Jul 21 2023 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild

* Thu Jun 15 2023 Python Maint <python-maint@redhat.com> - 2.6.0-3
- Rebuilt for Python 3.12

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

* Tue Aug 30 2022 Davide Cavalca <dcavalca@fedoraproject.org> - 2.6.0-1
- Initial import; Fixes: RHBZ#2121982