-%include /usr/lib/rpm/macros.python
+#
+# Conditional build:
+%bcond_with tests # test target [fails, some files are missing]
+%bcond_without doc # don't build doc
+%bcond_without python2 # CPython 2.x module
+%bcond_without python3 # CPython 3.x module
+
+%define module M2Crypto
Summary: Python interface to OpenSSL
-Summary(pl): Interfejs Pythona do OpenSSL
+Summary(pl.UTF-8): Interfejs Pythona do OpenSSL
Name: python-M2Crypto
-Version: 0.13
-Release: 1
+Version: 0.30.1
+Release: 4
License: BSD-like
-Source0: http://sandbox.rulemaker.net/ngps/Dist/m2crypto-%{version}.zip
-# Source0-md5: be2790a34349ab452dddbcfe4c95606a
-URL: http://sandbox.rulemaker.net/ngps/m2/
-Group: Development/Languages/Python
-%pyrequires_eq python
-BuildRequires: python-devel >= 2.2.1
-BuildRequires: openssl-devel >= 0.9.7d
-BuildRequires: swig >= 1.3.17
+Group: Libraries/Python
+#Source0Download: https://pypi.python.org/simple/m2crypto/
+Source0: https://pypi.debian.net/M2Crypto/M2Crypto-%{version}.tar.gz
+# Source0-md5: 7fce3cbf85eb84a669682892b935746b
+Patch0: %{name}-store2ssl.patch
+Patch1: %{name}-swig.patch
+URL: https://gitlab.com/m2crypto/m2crypto
+BuildRequires: openssl-devel >= 1.0.1e
+%if %{with python2}
+BuildRequires: python-devel >= 1:2.6
+BuildRequires: python-modules >= 1:2.6
+BuildRequires: python-setuptools
+%endif
+%if %{with python3}
+BuildRequires: python3-devel
+BuildRequires: python3-modules
+BuildRequires: python3-setuptools
+%endif
BuildRequires: rpm-pythonprov
+BuildRequires: rpmbuild(macros) >= 1.710
+BuildRequires: swig-python >= 2.0
+BuildRequires: unzip
+Requires: openssl >= 1.0.1e
+Requires: python-libs
BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
%description
M2Crypto is released under a very liberal BSD-like licence. See
LICENCE for details.
-%description -l pl
-M2Crypto udostêpnia z poziomu Pythona nastêpuj±ce funkcje:
-- DH, RSA, DSA, szyfry symetryczne, skróty, HMAC
-- SSL do implementacji klientów i serwerów
+%description -l pl.UTF-8
+M2Crypto udostępnia z poziomu Pythona następujące funkcje:
+- DH, RSA, DSA, szyfry symetryczne, skróty, HMAC
+- SSL do implementacji klientów i serwerów
+- S/MIME v2.
+
+M2Crypto jest wydane na bardzo liberalnej licencji BSD - szczegóły w
+pliku LICENCE.
+
+%package -n python3-%{module}
+Summary: Python interface to OpenSSL
+Summary(pl.UTF-8): Interfejs Pythona do OpenSSL
+Group: Libraries/Python
+Requires: openssl >= 1.0.1
+Requires: python3-libs
+Requires: python3-modules
+
+%description -n python3-%{module}
+M2Crypto makes accessible to the Python programmer the following:
+- DH, RSA, DSA, symmetric ciphers, message digests, HMACs.
+- SSL functionality to implement clients and servers.
+- S/MIME v2.
+
+M2Crypto is released under a very liberal BSD-like licence. See
+LICENCE for details.
+
+%description -n python3-%{module} -l pl.UTF-8
+M2Crypto udostępnia z poziomu Pythona następujące funkcje:
+- DH, RSA, DSA, szyfry symetryczne, skróty, HMAC
+- SSL do implementacji klientów i serwerów
- S/MIME v2.
+M2Crypto jest wydane na bardzo liberalnej licencji BSD - szczegóły w
+pliku LICENCE.
+
%prep
-%setup -q -n m2crypto-%{version}
+%setup -q -n M2Crypto-%{version}
+%patch0 -p1
+%patch1 -p1
%build
-python setup.py build
+%if %{with python2}
+%py_build %{?with_tests:test}
+%endif
+
+%if %{with python3}
+%py3_build %{?with_tests:test}
+%endif
%install
rm -rf $RPM_BUILD_ROOT
-install -d $RPM_BUILD_ROOT%{py_sitedir}
-python setup.py install \
- --root=$RPM_BUILD_ROOT \
- --optimize=2
+%if %{with python2}
+%py_install
+%py_postclean
+%endif
+
+%if %{with python3}
+%py3_install
+%endif
-# shutup check-files
-find $RPM_BUILD_ROOT/%{py_sitedir} -name \*.py \
- -exec rm {} \;
-
%clean
rm -rf $RPM_BUILD_ROOT
+%if %{with python2}
%files
%defattr(644,root,root,755)
-%doc BUGS CHANGES INSTALL LICENCE README doc/*.html demo
-%attr(755,root,root) %{py_sitedir}/M2Crypto/*.so
-%{py_sitedir}/M2Crypto/*.py[oc]
+%doc CHANGES LICENCE README.rst
+%dir %{py_sitedir}/M2Crypto
+%attr(755,root,root) %{py_sitedir}/M2Crypto/_m2crypto.so
+%{py_sitedir}/M2Crypto/*.py[co]
%dir %{py_sitedir}/M2Crypto/SSL
-%{py_sitedir}/M2Crypto/SSL/*.py[oc]
-%dir %{py_sitedir}/M2Crypto/PGP
-%{py_sitedir}/M2Crypto/PGP/*.py[oc]
+%{py_sitedir}/M2Crypto/SSL/*.py[co]
+%{py_sitedir}/M2Crypto-*.egg-info
+%endif
+
+%if %{with python3}
+%files -n python3-%{module}
+%defattr(644,root,root,755)
+%doc CHANGES LICENCE README.rst
+%dir %{py3_sitedir}/%{module}
+%{py3_sitedir}/%{module}/*.py
+%attr(755,root,root) %{py3_sitedir}/%{module}/*.so
+%{py3_sitedir}/%{module}/__pycache__
+%dir %{py3_sitedir}/%{module}/SSL
+%{py3_sitedir}/%{module}/SSL/*.py
+%{py3_sitedir}/%{module}/SSL/__pycache__
+%{py3_sitedir}/%{module}-%{version}-py*.egg-info
+%endif
+