[libcamera-devel] [PATCH v2] meson: Define python3 and python3-yaml required dependencies

Ezequiel Garcia ezequiel at collabora.com
Wed Nov 20 12:45:49 CET 2019


With this change, meson will complain specifically about missing
python3 and missing python3-yaml. As specified by meson
documentation: https://mesonbuild.com/Python-module.html,
this change requires meson v0.51.

Signed-off-by: Ezequiel Garcia <ezequiel at collabora.com>
---
v2:
* Make it optional and rework how it's done.

 meson.build               | 15 +++++++++++++++
 src/libcamera/meson.build |  2 ++
 2 files changed, 17 insertions(+)

diff --git a/meson.build b/meson.build
index 72ad7c8b493b..b7cfbd072421 100644
--- a/meson.build
+++ b/meson.build
@@ -62,6 +62,11 @@ add_project_link_arguments(cpp_arguments, language : 'cpp')
 
 libcamera_includes = include_directories('include')
 
+# Sub-directories fill py_modules with their
+# dependencies.
+
+py_modules = []
+
 subdir('include')
 subdir('src')
 subdir('utils')
@@ -85,3 +90,13 @@ pkg_mod.generate(libraries : libcamera,
                  name : 'libcamera',
                  filebase : 'camera',
                  description : 'Complex Camera Support Library')
+
+# Check for python installation and modules.
+#
+# This feature requires v0.51, but since we don't
+# want to force users to upgrade to meson v0.51+,
+# let's do this optionally.
+if meson.version().version_compare('>=0.51')
+    py_mod = import('python')
+    py_mod.find_installation('python3', modules: py_modules)
+endif
diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
index afbca76968f9..02f5157b7975 100644
--- a/src/libcamera/meson.build
+++ b/src/libcamera/meson.build
@@ -61,6 +61,8 @@ if libudev.found()
     ])
 endif
 
+py_modules += ['yaml']
+
 gen_controls = files('gen-controls.py')
 
 control_ids_cpp = custom_target('control_ids_cpp',
-- 
2.22.0



More information about the libcamera-devel mailing list