Blame SPECS/python3.11-cryptography.spec

527d9a
%global __python3 /usr/bin/python3.11
527d9a
%global python3_pkgversion 3.11
527d9a
527d9a
# RHEL: Tests disabled due to missing deps
527d9a
%bcond_with tests
527d9a
527d9a
%global srcname cryptography
527d9a
527d9a
Name:           python%{python3_pkgversion}-%{srcname}
527d9a
Version:        37.0.2
527d9a
Release:        5%{?dist}
527d9a
Summary:        PyCA's cryptography library
527d9a
527d9a
# We bundle various crates with cryptography which is dual licensed
527d9a
# under the ASL 2.0 and BSD-3-Clause, as well as the Python license
527d9a
# for the OS random engine derived by CPython.
527d9a
527d9a
# Inflector: BSD
527d9a
# aliasable: MIT
527d9a
# asn1: BSD
527d9a
# asn1_derive: BSD
527d9a
# autocfg: MIT or ASL 2.0
527d9a
# base64: MIT or ASL 2.0
527d9a
# cfg-if: MIT or ASL 2.0
527d9a
# chrono: MIT or ASL 2.0
527d9a
# indoc: MIT or ASL 2.0
527d9a
# indoc-impl: MIT or ASL 2.0
527d9a
# instant: BSD
527d9a
# lazy_static: MIT or ASL 2.0
527d9a
# libc: MIT or ASL 2.0
527d9a
# lock_api: MIT or ASL 2.0
527d9a
# num-integer: MIT or ASL 2.0
527d9a
# num-traits: MIT or ASL 2.0
527d9a
# once_cell: MIT or ASL 2.0
527d9a
# ouroboros: MIT or ASL 2.0
527d9a
# ouroboros_macro: MIT or ASL 2.0
527d9a
# parking_lot: MIT or ASL 2.0
527d9a
# parking_lot_core: MIT or ASL 2.0
527d9a
# paste: MIT or ASL 2.0
527d9a
# paste-impl: MIT or ASL 2.0
527d9a
# pem: MIT
527d9a
# proc-macro-error: MIT or ASL 2.0
527d9a
# proc-macro-error-attr: MIT or ASL 2.0
527d9a
# proc-macro-hack: MIT or ASL 2.0
527d9a
# proc-macro2: MIT or ASL 2.0
527d9a
# pyo3: ASL 2.0
527d9a
# pyo3-build-config: ASL 2.0
527d9a
# pyo3-macros: ASL 2.0
527d9a
# pyo3-macros-backend: ASL 2.0
527d9a
# quote: MIT or ASL 2.0
527d9a
# scopeguard: MIT or ASL 2.0
527d9a
# smallvec: MIT or ASL 2.0
527d9a
# stable_deref_trait: MIT or ASL 2.0
527d9a
# syn: MIT or ASL 2.0
527d9a
# unicode-xid: MIT or ASL 2.0
527d9a
# unindent: MIT or ASL 2.0
527d9a
# version_check: MIT or ASL 2.0
527d9a
527d9a
License:        (ASL 2.0 or BSD) and Python and BSD and MIT and (MIT or ASL 2.0) and ASL 2.0
527d9a
URL:            https://cryptography.io/en/latest/
527d9a
Source0:        https://github.com/pyca/cryptography/archive/%{version}/%{srcname}-%{version}.tar.gz
527d9a
                # created by ./vendor_rust.py helper script
