From d54e5537ca0909339bb6950f3a565c9077406a3c Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Mon, 18 Aug 2025 23:19:48 +0300 Subject: [PATCH] py: libcamera: Always use install path from meson python module libcamera uses the meson python module to handle native compilation of Python extension modules, and uses the shared_module() function when cross-compiling due to an issue in the python module. The difference between native and cross compilation also extends to the installation path: native compilation lets the python module handle the paths, while cross compilation constructs a path manually using a heuristic based on the Python version and hardcoded components. This manually-constructed installation path is problematic for cross compilation for the same reason it caused issue when used for native compilation: it is not guaranteed to be right, and it can't be overridden by users. Switch to obtaining the installation path from the meson python module for cross-compilation as well. This also prepares for usage of py.extension_module() once the file suffix issue will be fixed in meson. On Debian 13, this change replaces the incorrect path /usr/local/lib/python3.12/site-packages/libcamera with the still (but differently) incorrect /usr/local/lib/python3/dist-packages/libcamera. Future fixes in meson to address this issue will make the path correct by default. When the path calculated by the python module is not correct, it can now be overridden by the user through the meson python.platlibdir configuration variable. Signed-off-by: Laurent Pinchart Reviewed-by: Tomi Valkeinen --- src/py/libcamera/meson.build | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build index d5433fbc..b0bd291f 100644 --- a/src/py/libcamera/meson.build +++ b/src/py/libcamera/meson.build @@ -62,7 +62,7 @@ if meson.is_cross_build() # module. There's work in progress to fix this, based on PEP 739 # (https://github.com/mesonbuild/meson/pull/14657). While waiting for this # to become available, work around the issue by using shared_module(). - destdir = get_option('libdir') / ('python' + py3.language_version()) / 'site-packages' / 'libcamera' + destdir = py3.get_install_dir(subdir : 'libcamera', pure : false) pycamera = shared_module('_libcamera', pycamera_sources, @@ -72,9 +72,6 @@ if meson.is_cross_build() name_prefix : '', dependencies : pycamera_deps, cpp_args : pycamera_args) - install_data(['__init__.py'], - install_dir : destdir, - install_tag : 'python-runtime') else pycamera = py3.extension_module('_libcamera', pycamera_sources, @@ -82,11 +79,12 @@ else subdir : 'libcamera', dependencies : pycamera_deps, cpp_args : pycamera_args) - py3.install_sources(['__init__.py'], - subdir : 'libcamera', - pure : false) endif +py3.install_sources(['__init__.py'], + subdir : 'libcamera', + pure : false) + # Create symlinks from the build dir to the source dir so that we can use the # Python module directly from the build dir.