Blame SPECS/python3.11-cryptography.spec

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