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

# Break a circular dependency with sphinx-autodoc-typehints
%bcond bootstrap 0

# 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 a substitute.
%bcond doc 1

Name:           python-typeguard
Version:        4.1.5
Release:        %autorelease
Summary:        Run-time type checker for Python

# SPDX
License:        MIT
URL:            https://github.com/agronholm/typeguard
Source:         %{pypi_source typeguard}

BuildArch:      noarch

BuildRequires:  python3-devel
BuildRequires:  tomcli

%if %{with doc}
BuildRequires:  make
BuildRequires:  python3-sphinx-latex
BuildRequires:  latexmk
%endif

%global common_description %{expand:
This library provides run-time type checking for functions defined with PEP 484
argument (and return) type annotations.}

%description %{common_description}


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

%description -n python3-typeguard %{common_description}


%if %{with doc}
%package doc
Summary:        Documentation for typeguard

%description doc %{common_description}
%endif


%prep
%autosetup -n typeguard-%{version}

# Downstream-only: do not treat warnings in tests as errors
#
# This makes sense for upstream development and CI, but is too strict for
# distribution packaging.
tomcli set pyproject.toml lists delitem \
    'tool.pytest.ini_options.filterwarnings' error

%if %{with bootstrap}
tomcli set pyproject.toml lists delitem --type.regex \
    'project.optional-dependencies.doc' 'sphinx-autodoc-typehints\b.*'
sed -r -i 's/^([[:blank:]]*)(.(sphinx_autodoc_typehints))\b/\1# \2/' \
    docs/conf.py
%endif

# In docs/conf.py, packaging is used to access the version from the typeguard
# package distribution. This works for upstream, but it doesn’t work when we
# haven’t installed the package with proper dist-info metadata yet.
sed -r -i 's/get_version\("typeguard"\)/"%{version}"/' docs/conf.py

# Drop intersphinx mappings, since we can’t download remote inventories and
# can’t easily produce working hyperlinks from inventories in local
# documentation packages.
echo 'intersphinx_mapping.clear()' >> docs/conf.py

# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python/#_linters
tomcli set pyproject.toml lists delitem --type regex \
    'project.optional-dependencies.test' 'coverage\b.*'
# Note that we *do* need mypy for some of the tests; it is not just a
# “typechecking linter.”


%generate_buildrequires
export SETUPTOOLS_SCM_PRETEND_VERSION='%{version}'
%pyproject_buildrequires -x test%{?with_doc:,doc}


%build
export SETUPTOOLS_SCM_PRETEND_VERSION='%{version}'
%pyproject_wheel

%if %{with doc}
PYTHONPATH="${PWD}/src" sphinx-build -b latex -j%{?_smp_build_ncpus} \
    docs %{_vpath_builddir}/_latex
%make_build -C %{_vpath_builddir}/_latex LATEXMKOPTS='-quiet'
%endif


%install
export SETUPTOOLS_SCM_PRETEND_VERSION='%{version}'
%pyproject_install
%pyproject_save_files -l typeguard


%check
%pytest -v -rs


%files -n python3-typeguard -f %{pyproject_files}
%if %{without doc}
%doc README.rst
%endif


%if %{with doc}
%files doc
%license LICENSE
%doc README.rst
%doc %{_vpath_builddir}/_latex/typeguard.pdf
%endif


%changelog
## START: Generated by rpmautospec
* Fri Jan 26 2024 Fedora Release Engineering <releng@fedoraproject.org> - 4.1.5-6
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild

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

* Tue Dec 19 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 4.1.5-3
- Assert that %%pyproject_files contains a license file

* Thu Oct 26 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 4.1.5-2
- Do not treat warnings in tests as errors (fix RHBZ#2246127)

* Mon Sep 11 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 4.1.5-1
- Update to 4.1.5 (close RHBZ#2238247)

* Sun Aug 27 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 4.1.3-1
- Update to 4.1.3 (close RHBZ#2235133)

* Fri Aug 18 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 4.1.2-1
- Update to 4.1.2 (close RHBZ#2232695)

* Wed Aug 16 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 4.1.1-1
- Update to 4.1.1 (close RHBZ#2232257)

* Wed Aug 16 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 4.1.0-2
- Permit newer Sphinx versions (allow Sphinx 7)

* Sun Jul 30 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 4.1.0-1
- Update to 4.1.0 (close RHBZ#2160261)

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

* Wed Jul 12 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 4.0.0-6
- When PDF docs are disabled, omit the -doc subpackage

* Wed Jul 12 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 4.0.0-5
- Non-bootstrap build for Python 3.12

* Tue Jun 20 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 4.0.0-4
- Bootstrap for Python 3.12

* Tue Jun 20 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 4.0.0-3
- Add a bootstrap conditional

* Tue Jun 20 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 4.0.0-2
- Fixed deprecation warnings on Python 3.12

* Sun Jun 18 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 4.0.0-1
- Update to 4.0.0 (close RHBZ#2160261)

* Sun Jun 18 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 3.0.2-1
- Update to 3.0.2 (close RHBZ#2159587)

* Sun Jun 18 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.13.3-10
- Use new (rpm 4.17.1+) bcond style

* Sun May 07 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.13.3-8
- Fix package import error while building documentation

* Sat Mar 18 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 2.13.3-7
- Don’t assume %%_smp_mflags is -j%%_smp_build_ncpus

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

* Tue Aug 16 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 2.13.3-5
- Add -doc subpackage with Sphinx-generated PDF docs

* Tue Aug 16 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 2.13.3-4
- Port to pyproject-rpm-macros
- Clean up obsolete macros and stale dependencies/BR’s

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

* Mon Jun 13 2022 Python Maint <python-maint@redhat.com> - 2.13.3-2
- Rebuilt for Python 3.11

* Sat Jan 29 2022 Michel Alexandre Salim <salimma@fedoraproject.org> - 2.13.3-1
- Update to 2.13.3 (fixes: rhbz#2025745)

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

* Sun Nov 07 2021 Davide Cavalca <dcavalca@fedoraproject.org> - 2.13.0-1
- Update to 2.13.0; Fixes: RHBZ#2012648

* Tue Jun 08 2021 Davide Cavalca <dcavalca@fedoraproject.org> - 2.12.1-1
- Update to 2.12.1
- Gate out broken tests

* Fri Jun 04 2021 Python Maint <python-maint@redhat.com> - 2.10.0-4
- Rebuilt for Python 3.10

* Wed Jan 27 2021 Fedora Release Engineering <releng@fedoraproject.org> - 2.10.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild

* Thu Jan 14 2021 Michel Alexandre Salim <salimma@fedoraproject.org> - 2.10.0-2
- Fix egginfo on Fedora < 33 so the auto-generated Provides has the right version

* Mon Oct 26 2020 Christopher Brown <chris.brown@redhat.com> - 2.10.0-1
- Update to 2.10.0
- Remove conditional as python 3.9 now supported

* Mon Jul 6 2020 Christopher Brown <chris.brown@redhat.com> - 2.9.1-1
- Fix description
- Remove egg-info in prep
- Add conditional for python 3.9

* Wed May 27 2020 Christopher Brown <chris.brown@redhat.com> - 2.7.1-2
- Remove dep generator
- Simplify description
- Fix file glob

* Wed May 6 2020 Christopher Brown <chris.brown@redhat.com> - 2.7.1-1
- Initial package at 2.7.1

## END: Generated by rpmautospec