[pypy-commit] cffi static-callback-embedding: Py3 fixes. Skip the embedding tests if linking with -lpython%d.%d
arigo
pypy.commits at gmail.com
Fri Jan 8 02:17:44 EST 2016
Author: Armin Rigo <arigo at tunes.org>
Branch: static-callback-embedding
Changeset: r2550:e0a4793589e0
Date: 2016-01-08 08:17 +0100
http://bitbucket.org/cffi/cffi/changeset/e0a4793589e0/
Log: Py3 fixes. Skip the embedding tests if linking with -lpython%d.%d
fails (likely, the Python was not compiled with --enable-shared)
diff --git a/cffi/_embedding.h b/cffi/_embedding.h
--- a/cffi/_embedding.h
+++ b/cffi/_embedding.h
@@ -176,7 +176,11 @@
if (PyDict_SetItemString(global_dict, "__builtins__",
PyThreadState_GET()->interp->builtins) < 0)
goto error;
- x = PyEval_EvalCode((PyCodeObject *)pycode, global_dict, global_dict);
+ x = PyEval_EvalCode(
+#if PY_MAJOR_VERSION < 3
+ (PyCodeObject *)
+#endif
+ pycode, global_dict, global_dict);
if (x == NULL)
goto error;
Py_DECREF(x);
diff --git a/testing/embedding/add1.py b/testing/embedding/add1.py
--- a/testing/embedding/add1.py
+++ b/testing/embedding/add1.py
@@ -29,4 +29,4 @@
""")
fn = ffi.compile(verbose=True)
-print 'FILENAME:', fn
+print('FILENAME: %s' % (fn,))
diff --git a/testing/embedding/add2.py b/testing/embedding/add2.py
--- a/testing/embedding/add2.py
+++ b/testing/embedding/add2.py
@@ -25,4 +25,4 @@
""")
fn = ffi.compile(verbose=True)
-print 'FILENAME:', fn
+print('FILENAME: %s' % (fn,))
diff --git a/testing/embedding/add3.py b/testing/embedding/add3.py
--- a/testing/embedding/add3.py
+++ b/testing/embedding/add3.py
@@ -20,4 +20,4 @@
""")
fn = ffi.compile(verbose=True)
-print 'FILENAME:', fn
+print('FILENAME: %s' % (fn,))
diff --git a/testing/embedding/add_recursive.py b/testing/embedding/add_recursive.py
--- a/testing/embedding/add_recursive.py
+++ b/testing/embedding/add_recursive.py
@@ -25,4 +25,4 @@
""")
fn = ffi.compile(verbose=True)
-print 'FILENAME:', fn
+print('FILENAME: %s' % (fn,))
diff --git a/testing/embedding/test_basic.py b/testing/embedding/test_basic.py
--- a/testing/embedding/test_basic.py
+++ b/testing/embedding/test_basic.py
@@ -2,14 +2,33 @@
import sys, os, re
import shutil, subprocess, time
from testing.udir import udir
+import cffi
local_dir = os.path.dirname(os.path.abspath(__file__))
+_link_error = '?'
+
+def check_lib_python_found(tmpdir):
+ global _link_error
+ if _link_error == '?':
+ ffi = cffi.FFI()
+ kwds = {}
+ ffi._apply_embedding_fix(kwds)
+ ffi.set_source("_test_lib_python_found", "", **kwds)
+ try:
+ ffi.compile(tmpdir=tmpdir)
+ except cffi.VerificationError as e:
+ _link_error = e
+ else:
+ _link_error = None
+ if _link_error:
+ py.test.skip(str(_link_error))
class EmbeddingTests:
_compiled_modules = {}
def setup_method(self, meth):
+ check_lib_python_found(str(udir.ensure('embedding', dir=1)))
self._path = udir.join('embedding', meth.__name__)
def get_path(self):
@@ -74,7 +93,7 @@
else:
libpath = path
env['LD_LIBRARY_PATH'] = libpath
- print 'running %r in %r' % (name, path)
+ print('running %r in %r' % (name, path))
popen = subprocess.Popen([name], cwd=path, env=env,
stdout=subprocess.PIPE)
result = popen.stdout.read()
diff --git a/testing/embedding/test_performance.py b/testing/embedding/test_performance.py
--- a/testing/embedding/test_performance.py
+++ b/testing/embedding/test_performance.py
@@ -6,42 +6,42 @@
perf_cffi = self.prepare_module('perf')
self.compile('perf-test', [perf_cffi], opt=True)
output = self.execute('perf-test')
- print '='*79
- print output.rstrip()
- print '='*79
+ print('='*79)
+ print(output.rstrip())
+ print('='*79)
def test_perf_in_1_thread(self):
perf_cffi = self.prepare_module('perf')
self.compile('perf-test', [perf_cffi], opt=True, threads=True,
defines={'PTEST_USE_THREAD': '1'})
output = self.execute('perf-test')
- print '='*79
- print output.rstrip()
- print '='*79
+ print('='*79)
+ print(output.rstrip())
+ print('='*79)
def test_perf_in_2_threads(self):
perf_cffi = self.prepare_module('perf')
self.compile('perf-test', [perf_cffi], opt=True, threads=True,
defines={'PTEST_USE_THREAD': '2'})
output = self.execute('perf-test')
- print '='*79
- print output.rstrip()
- print '='*79
+ print('='*79)
+ print(output.rstrip())
+ print('='*79)
def test_perf_in_4_threads(self):
perf_cffi = self.prepare_module('perf')
self.compile('perf-test', [perf_cffi], opt=True, threads=True,
defines={'PTEST_USE_THREAD': '4'})
output = self.execute('perf-test')
- print '='*79
- print output.rstrip()
- print '='*79
+ print('='*79)
+ print(output.rstrip())
+ print('='*79)
def test_perf_in_8_threads(self):
perf_cffi = self.prepare_module('perf')
self.compile('perf-test', [perf_cffi], opt=True, threads=True,
defines={'PTEST_USE_THREAD': '8'})
output = self.execute('perf-test')
- print '='*79
- print output.rstrip()
- print '='*79
+ print('='*79)
+ print(output.rstrip())
+ print('='*79)
diff --git a/testing/embedding/tlocal.py b/testing/embedding/tlocal.py
--- a/testing/embedding/tlocal.py
+++ b/testing/embedding/tlocal.py
@@ -25,4 +25,4 @@
""")
fn = ffi.compile(verbose=True)
-print 'FILENAME:', fn
+print('FILENAME: %s' % (fn,))
More information about the pypy-commit
mailing list