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

Name:           python-jose
Version:        3.3.0
Release:        %autorelease
Summary:        A JOSE implementation in Python

# SPDX
License:        MIT
URL:            https://github.com/mpdavis/python-jose
Source:         %{pypi_source python-jose}

BuildArch:      noarch

BuildRequires:  python3-devel

# From setup_requires:
BuildRequires:  python3dist(pytest-runner)

%if %{with doc}
BuildRequires:  make
# From requirements-rtd.txt:
# sphinxcontrib-napoleon==0.3.4; but napoleon is now part of Sphinx proper
BuildRequires:  python3dist(sphinx)
BuildRequires:  python3-sphinx-latex
BuildRequires:  latexmk
BuildRequires:  tex-xetex-bin
%endif

# Upstream recommends the cryptography backend. We add it as a soft dependency
# so that anyone who does not go out of their way to select a different backend
# gets the best experience.
Recommends:     python3dist(python-jose[cryptography])

%global common_description %{expand:
The JavaScript Object Signing and Encryption (JOSE) technologies - JSON Web
Signature (JWS), JSON Web Encryption (JWE), JSON Web Key (JWK), and JSON Web
Algorithms (JWA) - collectively can be used to encrypt and/or sign content
using a variety of algorithms. While the full set of permutations is extremely
large, and might be daunting to some, it is expected that most applications
will only use a small set of algorithms to meet their needs.

As of 3.3.0, python-jose implements three different cryptographic backends. The
backend must be selected as an extra when installing python-jose. If you do not
select a backend, the native-python backend will be installed.

Unless otherwise noted, all backends support all operations.

Due to complexities with setuptools, the native-python backend is always
installed, even if you select a different backend on install.

  1. cryptography
       * This backend uses pyca/cryptography for all cryptographic operations.
         This is the recommended backend and is selected over all other
         backends if any others are present.
       * Installation: dnf install python3-jose+cryptography
       * Unused dependencies:
           - rsa
           - ecdsa
           - pyasn1

  2. pycryptodome
       * This backend uses pycryptodome for all cryptographic operations.
       * Installation: not available because pycryptodome (which, unlike
                       pycryptodomex, conflicts with pycrypto) is not packaged
       * Unused dependencies:
           - rsa

  3. native-python
       * This backend uses python-rsa and python-ecdsa for all cryptographic
         operations. This backend is always installed but any other backend
         will take precedence if one is installed.
       * Installation: dnf install python3-jose

     Note

     The native-python backend cannot process certificates.}

%description %{common_description}


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

%description -n python3-jose %{common_description}


# Fedora packages pycryptodomex, but not pycryptodome (which conflicts with
# pycrypto). Upstream refuses to switch to pycryptodomex for the pycryptodome
# backend (https://github.com/mpdavis/python-jose/issues/26), so we disable the
# corresponding extra because it will fail to install.
%pyproject_extras_subpkg -n python3-jose cryptography


%if %{with doc}
%package doc
Summary:        Documentation for python-jose

%description doc %{common_description}
%endif


%prep
%autosetup -p1

# Patch out pycryptodome backend extra and tests where required; see note near
# the BR’s
sed -r -i '/^[[:blank:]]*pycryptodome/d' tox.ini requirements.txt

# The napoleon extension is now part of Sphinx proper:
sed -r -i 's/(sphinx)contrib(\.napoleon)/\1.ext\2/g' docs/conf.py

# Patch out unnecessary coverage dependencies:
sed -r -i '/pytest-cov/d' tox.ini


%generate_buildrequires
%pyproject_buildrequires -t -x cryptography


%build
%pyproject_wheel

%if %{with doc}
%make_build -C docs latex SPHINXOPTS='-j%{?_smp_build_ncpus}'
%make_build -C docs/_build/latex LATEXMKOPTS='-quiet'
%endif


%install
%pyproject_install
%pyproject_save_files -l jose


%check
echo '>>> Backend: native-python <<<' 1>&2
m='not (cryptography or pycryptodome or backend_compatibility)'
%{pytest} -k "${k}" -m "${m}" tests