527d9a
Source1:        cryptography-%{version}-vendor.tar.bz2
527d9a
Source2:        conftest-skipper.py
527d9a
527d9a
# Security fix for CVE-2023-23931: memory corruption via immutable objects
527d9a
# Bugzilla tracker: https://bugzilla.redhat.com/show_bug.cgi?id=2171817
527d9a
# Resolved upstream: https://github.com/pyca/cryptography/commit/94a50a9731f35405f0357fa5f3b177d46a726ab3
527d9a
Patch0:         CVE-2023-23931.patch
527d9a
527d9a
ExclusiveArch:  %{rust_arches}
527d9a
527d9a
BuildRequires:  openssl-devel
527d9a
BuildRequires:  gcc
527d9a
BuildRequires:  gnupg2
527d9a
%if 0%{?fedora}
527d9a
BuildRequires:  rust-packaging
527d9a
%else
527d9a
BuildRequires:  rust-toolset
527d9a
%endif
527d9a
527d9a
BuildRequires:  python%{python3_pkgversion}-cffi >= 1.7
527d9a
BuildRequires:  python%{python3_pkgversion}-devel
527d9a
BuildRequires:  python%{python3_pkgversion}-rpm-macros
527d9a
BuildRequires:  python%{python3_pkgversion}-setuptools
527d9a
BuildRequires:  python%{python3_pkgversion}-setuptools-rust >= 0.11.3
527d9a
# Cargo.toml requires asn1 0.6, but package FTBFS with 0.6.1
527d9a
#BuildRequires:  rust-asn1-devel >= 0.6.4
527d9a
527d9a
%if %{with tests}
527d9a
%if 0%{?fedora}
527d9a
BuildRequires:  python%{python3_pkgversion}-hypothesis >= 1.11.4
527d9a
BuildRequires:  python%{python3_pkgversion}-iso8601
527d9a
BuildRequires:  python%{python3_pkgversion}-pretend
527d9a
BuildRequires:  python%{python3_pkgversion}-pytest-xdist
527d9a
%endif
527d9a
BuildRequires:  python%{python3_pkgversion}-pytest >= 6.0
527d9a
BuildRequires:  python%{python3_pkgversion}-pytest-benchmark
527d9a
BuildRequires:  python%{python3_pkgversion}-pytest-subtests >= 0.3.2
527d9a
BuildRequires:  python%{python3_pkgversion}-pytz
527d9a
%endif
527d9a
527d9a
Requires:       openssl-libs
527d9a
Requires:       python%{python3_pkgversion}-cffi >= 1.7
527d9a
527d9a
# Provides for the bundled crates
527d9a
527d9a
Provides: bundled(crate(Inflector)) = 0.11.4
527d9a
Provides: bundled(crate(aliasable)) = 0.1.3
527d9a
Provides: bundled(crate(asn1)) = 0.8.7
527d9a
Provides: bundled(crate(asn1_derive)) = 0.8.7
527d9a
Provides: bundled(crate(autocfg)) = 1.1.0
527d9a
Provides: bundled(crate(base64)) = 0.13.0
527d9a
Provides: bundled(crate(cfg-if)) = 1.0.0
527d9a
Provides: bundled(crate(chrono)) = 0.4.19
527d9a
Provides: bundled(crate(indoc)) = 0.3.6
527d9a
Provides: bundled(crate(indoc-impl)) = 0.3.6
527d9a
Provides: bundled(crate(instant)) = 0.1.12
527d9a
Provides: bundled(crate(lazy_static)) = 1.4.0
527d9a
Provides: bundled(crate(libc)) = 0.2.124
527d9a
Provides: bundled(crate(lock_api)) = 0.4.7
527d9a
Provides: bundled(crate(num-integer)) = 0.1.44
527d9a
Provides: bundled(crate(num-traits)) = 0.2.14
527d9a
Provides: bundled(crate(once_cell)) = 1.10.0
527d9a
Provides: bundled(crate(ouroboros)) = 0.15.0
527d9a
Provides: bundled(crate(ouroboros_macro)) = 0.15.0
527d9a
Provides: bundled(crate(parking_lot)) = 0.11.2
527d9a
Provides: bundled(crate(parking_lot_core)) = 0.8.5
527d9a
Provides: bundled(crate(paste)) = 0.1.18
527d9a
Provides: bundled(crate(paste-impl)) = 0.1.18
527d9a
Provides: bundled(crate(pem)) = 1.0.2
527d9a
Provides: bundled(crate(proc-macro-error)) = 1.0.4
527d9a
Provides: bundled(crate(proc-macro-error-attr)) = 1.0.4
527d9a
Provides: bundled(crate(proc-macro-hack)) = 0.5.19
527d9a
Provides: bundled(crate(proc-macro2)) = 1.0.37
527d9a
Provides: bundled(crate(pyo3)) = 0.15.2
527d9a
Provides: bundled(crate(pyo3-build-config)) = 0.15.2
527d9a
Provides: bundled(crate(pyo3-macros)) = 0.15.2
527d9a
Provides: bundled(crate(pyo3-macros-backend)) = 0.15.2
527d9a
Provides: bundled(crate(quote)) = 1.0.18
527d9a
Provides: bundled(crate(scopeguard)) = 1.1.0
527d9a
Provides: bundled(crate(smallvec)) = 1.8.0
527d9a
Provides: bundled(crate(stable_deref_trait)) = 1.2.0
527d9a
Provides: bundled(crate(syn)) = 1.0.91
527d9a
Provides: bundled(crate(unicode-xid)) = 0.2.2
527d9a
Provides: bundled(crate(unindent)) = 0.1.8
527d9a
Provides: bundled(crate(version_check)) = 0.9.4
527d9a
527d9a
# Cryptography crate
527d9a
Provides: crate(cryptography-rust) = 0.1.0
527d9a
527d9a
%description
527d9a
cryptography is a package designed to expose cryptographic primitives and
527d9a
recipes to Python developers.
527d9a
527d9a
%prep
527d9a
%autosetup -p1 -n %{srcname}-%{version}
527d9a
527d9a
527d9a
%if 0%{?fedora}
527d9a
# Fedora: use cargo macros to make use of RPMified crates
527d9a
%cargo_prep
527d9a
cd src/rust
527d9a
rm -f Cargo.lock
527d9a
%cargo_generate_buildrequires
527d9a
cd ../..
527d9a
%else
527d9a
# RHEL: use vendored Rust crates
527d9a
%cargo_prep -V 1
527d9a
%endif
527d9a
527d9a
%build
527d9a
export RUSTFLAGS="%__global_rustflags"
527d9a
%py3_build
527d9a
527d9a
%install
527d9a
# Actually other *.c and *.h are appropriate
527d9a
# see https://github.com/pyca/cryptography/issues/1463
527d9a
find . -name .keep -print -delete
527d9a
%py3_install
527d9a
527d9a
%check
527d9a
%if %{with tests}
527d9a
%if 0%{?rhel}
527d9a
# skip hypothesis tests on RHEL
527d9a
rm -rf tests/hypothesis
527d9a
# append skipper to skip iso8601 and pretend tests
527d9a
cat < %{SOURCE2} >> tests/conftest.py
527d9a
%endif
527d9a
527d9a
%if 0%{?eln}
527d9a
# enable SHA-1 signatures for RSA tests
527d9a
# also see https://github.com/pyca/cryptography/pull/6931 and rhbz#2060343
527d9a
export OPENSSL_ENABLE_SHA1_SIGNATURES=yes
527d9a
%endif
527d9a
527d9a
# see https://github.com/pyca/cryptography/issues/4885 and
527d9a
# see https://bugzilla.redhat.com/show_bug.cgi?id=1761194 for deselected tests
527d9a
# see rhbz#2042413 for memleak. It's unstable under Python 3.11 and makes
527d9a
# not much sense for downstream testing.
527d9a
PYTHONPATH=${PWD}/vectors:%{buildroot}%{python3_sitearch} \
527d9a
    %{__python3} -m pytest \
