# Created by pyp2rpm-3.2.2
%global pypi_name asn1crypto

%bcond_without python2
%bcond_without python3

%{!?python3_pkgversion:%global python3_pkgversion 3}

Summary:        Fast Python ASN.1 parser and serializer
Name:           python-%{pypi_name}
Version:        1.5.1
Release:        1%{?_dist_release}
Group:          programming
Vendor:         Project Vine
Distribution:   Vine Linux

License:        MIT
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:  python-rpm-macros
BuildRequires:  python2-rpm-macros
BuildRequires:  python-devel
BuildRequires:  python-setuptools
%{?python_provide:%python_provide python2-%{pypi_name}}
%endif
%if 0%{?with_python3}
BuildRequires:  python%{python3_pkgversion}-rpm-macros
BuildRequires:  python%{python3_pkgversion}-devel
BuildRequires:  python%{python3_pkgversion}-setuptools
%endif

%description
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_python3}
%package -n     python%{python3_pkgversion}-%{pypi_name}
Summary:        %{summary}
%{?python_provide:%python_provide python%{python3_pkgversion}-%{pypi_name}}

%description -n python%{python3_pkgversion}-%{pypi_name}
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


%prep
%autosetup -n %{pypi_name}-%{version}
# Remove bundled egg-info
rm -rf %{pypi_name}.egg-info


%build
%if 0%{?with_python2}
%py2_build
%endif
%if 0%{?with_python3}
%pip3_build_wheel
%endif

%install
%if 0%{?with_python2}
%py2_install
%endif
%if 0%{?with_python3}
%pip3_install_wheel
%endif


%check
# asn1crypto source distribution doesn't come with tests
# {__python2} setup.py test
%if 0%{?with_python3}
# {__python3} setup.py test
%endif


%if 0%{?with_python2}
%files
%license LICENSE
%doc readme* changelog*
%{python2_sitelib}/%{pypi_name}
%{python2_sitelib}/%{pypi_name}-%{version}-py?.?.egg-info
%endif

%if 0%{?with_python3}
%files -n python%{python3_pkgversion}-%{pypi_name}
%license LICENSE
%doc readme* changelog*
%{python3_sitelib}/%{pypi_name}
%{python3_sitelib}/%{pypi_name}-*-info
%endif


%changelog
* Fri Oct 28 2022 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.5.1-1
- new upstream release.

* Sat Aug 15 2020 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 1.4.0-1
- new upstream release.

* Mon Nov 19 2018 Tomohiro "Tomo-p" KATO <tomop@teamgedoh.net> - 0.24.0-6
- initial build for Vine Linux.

* Fri Jul 13 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.24.0-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_29_Mass_Rebuild

* Mon Jul 02 2018 Miro Hrončok <mhroncok@redhat.com> - 0.24.0-4
- Rebuilt for Python 3.7

* 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

* Wed Mar 21 2018 Christian Heimes <cheimes@redhat.com> - 0.24.0-1
- New upstream release 0.24.0

* Fri Feb 09 2018 Fedora Release Engineering <releng@fedoraproject.org> - 0.23.0-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild

* Thu Oct 12 2017 Christian Heimes <cheimes@redhat.com> - 0.23-1
- New upstream release 0.23.0

* Fri Aug 04 2017 Christian Heimes <cheimes@redhat.com> - 0.22.0-5
- Use python2-setuptools, add with_python3

* Thu Aug 03 2017 Christian Heimes <cheimes@redhat.com> - 0.22.0-4
- Modernize spec

* Thu Jul 27 2017 Fedora Release Engineering <releng@fedoraproject.org> - 0.22.0-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild

* Tue Jun 27 2017 Christian Heimes <cheimes@redhat.com> - 0.22.0-2
- Address rpmlint issues

* Tue Jun 27 2017 Christian Heimes <cheimes@redhat.com> - 0.22.0-1
- Initial package.
