python_libs=python.instance().libs
features |= runpath(src.bpl.path, base='')
-def extension_test(name, ext=[], script=None, np=False,
+def extension_test(name, exts=[], script=None, numpy=False,
features=features, condition=None):
"""Create a Python extension test `name`.
Arguments:
* name: the name of the test.
- * ext: extensions to be compiled, <name> if none are given.
+ * exts: extensions to be compiled, <name> if none are given.
* script: the test script to execute, <name>.py if none is given.
- * np: if true, add boost_numpy to sources
+ * numpy: if true, add boost_numpy to sources
* features: pre-defined features
* condition: any condition under which to run the test
Return:
features=features.copy()
extensions = []
- libs = [src.bnl, src.bpl] if np else [src.bpl]
- for e in ext or [name]:
- if type(e) is str: # build from a single source file
- n = e if e != name else e + '_ext'
- s = [e + '.cpp']
+ libs = [src.bnl, src.bpl] if numpy else [src.bpl]
+ for ext in exts or [name]:
+ if type(ext) is str: # build from a single source file
+ ext_name = ext if ext != name else ext + '_ext'
+ sources = [ext + '.cpp']
else: # build from a list of source files
- n = e[0] if e[0] != name else e[0] + '_ext'
- s = [n + '.cpp' for n in e]
- e = extension(n, s + libs, features=features)
- features |= pythonpath(e.path, base='')
- extensions.append(e)
+ ext_name = ext[0] if ext[0] != name else ext[0] + '_ext'
+ sources = [source + '.cpp' for source in ext]
+ ext = extension(ext_name, sources + libs, features=features)
+ features |= pythonpath(ext.path, base='')
+ extensions.append(ext)
if not script:
script = name+'.py'
return test(name, script, run=python.run, dependencies=extensions,
import_ = binary('import_', ['import_.cpp', src.bpl], features=features|python_libs)
if platform.os == 'Windows':
command = """set PATH=$(runpath);%PATH%
-$(>[1]) $(>[2])"""
+$(>[0]) $(>[1])"""
else:
- command = 'LD_LIBRARY_PATH=$(runpath) $(>[1]) $(>[2])'
+ command = 'LD_LIBRARY_PATH=$(runpath) $(>[0]) $(>[1])'
tests.append(test('import', [import_, 'import_.py'],
run=action('run', command),
'numpy/ndarray',
'numpy/indexing',
'numpy/shapes']:
- tests.append(extension_test(t, np=True,
+ tests.append(extension_test(t, numpy=True,
condition=set.define.contains('HAS_NUMPY')))
default = report('report', tests, fail_on_failures=True)