6efddd9
# Sphinx-generated HTML documentation is not suitable for packaging; see
6efddd9
# https://bugzilla.redhat.com/show_bug.cgi?id=2006555 for discussion.
6efddd9
#
04bbd44
# We can generate PDF documentation as a substitute.
6efddd9
%bcond_without doc_pdf
6efddd9
2737cab
Name:           python-jose
d86c4ed
Version:        3.3.0
5ac13d4
Release:        %autorelease
c3f9c4b
Summary:        A JOSE implementation in Python
Chenxiong Qi 14b559e
29dbdd3
# SPDX
Chenxiong Qi 14b559e
License:        MIT
5b4a5f5
URL:            https://github.com/mpdavis/python-jose
5b4a5f5
Source0:        %{pypi_source python-jose}
Chenxiong Qi 14b559e
BuildArch:      noarch
Chenxiong Qi 14b559e
Chenxiong Qi 14b559e
BuildRequires:  python3-devel
9820568
1c120ee
# From setup_requires:
Chenxiong Qi 14b559e
BuildRequires:  python3dist(pytest-runner)
Chenxiong Qi 14b559e
6d10f2c
# Documentation
6efddd9
%if %{with doc_pdf}
6d10f2c
BuildRequires:  make
6d10f2c
# From requirements-rtd.txt:
6d10f2c
# sphinxcontrib-napoleon==0.3.4; but napoleon is now part of Sphinx proper
6d10f2c
BuildRequires:  python3dist(sphinx)
6efddd9
BuildRequires:  python3-sphinx-latex
6efddd9
BuildRequires:  latexmk
6efddd9
BuildRequires:  tex-xetex-bin
6efddd9
%endif
6d10f2c
e29c826
# Upstream recommends the cryptography backend. We add it as a soft dependency
e29c826
# so that anyone who does not go out of their way to select a different backend
e29c826
# gets the best experience.
e29c826
Recommends:     python3dist(python-jose[cryptography])
e29c826
c3f9c4b
%global common_description %{expand:
Chenxiong Qi 14b559e
The JavaScript Object Signing and Encryption (JOSE) technologies - JSON Web
Chenxiong Qi 14b559e
Signature (JWS), JSON Web Encryption (JWE), JSON Web Key (JWK), and JSON Web
Chenxiong Qi 14b559e
Algorithms (JWA) - collectively can be used to encrypt and/or sign content
Chenxiong Qi 14b559e
using a variety of algorithms. While the full set of permutations is extremely
Chenxiong Qi 14b559e
large, and might be daunting to some, it is expected that most applications
Chenxiong Qi 14b559e
will only use a small set of algorithms to meet their needs.
Chenxiong Qi 14b559e
d86c4ed
As of 3.3.0, python-jose implements three different cryptographic backends. The
c3f9c4b
backend must be selected as an extra when installing python-jose. If you do not
c3f9c4b
select a backend, the native-python backend will be installed.
c3f9c4b
c3f9c4b
Unless otherwise noted, all backends support all operations.
c3f9c4b
c3f9c4b
Due to complexities with setuptools, the native-python backend is always
c3f9c4b
installed, even if you select a different backend on install.
c3f9c4b
c3f9c4b
  1. cryptography
c3f9c4b
       * This backend uses pyca/cryptography for all cryptographic operations.
1deedd6
         This is the recommended backend and is selected over all other
1deedd6
         backends if any others are present.
c3f9c4b
       * Installation: dnf install python3-jose+cryptography
c3f9c4b
       * Unused dependencies:
c3f9c4b
           - rsa
c3f9c4b
           - ecdsa
c3f9c4b
           - pyasn1
c3f9c4b
c3f9c4b
  2. pycryptodome
c3f9c4b
       * This backend uses pycryptodome for all cryptographic operations.
f92b7b8
       * Installation: not available because pycryptodome (which, unlike
f92b7b8
                       pycryptodomex, conflicts with pycrypto) is not packaged
c3f9c4b
       * Unused dependencies:
c3f9c4b
           - rsa
c3f9c4b
c3f9c4b
  3. native-python
c3f9c4b
       * This backend uses python-rsa and python-ecdsa for all cryptographic
c3f9c4b
         operations. This backend is always installed but any other backend
c3f9c4b
         will take precedence if one is installed.
c3f9c4b
       * Installation: dnf install python3-jose
c3f9c4b
c3f9c4b
     Note
c3f9c4b
d86c4ed
     The native-python backend cannot process certificates.}
