Debian Codegraph @

test cases/python/12 rust extmodule/meson.build

raw
1 project('Python extension module', 'c',
2 default_options : ['buildtype=release', 'python.bytecompile=-1'])
3 # Because Windows Python ships only with optimized libs,
4 # we must build this project the same way.
5
6 if meson.backend() != 'ninja'
7 error('MESON_SKIP_TEST: Ninja backend required')
8 endif
9 if not add_languages('rust', required: false, native: false)
10 error('MESON_SKIP_TEST: Rust compiler required')
11 endif
12
13 py_mod = import('python')
14 py = py_mod.find_installation()
15 py_dep = py.dependency(required: false)
16
17 if not py_dep.found()
18 error('MESON_SKIP_TEST: Python libraries not found.')
19 endif
20
21 # Rust code cannot rely on #define PyModule_Create, so it calls
22 # PyModule_Create2. But it is also not possible to use has_function()
23 # because the function is in the Python executable, so just check
24 # for PyPy.
25 if run_command(py, '-c', 'import sys; sys.exit("__pypy__" in sys.builtin_module_names)',
26 check: false).returncode() == 1
27 error('MESON_SKIP_TEST: Limited API not supported (PyPy?)')
28 endif
29
30 subdir('ext')
31
32 src = files('blaster.py')
33 test('extmod',
34 py,
35 args : src,
36 env : ['PYTHONPATH=' + pypathdir])