Build Python 2 package conditionally

This commit is contained in:
Christian Heimes 2018-06-19 11:07:01 +02:00
parent 3b8bf97eb9
commit 03e2fb9523

View File

@ -1,15 +1,25 @@
# Created by pyp2rpm-3.2.2
%global pypi_name asn1crypto
%if 0%{?fedora}
%global with_python3 1
%if 0%{?fedora} || 0%{?rhel} > 7
# Enable python3 build by default
%bcond_without python3
%else
%bcond_with python3
%endif
%if 0%{?rhel} > 7
# Disable python2 build by default
%bcond_with python2
%else
%bcond_without python2
%endif
%{!?python3_pkgversion:%global python3_pkgversion 3}
Name: python-%{pypi_name}
Version: 0.24.0
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Fast Python ASN.1 parser and serializer
License: MIT
@ -17,9 +27,10 @@ URL: https://github.com/wbond/asn1crypto
Source0: https://files.pythonhosted.org/packages/source/a/%{pypi_name}/%{pypi_name}-%{version}.tar.gz
BuildArch: noarch
%if 0%{?with_python2}
BuildRequires: python2-devel
BuildRequires: python2-setuptools
%endif
%if 0%{?with_python3}
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python%{python3_pkgversion}-setuptools
@ -30,6 +41,7 @@ Fast ASN.1 parser and serializer with definitions for private keys,
public keys, certificates, CRL, OCSP, CMS, PKCS#3, PKCS#7, PKCS#8,
PKCS#12, PKCS#5, X.509 and TSP.
%if 0%{?with_python2}
%package -n python2-%{pypi_name}
Summary: %{summary}
%{?python_provide:%python_provide python2-%{pypi_name}}
@ -38,6 +50,7 @@ Summary: %{summary}
Fast ASN.1 parser and serializer with definitions for private keys,
public keys, certificates, CRL, OCSP, CMS, PKCS#3, PKCS#7, PKCS#8,
PKCS#12, PKCS#5, X.509 and TSP.
%endif
%if 0%{?with_python3}
%package -n python%{python3_pkgversion}-%{pypi_name}
@ -56,20 +69,21 @@ PKCS#12, PKCS#5, X.509 and TSP.
rm -rf %{pypi_name}.egg-info
%build
%if 0%{?with_python2}
%py2_build
%endif
%if 0%{?with_python3}
%py3_build
%endif
%install
# Must do the subpackages' install first because the scripts in /usr/bin are
# overwritten with every setup.py install.
%if 0%{?with_python2}
%py2_install
%endif
%if 0%{?with_python3}
%py3_install
%endif
%py2_install
%check
# asn1crypto source distribution doesn't come with tests
@ -78,10 +92,12 @@ rm -rf %{pypi_name}.egg-info
# {__python3} setup.py test
%endif
%if 0%{?with_python2}
%files -n python2-%{pypi_name}
%doc
%{python2_sitelib}/%{pypi_name}
%{python2_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info
%endif
%if 0%{?with_python3}
%files -n python%{python3_pkgversion}-%{pypi_name}
@ -91,6 +107,9 @@ rm -rf %{pypi_name}.egg-info
%endif
%changelog
* Tue Jun 19 2018 Christian Heimes <cheimes@redhat.com> - 0.24.0-3
- Build Python 2 package conditionally
* Fri Jun 15 2018 Miro Hrončok <mhroncok@redhat.com> - 0.24.0-2
- Rebuilt for Python 3.7