Compare commits

...
Sign in to create a new pull request.

1 commit

Author SHA1 Message Date
Christian Heimes
73f0b3216f Skip unit tests that fail with OpenSSL 1.1.1.d
Fix and simplify Python 3 packaging

Resolves: rhbz#1761194
2019-10-13 16:51:02 +02:00

View file

@ -1,8 +1,15 @@
%if 0%{?fedora} || 0%{?rhel} >= 8
%global with_python3 1
%if 0%{?fedora} || 0%{?rhel} > 7
# Enable python3 build by default
%bcond_without python3
%else
%{!?__python2: %global __python2 /usr/bin/python2}
%{!?python2_sitearch: %global python2_sitearch %(%{__python2} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%bcond_with python3
%endif
%if 0%{?fedora} > 31 || 0%{?rhel} > 7
# Disable python2 build by default
%bcond_with python2
%else
%bcond_without python2
%endif
%{!?python3_pkgversion:%global python3_pkgversion 3}
@ -11,7 +18,7 @@
Name: python-%{srcname}
Version: 2.6.1
Release: 2%{?dist}
Release: 3%{?dist}
Summary: PyCA's cryptography library
License: ASL 2.0 or BSD
@ -21,6 +28,7 @@ Source0: https://pypi.io/packages/source/c/%{srcname}/%{srcname}-%{versio
BuildRequires: openssl-devel
BuildRequires: gcc
%if 0%{?with_python2}
BuildRequires: python2-devel
BuildRequires: python2-pytest >= 3.2.1
BuildRequires: python2-setuptools
@ -36,6 +44,7 @@ BuildRequires: python2-six >= 1.4.1
BuildRequires: python2-cffi >= 1.7
BuildRequires: python2-enum34
BuildRequires: python2-ipaddress
%endif
%if 0%{?with_python3}
BuildRequires: python%{python3_pkgversion}-devel
@ -57,6 +66,7 @@ BuildRequires: python%{python3_pkgversion}-cffi >= 1.7
cryptography is a package designed to expose cryptographic primitives and
recipes to Python developers.
%if 0%{?with_python2}
%package -n python2-%{srcname}
Summary: PyCA's cryptography library
@ -77,6 +87,7 @@ Requires: python2-ipaddress
%description -n python2-%{srcname}
cryptography is a package designed to expose cryptographic primitives and
recipes to Python developers.
%endif
%if 0%{?with_python3}
%package -n python%{python3_pkgversion}-%{srcname}
@ -97,64 +108,61 @@ recipes to Python developers.
%prep
%autosetup -p1 -n %{srcname}-%{version}
%if 0%{?with_python3}
rm -rf %{py3dir}
cp -a . %{py3dir}
find %{py3dir} -name '*.py' | xargs sed -i '1s|^#!/usr/bin/python|#!%{__python3}|'
%endif
%build
%if 0%{?with_python3}
%if 0%{?with_python2}
%py2_build
pushd %{py3dir}
%endif
%if 0%{?with_python3}
%py3_build
popd
%else
%{__python2} setup.py build
%endif # with_python3
%endif
%install
# Actually other *.c and *.h are appropriate
# see https://github.com/pyca/cryptography/issues/1463
find . -name .keep -print -delete
%if 0%{?with_python3}
%if 0%{?with_python2}
%py2_install
pushd %{py3dir}
%endif
%if 0%{?with_python3}
%py3_install
popd
%else
%{__python2} setup.py install --skip-build --prefix=%{_prefix} --root %{buildroot}
%endif # with_python3
%endif
%check
# see https://github.com/pyca/cryptography/issues/4885 for the deselected test
PYTHONPATH=%{buildroot}%{python2_sitearch} %{__python2} -m pytest -k "not test_buffer_protocol_alternate_modes[mode5]"
%if 0%{?with_python2}
# see https://github.com/pyca/cryptography/issues/4885 and
# see https://bugzilla.redhat.com/show_bug.cgi?id=1761194 for deselected tests
PYTHONPATH=%{buildroot}%{python2_sitearch} %{__python2} -m pytest -k "not (test_buffer_protocol_alternate_modes or test_dh_parameters_supported or test_load_ecdsa_no_named_curve)"
%endif
%if 0%{?with_python3}
pushd %{py3dir}
PYTHONPATH=%{buildroot}%{python3_sitearch} %{__python3} -m pytest -k "not test_buffer_protocol_alternate_modes[mode5]"
popd
PYTHONPATH=%{buildroot}%{python3_sitearch} %{__python3} -m pytest -k "not (test_buffer_protocol_alternate_modes or test_dh_parameters_supported or test_load_ecdsa_no_named_curve)"
%endif
%if 0%{?with_python2}
%files -n python2-%{srcname}
%doc LICENSE LICENSE.APACHE LICENSE.BSD README.rst docs
%{python2_sitearch}/%{srcname}
%{python2_sitearch}/%{srcname}-%{version}-py*.egg-info
%endif
%if 0%{?with_python3}
%files -n python%{python3_pkgversion}-%{srcname}
%doc README.rst docs
%license LICENSE LICENSE.APACHE LICENSE.BSD
%{python3_sitearch}/*
%{python3_sitearch}/%{srcname}
%{python3_sitearch}/%{srcname}-%{version}-py*.egg-info
%endif
%changelog
* Sun Oct 13 2019 Christian Heimes <cheimes@redhat.com> - 2.6.1-3
- Skip unit tests that fail with OpenSSL 1.1.1.d
- Resolves: rhbz#1761194
- Fix and simplify Python 3 packaging
* Fri Jul 26 2019 Fedora Release Engineering <releng@fedoraproject.org> - 2.6.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_31_Mass_Rebuild