c3f9c4b
c3f9c4b
%description %{common_description}
Chenxiong Qi 14b559e
061d513
2737cab
%package -n     python3-jose
c3f9c4b
Summary:        %{summary}
1deedd6
2737cab
%description -n python3-jose %{common_description}
Chenxiong Qi 14b559e
061d513
88f77f6
# Fedora packages pycryptodomex, but not pycryptodome (which conflicts with
88f77f6
# pycrypto). Upstream refuses to switch to pycryptodomex for the pycryptodome
88f77f6
# backend (https://github.com/mpdavis/python-jose/issues/26), so we disable the
88f77f6
# corresponding extra because it will fail to install.
88f77f6
%pyproject_extras_subpkg -n python3-jose cryptography
88f77f6
88f77f6
6d10f2c
%package doc
5b4a5f5
Summary:        Documentation for python-jose
6d10f2c
6d10f2c
%description doc %{common_description}
6d10f2c
6d10f2c
Chenxiong Qi 14b559e
%prep
aabf999
%autosetup -p1
f473b54
f92b7b8
# Patch out pycryptodome backend extra and tests where required; see note near
f92b7b8
# the BR’s
f92b7b8
sed -r -i '/^[[:blank:]]*pycryptodome/d' tox.ini requirements.txt
Chenxiong Qi 14b559e
6d10f2c
# The napoleon extension is now part of Sphinx proper:
6d10f2c
sed -r -i 's/(sphinx)contrib(\.napoleon)/\1.ext\2/g' docs/conf.py
6d10f2c
fb2c145
# Patch out unnecessary coverage dependencies:
fb2c145
sed -r -i '/pytest-cov/d' tox.ini
fb2c145
1deedd6
a70f354
%generate_buildrequires
a70f354
%pyproject_buildrequires -t -x cryptography
a70f354
a70f354
Chenxiong Qi 14b559e
%build
f92b7b8
%pyproject_wheel
fe57a10
6efddd9
%if %{with doc_pdf}
6efddd9
%make_build -C docs latex SPHINXOPTS='%{?_smp_mflags}'
04bbd44
%make_build -C docs/_build/latex LATEXMKOPTS='-quiet'
6efddd9
%endif
Chenxiong Qi 14b559e
1deedd6
Chenxiong Qi 14b559e
%install
f92b7b8
%pyproject_install
2737cab
%pyproject_save_files jose
Chenxiong Qi 14b559e
1deedd6
Chenxiong Qi 14b559e
%check
aadd790
echo '>>> Backend: native-python <<<' 1>&2
d86c4ed
m='not (cryptography or pycryptodome or backend_compatibility)'
aadd790
%{pytest} -k "${k}" -m "${m}" tests
Chenxiong Qi 14b559e
aadd790
echo '>>> Backend: cryptography <<<' 1>&2
d86c4ed
m='not (pycryptodome or backend_compatibility)'
aadd790
%{pytest} -k "${k}" -m "${m}" tests
Chenxiong Qi 14b559e
aadd790
echo '>>> Cross-backend compatibility and coexistence <<<' 1>&2
aadd790
%{pytest} -k "${k}" tests
Chenxiong Qi 14b559e
1deedd6
2737cab
%files -n python3-jose -f %{pyproject_files}
Chenxiong Qi 14b559e
%doc README.rst
Chenxiong Qi 14b559e
1deedd6
6d10f2c
%files doc
6d10f2c
%license LICENSE
6efddd9
%if %{with doc_pdf}
6efddd9
%doc docs/_build/latex/python-jose.pdf
6efddd9
%endif
6d10f2c
6d10f2c
Chenxiong Qi 14b559e
%changelog
5ac13d4
%autochangelog