[libcamera-devel] [PATCH] meson: import python3 to use also from sysroot

Laurent Pinchart laurent.pinchart at ideasonboard.com
Sat Jan 11 03:08:57 CET 2020


Hi Madhavan,

Thank you for the patch.

On Fri, Jan 10, 2020 at 01:41:43PM +0100, madhavan.krishnan at linaro.org wrote:
> From: Madhavan Krishnan <madhavan.krishnan at linaro.org>
> 
> importing python module can provide the exact path
> which can be used in desktop build as well as from
> any build system
> ---
>  include/libcamera/meson.build | 4 +++-
>  src/libcamera/meson.build     | 4 +++-
>  2 files changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build
> index 99abf06..83525e2 100644
> --- a/include/libcamera/meson.build
> +++ b/include/libcamera/meson.build
> @@ -21,13 +21,15 @@ include_dir = join_paths(libcamera_include_dir, 'libcamera')
>  install_headers(libcamera_api,
>                  subdir : include_dir)
>  
> +python_mod = import('python3').find_python()
> +

Strictly speaking, the return value of find_python() isn't a module but
an external_program object. I would thus rename python_mod to python.

Furthermore, as python is used in multiple directories, I think we
should get the python installation in the top-level meson.build file
instead of duplicating here and in src/libcamera/meson.build. You can do
so right after the add_project_link_arguments() call there.

Finally, the python3 module is deprecated and replaced with the python
module in meson 0.46. We're currently based on meson 0.41, so we should
keep using the python3 module, but we will soon bump the minimum
required version to 0.47. I will then update this to use the new python
module. Not change is required now.

The rest of the patch looks good to me. Could you submit a v2 with the
above modifications ?

>  gen_controls = files('../../src/libcamera/gen-controls.py')
>  
>  control_ids_h = custom_target('control_ids_h',
>                                input : files('../../src/libcamera/control_ids.yaml', 'control_ids.h.in'),
>                                output : 'control_ids.h',
>                                depend_files : gen_controls,
> -                              command : [gen_controls, '-o', '@OUTPUT@', '@INPUT@'],
> +                              command : [python_mod, gen_controls, '-o', '@OUTPUT@', '@INPUT@'],
>                                install : true,
>                                install_dir : join_paths('include', include_dir))
>  
> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> index c4f965b..243935b 100644
> --- a/src/libcamera/meson.build
> +++ b/src/libcamera/meson.build
> @@ -65,13 +65,15 @@ if libudev.found()
>      ])
>  endif
>  
> +python_mod = import('python3').find_python()
> +
>  gen_controls = files('gen-controls.py')
>  
>  control_ids_cpp = custom_target('control_ids_cpp',
>                                  input : files('control_ids.yaml', 'control_ids.cpp.in'),
>                                  output : 'control_ids.cpp',
>                                  depend_files : gen_controls,
> -                                command : [gen_controls, '-o', '@OUTPUT@', '@INPUT@'])
> +                                command : [python_mod, gen_controls, '-o', '@OUTPUT@', '@INPUT@'])
>  
>  libcamera_sources += control_ids_cpp
>  libcamera_sources += control_ids_h

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list