527d9a
    -k "not (test_buffer_protocol_alternate_modes or test_dh_parameters_supported or test_load_ecdsa_no_named_curve or test_openssl_memleak)"
527d9a
%endif
527d9a
527d9a
%files -n python%{python3_pkgversion}-%{srcname}
527d9a
%doc README.rst docs
527d9a
%license LICENSE LICENSE.APACHE LICENSE.BSD
527d9a
%{python3_sitearch}/%{srcname}
527d9a
%{python3_sitearch}/%{srcname}-%{version}-py*.egg-info
527d9a
527d9a
%changelog
527d9a
* Thu Feb 23 2023 Charalampos Stratakis <cstratak@redhat.com> - 37.0.2-5
527d9a
- Bump release for rebuild
527d9a
527d9a
* Mon Feb 20 2023 Charalampos Stratakis <cstratak@redhat.com> - 37.0.2-4
527d9a
- Security fix for CVE-2023-23931
527d9a
527d9a
* Tue Feb 14 2023 Charalampos Stratakis <cstratak@redhat.com> - 37.0.2-3
527d9a
- Rebuild for gating
527d9a
527d9a
* Mon Feb 13 2023 Charalampos Stratakis <cstratak@redhat.com> - 37.0.2-2
527d9a
- Add explicit dependency on python3.11-rpm-macros
527d9a
527d9a
* Thu Dec 01 2022 Charalampos Stratakis <cstratak@redhat.com> - 37.0.2-1
527d9a
- Initial package
527d9a
- Fedora contributions by:
527d9a
      Alfredo Moralejo <amoralej@redhat.com>
527d9a
      Charalampos Stratakis <cstratak@redhat.com>
527d9a
      Christian Heimes <christian@python.org>
527d9a
      Colin Walters <walters@verbum.org>
527d9a
      Dennis Gilmore <dennis@ausil.us>
527d9a
      Fabio Valentini <decathorpe@gmail.com>
527d9a
      Felix Schwarz <felix.schwarz@oss.schwarz.eu>
527d9a
      Haikel Guemar <hguemar@fedoraproject.org>
527d9a
      Igor Gnatenko <ignatenkobrain@fedoraproject.org>
527d9a
      Iryna Shcherbina <shcherbina.iryna@gmail.com>
527d9a
      Lumir Balhar <lbalhar@redhat.com>
527d9a
      Matěj Cepl <mcepl@cepl.eu>
527d9a
      Miro Hrončok <miro@hroncok.cz>
527d9a
      Nathaniel McCallum <npmccallum@redhat.com>
527d9a
      Randy Barlow <randy@electronsweatshop.com>
527d9a
      Robert Kuska <rkuska@redhat.com>
527d9a
      Sahana Prasad <sahana@redhat.com>
527d9a
      Stephen Gallagher <sgallagh@redhat.com>
527d9a
      Troy Dawson <tdawson@redhat.com>