echo '>>> Backend: cryptography <<<' 1>&2
m='not (pycryptodome or backend_compatibility)'
%{pytest} -k "${k}" -m "${m}" tests

echo '>>> Cross-backend compatibility and coexistence <<<' 1>&2
%{pytest} -k "${k}" tests


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


%if %{with doc}
%files doc
%license LICENSE
%doc README.rst
%doc docs/_build/latex/python-jose.pdf
%endif


%changelog
## START: Generated by rpmautospec
* Sat Mar 30 2024 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-29
- Add missing README.md in -doc subpackage

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

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

* Mon Dec 18 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-25
- Assert that %%pyproject_files contains a license file

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

* Tue Jul 11 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-23
- When PDF docs are disabled, omit the -doc subpackage

* Fri Jul 07 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-22
- Use new (rpm 4.17.1+) bcond style

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

* Fri Mar 17 2023 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-19
- Don’t assume %%_smp_mflags is -j%%_smp_build_ncpus

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

* Wed Dec 21 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-17
- F38+: drop conditionals for F37 and older

* Sat Oct 22 2022 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-16
- Confirm License is SPDX MIT

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

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

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

* Fri Dec 17 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-12
- Drop unnecessary pytest-cov dependency

* Sat Nov 27 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-11
- Reduce LaTeX PDF build verbosity

* Thu Sep 30 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-10
- Generate PDF instead of HTML Sphinx documentation.

* Mon Sep 13 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-9
- Let pyproject-rpm-macros handle the license file

* Sun Sep 12 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-8
- Reduce macro indirection in the spec file

* Sun Sep 12 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-7
- Drop BR on pyproject-rpm-macros, now implied by python3-devel

* Sun Sep 12 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-6
- Reduce spec file macro indirection

* Tue Jul 27 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-5
- Move %%generate_buildrequires after %%prep to make the spec file easier
  to follow

* Fri Jul 23 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.0-4
- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild

* Wed Jul 21 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-3
- Drop unused _summary macro

* Sun Jun 06 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 3.3.0-1
- Update to 3.3.0 (fixes RHBZ#1968095)
- Drop python-jose-3.2.0-pr-199.patch (backported ecdsa 0.16 support), now
  merged upstream
- Upstream dropped pycypto backend; we drop the corresponding extra
- Remove a comment referring to Fedora 32 since it is EOL
- Stop removing egg-info/dist-info (not needed with pyproject-rpm-macros

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

* Sat Apr 10 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 3.2.0-6
- Drop Fedora 32 workarounds
- Fix some remaining conditionals

* Tue Mar 16 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 3.2.0-5
- Drop python3dist(setuptools) BR, redundant with %%pyproject_buildrequires

* Fri Mar 05 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 3.2.0-4
- Backport unreleased ecdsa 0.16 support from upstream. Fixes
  TestECAlgorithm.test_key_too_short test.

* Sat Feb 27 2021 Benjamin A. Beasley <code@musicinmybrain.net> - 3.2.0-3
- Change “test_key_too_short” skip from patch to pytest option
- Simplify use of name macros
- Switch URL to HTTPS
- Improved summaries and descriptions
- After verifying no dependent packages use them, replace the ad-hoc backend
  metapackages with standard extras metapackages
- Drop obsolete python_provide macro
- Use %%pytest macro and print a message for each backend-specific test
  invocation
- Whitespace changes
- Remove explicit/manual Requires from main package
- Use pyproject-rpm-macros, including generated BR’s
- Fedora packages pycryptodomex, but not pycryptodome (which conflicts with
  pycrypto). Upstream refuses to switch to pycryptodomex for the pycryptodome
  backend (https://github.com/mpdavis/python-jose/issues/26), so we disable the
  corresponding extra because it will fail to install.
- Add a soft dependency on the cryptography backend extra
- Build the HTML documentation in a new -doc subpackage

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

* Mon Oct  5 23:59:32 -03 2020 Itamar Reis Peixoto <itamar@ispbrasil.com.br> - 3.2.0-1
- 3.2.0

* Wed Jul 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.1.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild

* Sun May 17 2020 Chenxiong Qi <qcxhome@gmail.com> - 3.1.0-1
- Initial package.

## END: Generated by rpmautospec