summaryrefslogtreecommitdiffstats
path: root/meta-python/recipes-devtools/python/python-m2crypto
diff options
context:
space:
mode:
authorLi xin <lixin.fnst@cn.fujitsu.com>2015-07-30 18:31:25 +0800
committerMartin Jansa <Martin.Jansa@gmail.com>2015-08-18 11:52:31 +0200
commit74de7be5a464e184fed64661e2a45f2f6fac58a5 (patch)
tree308ff9543d24fb0734c0f2bc80d399a8236cb5b8 /meta-python/recipes-devtools/python/python-m2crypto
parent9cc54e10efa5ca70d9980f833a8e5a310e5ad21d (diff)
downloadmeta-openembedded-74de7be5a464e184fed64661e2a45f2f6fac58a5.tar.gz
python-m2crypto: Error fix for swig >= 3.0.5
After swig upgrade to 3.0.6, build the recipes which depends on python-m2crypto will occur errors like this: "SALT_LEN = m2.PKCS5_SALT_LEN AttributeError: 'module' object has no attribute 'PKCS5_SALT_LEN'" Reference https://github.com/martinpaljak/M2Crypto/issues/60#issuecomment-75735489 Signed-off-by: Li Xin <lixin.fnst@cn.fujitsu.com> Signed-off-by: Martin Jansa <Martin.Jansa@gmail.com>
Diffstat (limited to 'meta-python/recipes-devtools/python/python-m2crypto')
-rw-r--r--meta-python/recipes-devtools/python/python-m2crypto/0001-M2Crypto-Error-fix.patch162
1 files changed, 162 insertions, 0 deletions
diff --git a/meta-python/recipes-devtools/python/python-m2crypto/0001-M2Crypto-Error-fix.patch b/meta-python/recipes-devtools/python/python-m2crypto/0001-M2Crypto-Error-fix.patch
new file mode 100644
index 000000000..2a74b6850
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python-m2crypto/0001-M2Crypto-Error-fix.patch
@@ -0,0 +1,162 @@
1From 02a24ac541df68033d4efd7e2f8a1b92dc49328d Mon Sep 17 00:00:00 2001
2From: Li xin <lixin.fnst@cn.fujitsu.com>
3Date: Mon, 27 Jul 2015 05:06:20 +0900
4Subject: [PATCH] M2Crypto: Error fix.
5
6After swig upgrade from 3.0.2 to 3.0.6,build the recipes which
7depends on python-m2crypto will occur errors like this:
8SALT_LEN = m2.PKCS5_SALT_LEN
9AttributeError: 'module' object has no attribute 'PKCS5_SALT_LEN'
10since python-m2crypto depends on swig-native
11
12Ref:
13https://github.com/martinpaljak/M2Crypto/issues/60#issuecomment-75735489
14
15This patch is from:
16http://pkgs.fedoraproject.org/cgit/m2crypto.git/tree/m2crypto-0.21.1-swig-3.0.5.patch
17
18Upstream-Status: pending
19
20Signed-off-by: Li Xin <lixin.fnst@cn.fujitsu.com>
21---
22 M2Crypto/__init__.py | 4 ++--
23 M2Crypto/m2.py | 2 +-
24 SWIG/_lib.i | 4 ++++
25 SWIG/_pkcs7.i | 1 +
26 setup.py | 26 +++++++++++++++++++++++++-
27 5 files changed, 33 insertions(+), 4 deletions(-)
28
29diff --git a/M2Crypto/__init__.py b/M2Crypto/__init__.py
30index e7acfe7..02f4d28 100644
31--- a/M2Crypto/__init__.py
32+++ b/M2Crypto/__init__.py
33@@ -19,7 +19,7 @@ Copyright 2008-2011 Heikki Toivonen. All rights reserved.
34 version_info = (0, 21, 1)
35 version = '.'.join([str(_v) for _v in version_info])
36
37-import __m2crypto
38+import _m2crypto
39 import m2
40 import ASN1
41 import AuthCookie
42@@ -57,4 +57,4 @@ import util
43 encrypt=1
44 decrypt=0
45
46-__m2crypto.lib_init()
47+_m2crypto.lib_init()
48diff --git a/M2Crypto/m2.py b/M2Crypto/m2.py
49index e4bb695..822143f 100644
50--- a/M2Crypto/m2.py
51+++ b/M2Crypto/m2.py
52@@ -25,7 +25,7 @@ Portions created by Open Source Applications Foundation (OSAF) are
53 Copyright (C) 2004 OSAF. All Rights Reserved.
54 """
55
56-from __m2crypto import *
57+from _m2crypto import *
58 lib_init()
59
60
61diff --git a/SWIG/_lib.i b/SWIG/_lib.i
62index 42dc180..47a53b8 100644
63--- a/SWIG/_lib.i
64+++ b/SWIG/_lib.i
65@@ -100,6 +100,7 @@ int ssl_verify_callback(int ok, X509_STORE_CTX *ctx) {
66 int cret;
67 int new_style_callback = 0, warning_raised_exception=0;
68 PyGILState_STATE gilstate;
69+ PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */
70
71 ssl = (SSL *)X509_STORE_CTX_get_app_data(ctx);
72
73@@ -185,6 +186,7 @@ int ssl_verify_callback(int ok, X509_STORE_CTX *ctx) {
74 void ssl_info_callback(const SSL *s, int where, int ret) {
75 PyObject *argv, *retval, *_SSL;
76 PyGILState_STATE gilstate;
77+ PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */
78
79 gilstate = PyGILState_Ensure();
80
81@@ -204,6 +206,7 @@ DH *ssl_set_tmp_dh_callback(SSL *ssl, int is_export, int keylength) {
82 PyObject *argv, *ret, *_ssl;
83 DH *dh;
84 PyGILState_STATE gilstate;
85+ PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */
86
87 gilstate = PyGILState_Ensure();
88
89@@ -227,6 +230,7 @@ RSA *ssl_set_tmp_rsa_callback(SSL *ssl, int is_export, int keylength) {
90 PyObject *argv, *ret, *_ssl;
91 RSA *rsa;
92 PyGILState_STATE gilstate;
93+ PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */
94
95 gilstate = PyGILState_Ensure();
96
97diff --git a/SWIG/_pkcs7.i b/SWIG/_pkcs7.i
98index 174f40a..7bffbfc 100644
99--- a/SWIG/_pkcs7.i
100+++ b/SWIG/_pkcs7.i
101@@ -157,6 +157,7 @@ PyObject *smime_read_pkcs7(BIO *bio) {
102 BIO *bcont = NULL;
103 PKCS7 *p7;
104 PyObject *tuple, *_p7, *_BIO;
105+ PyObject *self = NULL; /* bug in SWIG_NewPointerObj as of 3.0.5 */
106
107 if (BIO_method_type(bio) == BIO_TYPE_MEM) {
108 /* OpenSSL FAQ explains that this is needed for mem BIO to return EOF,
109diff --git a/setup.py b/setup.py
110index e7c49eb..b98abe0 100644
111--- a/setup.py
112+++ b/setup.py
113@@ -20,6 +20,7 @@ except ImportError:
114 from distutils.command import build_ext
115
116 from distutils.core import Extension
117+from distutils.file_util import copy_file
118
119
120 class _M2CryptoBuildExt(build_ext.build_ext):
121@@ -57,7 +58,17 @@ class _M2CryptoBuildExt(build_ext.build_ext):
122 self.swig_opts.append('-includeall')
123 #self.swig_opts.append('-D__i386__') # Uncomment for early OpenSSL 0.9.7 versions, or on Fedora Core if build fails
124 #self.swig_opts.append('-DOPENSSL_NO_EC') # Try uncommenting if you can't build with EC disabled
125-
126+ self.swig_opts.append('-modern')
127+ self.swig_opts.append('-builtin')
128+
129+ # These two lines are a workaround for
130+ # http://bugs.python.org/issue2624 , hard-coding that we are only
131+ # building a single extension with a known path; a proper patch to
132+ # distutils would be in the run phase, when extension name and path are
133+ # known.
134+ self.swig_opts.append('-outdir')
135+ self.swig_opts.append(os.path.join(self.build_lib, 'M2Crypto'))
136+
137 self.include_dirs += [os.path.join(self.openssl, opensslIncludeDir),
138 os.path.join(os.getcwd(), 'SWIG')]
139
140@@ -71,6 +82,19 @@ class _M2CryptoBuildExt(build_ext.build_ext):
141
142 self.library_dirs += [os.path.join(self.openssl, opensslLibraryDir)]
143
144+ def run(self):
145+ '''Overloaded build_ext implementation to allow inplace=1 to work,
146+ which is needed for (python setup.py test).'''
147+ # This is another workaround for http://bugs.python.org/issue2624 + the
148+ # corresponding lack of support in setuptools' test command. Note that
149+ # just using self.inplace in finalize_options() above does not work
150+ # because swig is not rerun if the __m2crypto.so extension exists.
151+ # Again, hard-coding our extension name and location.
152+ build_ext.build_ext.run(self)
153+ if self.inplace:
154+ copy_file(os.path.join(self.build_lib, 'M2Crypto', '_m2crypto.py'),
155+ os.path.join('M2Crypto', '_m2crypto.py'),
156+ verbose=self.verbose, dry_run=self.dry_run)
157
158 if sys.version_info < (2,4):
159
160--
1611.8.4.2
162