[libcamera-devel,2/2] meson: Define python3 and python3-yaml required dependencies

Message ID 20191115152342.27723-2-ezequiel@collabora.com
State Accepted
Headers show
Series
  • [libcamera-devel,1/2] README: Simplify a bit the build instructions
Related show

Commit Message

Ezequiel Garcia Nov. 15, 2019, 3:23 p.m. UTC
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@collabora.com>
---
 meson.build               | 2 +-
 src/libcamera/meson.build | 3 +++
 2 files changed, 4 insertions(+), 1 deletion(-)

Comments

Laurent Pinchart Nov. 18, 2019, 12:26 a.m. UTC | #1
Hi Ezequiel,

Thank you for the patch.

On Fri, Nov 15, 2019 at 12:23:42PM -0300, Ezequiel Garcia wrote:
> 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.

Neither Debian stable nor Ubuntu stable ship meson v0.51 or newer, so I
think this is a too strict requirement. There are useful features in
newer meson verions, but we want to keep libcamera easily buildable on
common distributions.

> Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
> ---
>  meson.build               | 2 +-
>  src/libcamera/meson.build | 3 +++
>  2 files changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/meson.build b/meson.build
> index 72ad7c8b493b..38c0f1d55b56 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -1,5 +1,5 @@
>  project('libcamera', 'c', 'cpp',
> -    meson_version : '>= 0.40',
> +    meson_version : '>= 0.51',
>      version : '0.0.0',
>      default_options : [
>          'werror=true',
> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> index afbca76968f9..509499359cdb 100644
> --- a/src/libcamera/meson.build
> +++ b/src/libcamera/meson.build
> @@ -61,6 +61,9 @@ if libudev.found()
>      ])
>  endif
>  
> +py_mod = import('python')
> +py_inst = py_mod.find_installation('python3', modules: ['yaml'])
> +
>  gen_controls = files('gen-controls.py')
>  
>  control_ids_cpp = custom_target('control_ids_cpp',
Ezequiel Garcia Nov. 18, 2019, 12:14 p.m. UTC | #2
On Mon, 2019-11-18 at 02:26 +0200, Laurent Pinchart wrote:
> Hi Ezequiel,
> 
> Thank you for the patch.
> 
> On Fri, Nov 15, 2019 at 12:23:42PM -0300, Ezequiel Garcia wrote:
> > 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.
> 

How about this

+# meson v0.51 is too new and not distributed
+# by major distros. Let's take advantage of it
+# optionally.
+if meson.version().version_compare('>=0.51')
+    py_mod = import('python')
+    py_inst = py_mod.find_installation('python3', modules: ['yaml'])
+endif
+

?

Just to get the thing documented, we can drop the ifs
once libcamera requires meson 0.51

Thanks,
Eze

> Neither Debian stable nor Ubuntu stable ship meson v0.51 or newer, so I
> think this is a too strict requirement. There are useful features in
> newer meson verions, but we want to keep libcamera easily buildable on
> common distributions.
> 
> > Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
> > ---
> >  meson.build               | 2 +-
> >  src/libcamera/meson.build | 3 +++
> >  2 files changed, 4 insertions(+), 1 deletion(-)
> > 
> > diff --git a/meson.build b/meson.build
> > index 72ad7c8b493b..38c0f1d55b56 100644
> > --- a/meson.build
> > +++ b/meson.build
> > @@ -1,5 +1,5 @@
> >  project('libcamera', 'c', 'cpp',
> > -    meson_version : '>= 0.40',
> > +    meson_version : '>= 0.51',
> >      version : '0.0.0',
> >      default_options : [
> >          'werror=true',
> > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> > index afbca76968f9..509499359cdb 100644
> > --- a/src/libcamera/meson.build
> > +++ b/src/libcamera/meson.build
> > @@ -61,6 +61,9 @@ if libudev.found()
> >      ])
> >  endif
> >  
> > +py_mod = import('python')
> > +py_inst = py_mod.find_installation('python3', modules: ['yaml'])
> > +
> >  gen_controls = files('gen-controls.py')
> >  
> >  control_ids_cpp = custom_target('control_ids_cpp',
Laurent Pinchart Nov. 18, 2019, 6:54 p.m. UTC | #3
Hi Ezequiel,

On Mon, Nov 18, 2019 at 09:14:10AM -0300, Ezequiel Garcia wrote:
> On Mon, 2019-11-18 at 02:26 +0200, Laurent Pinchart wrote:
> > On Fri, Nov 15, 2019 at 12:23:42PM -0300, Ezequiel Garcia wrote:
> > > 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.
> 
> How about this
> 
> +# meson v0.51 is too new and not distributed
> +# by major distros. Let's take advantage of it
> +# optionally.
> +if meson.version().version_compare('>=0.51')
> +    py_mod = import('python')
> +    py_inst = py_mod.find_installation('python3', modules: ['yaml'])

Do you need to assign the return value to a variable ?

> +endif
> +
> 
> ?
> 
> Just to get the thing documented, we can drop the ifs
> once libcamera requires meson 0.51

That looks better to me, but should be conditioned to the documentation
option being enabled.

> > Neither Debian stable nor Ubuntu stable ship meson v0.51 or newer, so I
> > think this is a too strict requirement. There are useful features in
> > newer meson verions, but we want to keep libcamera easily buildable on
> > common distributions.
> > 
> > > Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
> > > ---
> > >  meson.build               | 2 +-
> > >  src/libcamera/meson.build | 3 +++
> > >  2 files changed, 4 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/meson.build b/meson.build
> > > index 72ad7c8b493b..38c0f1d55b56 100644
> > > --- a/meson.build
> > > +++ b/meson.build
> > > @@ -1,5 +1,5 @@
> > >  project('libcamera', 'c', 'cpp',
> > > -    meson_version : '>= 0.40',
> > > +    meson_version : '>= 0.51',
> > >      version : '0.0.0',
> > >      default_options : [
> > >          'werror=true',
> > > diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> > > index afbca76968f9..509499359cdb 100644
> > > --- a/src/libcamera/meson.build
> > > +++ b/src/libcamera/meson.build
> > > @@ -61,6 +61,9 @@ if libudev.found()
> > >      ])
> > >  endif
> > >  
> > > +py_mod = import('python')
> > > +py_inst = py_mod.find_installation('python3', modules: ['yaml'])
> > > +
> > >  gen_controls = files('gen-controls.py')
> > >  
> > >  control_ids_cpp = custom_target('control_ids_cpp',
Laurent Pinchart Nov. 18, 2019, 7:01 p.m. UTC | #4
Hi Ezequiel,

On Mon, Nov 18, 2019 at 08:54:43PM +0200, Laurent Pinchart wrote:
> On Mon, Nov 18, 2019 at 09:14:10AM -0300, Ezequiel Garcia wrote:
> > On Mon, 2019-11-18 at 02:26 +0200, Laurent Pinchart wrote:
> >> On Fri, Nov 15, 2019 at 12:23:42PM -0300, Ezequiel Garcia wrote:
> >>> 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.
> > 
> > How about this
> > 
> > +# meson v0.51 is too new and not distributed
> > +# by major distros. Let's take advantage of it
> > +# optionally.
> > +if meson.version().version_compare('>=0.51')
> > +    py_mod = import('python')
> > +    py_inst = py_mod.find_installation('python3', modules: ['yaml'])
> 
> Do you need to assign the return value to a variable ?
> 
> > +endif
> > +
> > 
> > ?
> > 
> > Just to get the thing documented, we can drop the ifs
> > once libcamera requires meson 0.51
> 
> That looks better to me, but should be conditioned to the documentation
> option being enabled.

Scratch this, I got it mixed in my head. This is unrelated to
documentation. Your proposal looks good. We may want to already prepare
for additional modules with something along the lines of

/meson.build:

# Towards the beginning

py_modules = []

...

# Towards the end

if meson.version().version_compare('>=0.51')
    py_mod = import('python')
    py_mod.find_installation('python3', modules: py_modules)
endif

/src/libcamera/meson.build:

...
py_modules += ['yaml']
...

but that could also be done later.

> >> Neither Debian stable nor Ubuntu stable ship meson v0.51 or newer, so I
> >> think this is a too strict requirement. There are useful features in
> >> newer meson verions, but we want to keep libcamera easily buildable on
> >> common distributions.
> >> 
> >>> Signed-off-by: Ezequiel Garcia <ezequiel@collabora.com>
> >>> ---
> >>>  meson.build               | 2 +-
> >>>  src/libcamera/meson.build | 3 +++
> >>>  2 files changed, 4 insertions(+), 1 deletion(-)
> >>> 
> >>> diff --git a/meson.build b/meson.build
> >>> index 72ad7c8b493b..38c0f1d55b56 100644
> >>> --- a/meson.build
> >>> +++ b/meson.build
> >>> @@ -1,5 +1,5 @@
> >>>  project('libcamera', 'c', 'cpp',
> >>> -    meson_version : '>= 0.40',
> >>> +    meson_version : '>= 0.51',
> >>>      version : '0.0.0',
> >>>      default_options : [
> >>>          'werror=true',
> >>> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> >>> index afbca76968f9..509499359cdb 100644
> >>> --- a/src/libcamera/meson.build
> >>> +++ b/src/libcamera/meson.build
> >>> @@ -61,6 +61,9 @@ if libudev.found()
> >>>      ])
> >>>  endif
> >>>  
> >>> +py_mod = import('python')
> >>> +py_inst = py_mod.find_installation('python3', modules: ['yaml'])
> >>> +
> >>>  gen_controls = files('gen-controls.py')
> >>>  
> >>>  control_ids_cpp = custom_target('control_ids_cpp',

Patch

diff --git a/meson.build b/meson.build
index 72ad7c8b493b..38c0f1d55b56 100644
--- a/meson.build
+++ b/meson.build
@@ -1,5 +1,5 @@ 
 project('libcamera', 'c', 'cpp',
-    meson_version : '>= 0.40',
+    meson_version : '>= 0.51',
     version : '0.0.0',
     default_options : [
         'werror=true',
diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
index afbca76968f9..509499359cdb 100644
--- a/src/libcamera/meson.build
+++ b/src/libcamera/meson.build
@@ -61,6 +61,9 @@  if libudev.found()
     ])
 endif
 
+py_mod = import('python')
+py_inst = py_mod.find_installation('python3', modules: ['yaml'])
+
 gen_controls = files('gen-controls.py')
 
 control_ids_cpp = custom_target('control_ids_cpp',