Unified Fedora/EPEL-7 spec

- Enable python3 builds from EPEL-7 (#1110373)
- Modernize spec
f38
Paul Howarth 9 years ago
parent f4c1fee439
commit 71ec20eb47

@ -1,51 +1,56 @@
%global pythonver %(%{__python} -c "import sys; print sys.version[:3]" 2>/dev/null || echo 0.0)
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)" 2>/dev/null)}
# Share docs between python2 and python3 packages
%global _docdir_fmt %{name}
# Python3 introduced in Fedora 13
%global with_python3 %([ 0%{?fedora} -gt 12 ] && echo 1 || echo 0)
# Single python3 version in Fedora, python3_pkgversion macro not available
%{!?python3_pkgversion:%global python3_pkgversion 3}
# For consistency and completeness
%global python2_pkgversion 2
Summary: Cryptography library for Python
Name: python-crypto
Version: 2.6.1
Release: 8%{?dist}
Release: 9%{?dist}
# Mostly Public Domain apart from parts of HMAC.py and setup.py, which are Python
License: Public Domain and Python
Group: Development/Libraries
URL: http://www.pycrypto.org/
Source0: http://ftp.dlitz.net/pub/dlitz/crypto/pycrypto/pycrypto-%{version}.tar.gz
Patch0: python-crypto-2.4-optflags.patch
Patch1: python-crypto-2.4-fix-pubkey-size-divisions.patch
Patch2: pycrypto-2.6.1-unbundle-libtomcrypt.patch
Provides: pycrypto = %{version}-%{release}
BuildRequires: python2-devel >= 2.2, gmp-devel >= 4.1, libtomcrypt-devel >= 1.16
%if %{with_python3}
BuildRequires: coreutils
BuildRequires: findutils
BuildRequires: gcc
BuildRequires: gmp-devel >= 4.1
BuildRequires: libtomcrypt-devel >= 1.16
BuildRequires: python%{python2_pkgversion}-devel >= 2.4
BuildRequires: python%{python3_pkgversion}-devel
BuildRequires: python-tools
BuildRequires: python3-devel
%endif
BuildRoot: %{_tmppath}/%{name}-%{version}-buildroot-%(id -nu)
# Don't want provides for python shared objects
%{?filter_provides_in: %filter_provides_in %{python_sitearch}/Crypto/.*\.so}
%if %{with_python3}
%{?filter_provides_in: %filter_provides_in %{python3_sitearch}/Crypto/.*\.so}
%endif
%{?filter_setup}
%description
PyCrypto is a collection of both secure hash functions (such as MD5 and
SHA), and various encryption algorithms (AES, DES, RSA, ElGamal, etc.).
%if %{with_python3}
%package -n python3-crypto
%package -n python%{python2_pkgversion}-crypto
Summary: Cryptography library for Python 2
Provides: pycrypto = %{version}-%{release}
%{?python_provide:%python_provide python2-crypto}
%description -n python%{python2_pkgversion}-crypto
PyCrypto is a collection of both secure hash functions (such as MD5 and
SHA), and various encryption algorithms (AES, DES, RSA, ElGamal, etc.).
This is the Python 2 build of the package.
%package -n python%{python3_pkgversion}-crypto
Summary: Cryptography library for Python 3
Group: Development/Libraries
%{?python_provide:%python_provide python3-crypto}
%description -n python3-crypto
%description -n python%{python3_pkgversion}-crypto
PyCrypto is a collection of both secure hash functions (such as MD5 and
SHA), and various encryption algorithms (AES, DES, RSA, ElGamal, etc.).
This is the Python 3 build of the package.
%endif
%prep
%setup -n pycrypto-%{version} -q
@ -60,72 +65,48 @@ This is the Python 3 build of the package.
rm -rf src/libtom
%patch2
# Prepare python3 build (setup.py doesn't run 2to3 on pct-speedtest.py)
%if %{with_python3}
cp -a . %{py3dir}
2to3 -wn %{py3dir}/pct-speedtest.py
%endif
# setup.py doesn't run 2to3 on pct-speedtest.py
cp pct-speedtest.py pct-speedtest3.py
2to3 -wn pct-speedtest3.py
%build
CFLAGS="%{optflags} -fno-strict-aliasing" %{__python} setup.py build
%if %{with_python3}
cd %{py3dir}
CFLAGS="%{optflags} -fno-strict-aliasing" %{__python3} setup.py build
cd -
%endif
%global optflags %{optflags} -fno-strict-aliasing
%py2_build
%py3_build
%install
rm -rf %{buildroot}
%{__python} setup.py install -O1 --skip-build --root %{buildroot}
%py2_install
%py3_install
# Remove group write permissions on shared objects
find %{buildroot}%{python_sitearch} -name '*.so' -exec chmod -c g-w {} \;
# Build for python3 too
%if %{with_python3}
cd %{py3dir}
%{__python3} setup.py install -O1 --skip-build --root %{buildroot}
cd -
find %{buildroot}%{python2_sitearch} -name '*.so' -exec chmod -c g-w {} \;
find %{buildroot}%{python3_sitearch} -name '*.so' -exec chmod -c g-w {} \;
%endif
# See if there's any egg-info
if [ -f %{buildroot}%{python_sitearch}/pycrypto-%{version}-py%{pythonver}.egg-info ]; then
echo %{python_sitearch}/pycrypto-%{version}-py%{pythonver}.egg-info
fi > egg-info
%check
%{__python} setup.py test
# Benchmark uses os.urandom(), which is available from python 2.4
%if %(%{__python} -c "import sys; print sys.hexversion >= 0x02040000 and 1 or 0" 2>/dev/null || echo 0)
PYTHONPATH=%{buildroot}%{python_sitearch} %{__python} pct-speedtest.py
%endif
# Test the python3 build too
%if %{with_python3}
cd %{py3dir}
%{__python2} setup.py test
%{__python3} setup.py test
PYTHONPATH=%{buildroot}%{python3_sitearch} %{__python3} pct-speedtest.py
cd -
%endif
%clean
rm -rf %{buildroot}
# Benchmark
PYTHONPATH=%{buildroot}%{python2_sitearch} %{__python2} pct-speedtest.py
PYTHONPATH=%{buildroot}%{python3_sitearch} %{__python3} pct-speedtest3.py
%files -f egg-info
%doc README TODO ACKS ChangeLog LEGAL/ COPYRIGHT Doc/
%{python_sitearch}/Crypto/
%files -n python%{python2_pkgversion}-crypto
%license COPYRIGHT LEGAL/
%doc README TODO ACKS ChangeLog Doc/
%{python2_sitearch}/Crypto/
%{python2_sitearch}/pycrypto-%{version}-py2.*.egg-info
%if %{with_python3}
%files -n python3-crypto
%doc README TODO ACKS ChangeLog LEGAL/ COPYRIGHT Doc/
%files -n python%{python3_pkgversion}-crypto
%license COPYRIGHT LEGAL/
%doc README TODO ACKS ChangeLog Doc/
%{python3_sitearch}/Crypto/
%{python3_sitearch}/pycrypto-*py3.*.egg-info
%endif
%{python3_sitearch}/pycrypto-%{version}-py3.*.egg-info
%changelog
* Wed Dec 30 2015 Paul Howarth <paul@city-fan.org> - 2.6.1-9
- Enable python3 builds from EPEL-7 (#1110373)
- Modernize spec
* Wed Nov 04 2015 Matej Stuchlik <mstuchli@redhat.com> - 2.6.1-8
- Rebuilt for Python 3.5

Loading…
Cancel
Save