[libcamera-devel] [PATCH] py: Use Meson python module
Chris Mayo
aklhfex at gmail.com
Sun May 15 19:02:53 CEST 2022
Detection with dependency('python3') can fail because not all
distributions install python-3.pc. Installation is invalid if
site-packages is not below get_option('libdir').
Signed-off-by: Chris Mayo <aklhfex at gmail.com>
---
src/py/libcamera/meson.build | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)
diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build
index 0cd7c75b..130c1be6 100644
--- a/src/py/libcamera/meson.build
+++ b/src/py/libcamera/meson.build
@@ -1,6 +1,8 @@
# SPDX-License-Identifier: CC0-1.0
-py3_dep = dependency('python3', required : get_option('pycamera'))
+pymod = import('python')
+py3 = pymod.find_installation('python3')
+py3_dep = py3.dependency(required : get_option('pycamera'))
if not py3_dep.found()
pycamera_enabled = false
@@ -44,21 +46,16 @@ pycamera_args = [
'-DLIBCAMERA_BASE_PRIVATE',
]
-destdir = get_option('libdir') / ('python' + py3_dep.version()) / 'site-packages' / 'libcamera'
+py3.extension_module('_libcamera',
+ pycamera_sources,
+ install : true,
+ dependencies : pycamera_deps,
+ cpp_args : pycamera_args,
+ subdir : 'libcamera')
-pycamera = shared_module('_libcamera',
- pycamera_sources,
- install : true,
- install_dir : destdir,
- name_prefix : '',
- dependencies : pycamera_deps,
- cpp_args : pycamera_args)
-
-run_command('ln', '-fsT', '../../../../src/py/libcamera/__init__.py',
- meson.current_build_dir() / '__init__.py',
- check: true)
-
-install_data(['__init__.py'], install_dir : destdir)
+py3.install_sources('__init__.py',
+ pure : false,
+ subdir : 'libcamera')
# \todo Generate stubs when building. See https://peps.python.org/pep-0484/#stub-files
# Note: Depends on pybind11-stubgen. To generate pylibcamera stubs:
--
2.35.1
More information about the libcamera-devel
mailing list