The existing meson.build file installs the bindings to a manually constructed directory that is not included in the Python path in most distributions. For instance, on a Debian 12 system, the modules is intalled in /usr/lib/x86_64-linux-gnu/python3.11/site-packages/, while the Python interpreter looks for site packages in /usr/lib/python3/dist-packages/. It also always builds the bindings using the system Python, as it searches for the Python library using the standard dependency() function. This prevents build the Python bindings for a different interpreter version without changing the system default interpreter. Modify the build process to use the meson python module to build the Python bindings targets, so it installs them to the correct directories for Python. This also allows specifying a different target Python interpreter through the '[binaries]' section of a meson native file. The behaviour is not changed for cross-compilation, as the meson python module has known issues in that case. Signed-off-by: William Vinnicombe <william.vinnicombe@raspberrypi.com> Co-developed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
40 lines
1.1 KiB
Meson
40 lines
1.1 KiB
Meson
# SPDX-License-Identifier: CC0-1.0
|
|
|
|
if not pycamera_enabled
|
|
subdir_done()
|
|
endif
|
|
|
|
# If ASan is enabled, the link order runtime check will fail as Python is not
|
|
# linked to ASan. LD_PRELOAD the ASan runtime if available, or skip the test
|
|
# otherwise.
|
|
|
|
if asan_runtime_missing
|
|
warning('Unable to get path to ASan runtime, Python test disabled')
|
|
subdir_done()
|
|
endif
|
|
|
|
py_env = environment()
|
|
|
|
pypathdir = meson.project_build_root() / 'src' / 'py'
|
|
py_env.append('PYTHONPATH', pypathdir)
|
|
|
|
if asan_enabled
|
|
py_env.append('LD_PRELOAD', asan_runtime)
|
|
|
|
# Preload the C++ standard library to work around a bug in ASan when
|
|
# dynamically loading C++ .so modules.
|
|
stdlib = run_command(cxx, '-print-file-name=' + cxx_stdlib + '.so',
|
|
check : true).stdout().strip()
|
|
py_env.append('LD_PRELOAD', stdlib)
|
|
|
|
# Disable leak detection as the Python interpreter is full of leaks.
|
|
py_env.append('ASAN_OPTIONS', 'detect_leaks=0')
|
|
endif
|
|
|
|
test('pyunittests',
|
|
py3,
|
|
args : files('unittests.py'),
|
|
env : py_env,
|
|
suite : 'pybindings',
|
|
is_parallel : false)
|