- Add cryptography-custom-install-cmd.patch: Fix installation to plat_lib

- Properly invoke testsuite, therefore add dependencies on iso8601 and pretend
- Only use pkg-config for libffi on newer distros, stay with old-style
  devel package requires to fix SLE build

OBS-URL: https://build.opensuse.org/package/show/devel:languages:python/python-cryptography?expand=0&rev=2
This commit is contained in:
Sascha Peilicke 2014-04-01 08:25:31 +00:00 committed by Git OBS Bridge
parent a003527a66
commit 587832a356
3 changed files with 109 additions and 24 deletions

View File

@ -0,0 +1,80 @@
--- a/setup.py 2014-02-22 22:35:18.000000000 +0100
+++ b/setup.py 2014-03-31 18:02:28.144820932 +0200
@@ -12,6 +12,7 @@
# limitations under the License.
import os
from distutils.command.build import build
+from distutils.command.install import install
from setuptools import setup, find_packages
@@ -32,6 +33,27 @@
]
+def get_ext_modules():
+ from cryptography.hazmat.bindings.commoncrypto.binding import (
+ Binding as CommonCryptoBinding
+ )
+ from cryptography.hazmat.bindings.openssl.binding import (
+ Binding as OpenSSLBinding
+ )
+ from cryptography.hazmat.primitives import constant_time, padding
+
+ ext_modules = [
+ OpenSSLBinding().ffi.verifier.get_extension(),
+ constant_time._ffi.verifier.get_extension(),
+ padding._ffi.verifier.get_extension()
+ ]
+ if CommonCryptoBinding.is_available():
+ ext_modules.append(
+ CommonCryptoBinding().ffi.verifier.get_extension()
+ )
+ return ext_modules
+
+
class cffi_build(build):
"""
This class exists, instead of just providing ``ext_modules=[...]`` directly
@@ -43,25 +65,17 @@
"""
def finalize_options(self):
- from cryptography.hazmat.bindings.commoncrypto.binding import (
- Binding as CommonCryptoBinding
- )
- from cryptography.hazmat.bindings.openssl.binding import (
- Binding as OpenSSLBinding
- )
- from cryptography.hazmat.primitives import constant_time, padding
+ self.distribution.ext_modules = get_ext_modules()
+ build.finalize_options(self)
- self.distribution.ext_modules = [
- OpenSSLBinding().ffi.verifier.get_extension(),
- constant_time._ffi.verifier.get_extension(),
- padding._ffi.verifier.get_extension()
- ]
- if CommonCryptoBinding.is_available():
- self.distribution.ext_modules.append(
- CommonCryptoBinding().ffi.verifier.get_extension()
- )
- build.finalize_options(self)
+class cffi_install(install):
+ """
+ As a consequence...
+ """
+ def finalize_options(self):
+ self.distribution.ext_modules = get_ext_modules()
+ install.finalize_options(self)
with open(os.path.join(base_dir, "README.rst")) as f:
@@ -111,5 +125,6 @@
ext_package="cryptography",
cmdclass={
"build": cffi_build,
+ "install": cffi_install
}
)

View File

@ -1,3 +1,11 @@
-------------------------------------------------------------------
Mon Mar 31 16:03:46 UTC 2014 - speilicke@suse.com
- Add cryptography-custom-install-cmd.patch: Fix installation to plat_lib
- Properly invoke testsuite, therefore add dependencies on iso8601 and pretend
- Only use pkg-config for libffi on newer distros, stay with old-style
devel package requires to fix SLE build
-------------------------------------------------------------------
Mon Feb 24 12:43:32 UTC 2014 - mvyskocil@suse.com

View File

@ -26,28 +26,28 @@ Group: Development/Languages/Python
Source0: https://pypi.python.org/packages/source/c/cryptography/cryptography-%{version}.tar.gz
Source1: https://pypi.python.org/packages/source/c/cryptography/cryptography-%{version}.tar.gz.asc
Source2: %{name}.keyring
# PATCH-FIX-UPSTREAM speilicke@suse.com -- Backport of https://github.com/pyca/cryptography/pull/872
Patch0: cryptography-custom-install-cmd.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
%if 0%{suse_version} && 0%{?suse_version} >= 1220
BuildRequires: gpg-offline
%endif
BuildRequires: pkgconfig(python2)
BuildRequires: pkgconfig(openssl)
BuildRequires: pkgconfig(libffi)
BuildRequires: libopenssl-devel
BuildRequires: python-cffi >= 0.8
BuildRequires: python-six >= 1.4.1
BuildRequires: python-devel
BuildRequires: python-setuptools
#test requirements
BuildRequires: python-six >= 1.4.1
# Test requirements
BuildRequires: python-iso8601
BuildRequires: python-pretend
BuildRequires: python-pytest
Requires: python-cffi >= 0.8
Requires: python-six >= 1.4.1
Requires: python-cffi >= 0.8
Requires: python-six >= 1.4.1
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
%{!?python_sitelib: %global python_sitelib %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
%{!?python_sitearch: %global python_sitearch %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(True)")}
%{!?py_ver: %global py_ver %(python -c "import sys; v=sys.version_info[:2]; print '%%d.%%d'%%v" 2>/dev/null || echo PYTHON-NOT-FOUND)}
%{!?python_sitearch: %global python_sitearch %(python -c "from distutils.sysconfig import get_python_lib; print get_python_lib(1)")}
BuildRequires: libffi43-devel
%else
BuildRequires: pkgconfig(libffi)
%endif
%description
@ -66,6 +66,11 @@ functions.
%gpg_verify %{SOURCE1}
%endif
%setup -q -n cryptography-%{version}
%patch0 -p1
%if 0%{?suse_version} && 0%{?suse_version} <= 1110
#TODO(saschpe): Failing on SP3, debug later:
rm tests/hazmat/primitives/test_rsa.py
%endif
%build
CFLAGS="%{optflags} -fno-strict-aliasing" python setup.py build
@ -73,16 +78,8 @@ CFLAGS="%{optflags} -fno-strict-aliasing" python setup.py build
%install
python setup.py install --prefix=%{_prefix} --root=%{buildroot}
#mvyskocil: FIXME somehow in setup.py
if [ "%{python_sitelib}" != "%{python_sitearch}" ]; then
mkdir -p %{buildroot}/%{python_sitearch}/
mv %{buildroot}/%{python_sitelib}/cryptography* %{buildroot}/%{python_sitearch}/
rm -rf %{buildroot}/%{python_sitelib}/
fi
#mvyskocil: FIXME, modules iso8601 and pretend are needed to run tests
#%check
#py.test tests/
%check
py.test
%files
%defattr(-,root,root,-)