[libcamera-devel] build: Fix python dependency
diff mbox series

Message ID beec98c3ab67cb75851c1108f5c5eef29baa7f20.1660215299.git.nert.pinx@gmail.com
State New
Headers show
Series
  • [libcamera-devel] build: Fix python dependency
Related show

Commit Message

Martin Kletzander Aug. 11, 2022, 10:54 a.m. UTC
Building with pycamera fails due to dependency search for 'python3'.  Fix that
by using meson's python module which searches for the proper files and various
versions.

Signed-off-by: Martin Kletzander <nert.pinx@gmail.com>
---
 src/py/libcamera/meson.build | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Tomi Valkeinen Aug. 11, 2022, 2:11 p.m. UTC | #1
On 11/08/2022 13:54, Martin Kletzander via libcamera-devel wrote:
> Building with pycamera fails due to dependency search for 'python3'.  Fix that
> by using meson's python module which searches for the proper files and various
> versions.
> 
> Signed-off-by: Martin Kletzander <nert.pinx@gmail.com>
> ---
>   src/py/libcamera/meson.build | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build
> index eb8845388692..cf2e9395de38 100644
> --- a/src/py/libcamera/meson.build
> +++ b/src/py/libcamera/meson.build
> @@ -1,8 +1,9 @@
>   # SPDX-License-Identifier: CC0-1.0
>   
> -py3_dep = dependency('python3', required : get_option('pycamera'))
> +pymod = import('python')
> +py3 = pymod.find_installation('python3', required : get_option('pycamera'))
>   
> -if not py3_dep.found()
> +if not py3.found()
>       pycamera_enabled = false
>       subdir_done()
>   endif
> @@ -60,7 +61,7 @@ pycamera_sources += custom_target('py_gen_formats',
>   
>   pycamera_deps = [
>       libcamera_public,
> -    py3_dep,
> +    py3.dependency(),
>       pybind11_dep,
>   ]
>   
> @@ -71,7 +72,7 @@ pycamera_args = [
>       '-DLIBCAMERA_BASE_PRIVATE',
>   ]
>   
> -destdir = get_option('libdir') / ('python' + py3_dep.version()) / 'site-packages' / 'libcamera'
> +destdir = get_option('libdir') / ('python' + py3.language_version()) / 'site-packages' / 'libcamera'
>   
>   pycamera = shared_module('_libcamera',
>                            pycamera_sources,

There was a similar patch posted some time back:

https://lists.libcamera.org/pipermail/libcamera-devel/2022-May/030423.html

This doesn't work when cross-compiling.

  Tomi
Laurent Pinchart Aug. 11, 2022, 2:36 p.m. UTC | #2
On Thu, Aug 11, 2022 at 05:11:07PM +0300, Tomi Valkeinen via libcamera-devel wrote:
> On 11/08/2022 13:54, Martin Kletzander via libcamera-devel wrote:
> > Building with pycamera fails due to dependency search for 'python3'.  Fix that
> > by using meson's python module which searches for the proper files and various
> > versions.
> > 
> > Signed-off-by: Martin Kletzander <nert.pinx@gmail.com>
> > ---
> >   src/py/libcamera/meson.build | 9 +++++----
> >   1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build
> > index eb8845388692..cf2e9395de38 100644
> > --- a/src/py/libcamera/meson.build
> > +++ b/src/py/libcamera/meson.build
> > @@ -1,8 +1,9 @@
> >   # SPDX-License-Identifier: CC0-1.0
> >   
> > -py3_dep = dependency('python3', required : get_option('pycamera'))
> > +pymod = import('python')
> > +py3 = pymod.find_installation('python3', required : get_option('pycamera'))
> >   
> > -if not py3_dep.found()
> > +if not py3.found()
> >       pycamera_enabled = false
> >       subdir_done()
> >   endif
> > @@ -60,7 +61,7 @@ pycamera_sources += custom_target('py_gen_formats',
> >   
> >   pycamera_deps = [
> >       libcamera_public,
> > -    py3_dep,
> > +    py3.dependency(),
> >       pybind11_dep,
> >   ]
> >   
> > @@ -71,7 +72,7 @@ pycamera_args = [
> >       '-DLIBCAMERA_BASE_PRIVATE',
> >   ]
> >   
> > -destdir = get_option('libdir') / ('python' + py3_dep.version()) / 'site-packages' / 'libcamera'
> > +destdir = get_option('libdir') / ('python' + py3.language_version()) / 'site-packages' / 'libcamera'
> >   
> >   pycamera = shared_module('_libcamera',
> >                            pycamera_sources,
> 
> There was a similar patch posted some time back:
> 
> https://lists.libcamera.org/pipermail/libcamera-devel/2022-May/030423.html
> 
> This doesn't work when cross-compiling.

Tomi, would you be able to resume discussions with the meson developers
to see how this could be fixed ?
Martin Kletzander Aug. 11, 2022, 3:44 p.m. UTC | #3
On Thu, Aug 11, 2022 at 05:36:41PM +0300, Laurent Pinchart wrote:
>On Thu, Aug 11, 2022 at 05:11:07PM +0300, Tomi Valkeinen via libcamera-devel wrote:
>> On 11/08/2022 13:54, Martin Kletzander via libcamera-devel wrote:
>> > Building with pycamera fails due to dependency search for 'python3'.  Fix that
>> > by using meson's python module which searches for the proper files and various
>> > versions.
>> >
>> > Signed-off-by: Martin Kletzander <nert.pinx@gmail.com>
>> > ---
>> >   src/py/libcamera/meson.build | 9 +++++----
>> >   1 file changed, 5 insertions(+), 4 deletions(-)
>> >
>> > diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build
>> > index eb8845388692..cf2e9395de38 100644
>> > --- a/src/py/libcamera/meson.build
>> > +++ b/src/py/libcamera/meson.build
>> > @@ -1,8 +1,9 @@
>> >   # SPDX-License-Identifier: CC0-1.0
>> >
>> > -py3_dep = dependency('python3', required : get_option('pycamera'))
>> > +pymod = import('python')
>> > +py3 = pymod.find_installation('python3', required : get_option('pycamera'))
>> >
>> > -if not py3_dep.found()
>> > +if not py3.found()
>> >       pycamera_enabled = false
>> >       subdir_done()
>> >   endif
>> > @@ -60,7 +61,7 @@ pycamera_sources += custom_target('py_gen_formats',
>> >
>> >   pycamera_deps = [
>> >       libcamera_public,
>> > -    py3_dep,
>> > +    py3.dependency(),
>> >       pybind11_dep,
>> >   ]
>> >
>> > @@ -71,7 +72,7 @@ pycamera_args = [
>> >       '-DLIBCAMERA_BASE_PRIVATE',
>> >   ]
>> >
>> > -destdir = get_option('libdir') / ('python' + py3_dep.version()) / 'site-packages' / 'libcamera'
>> > +destdir = get_option('libdir') / ('python' + py3.language_version()) / 'site-packages' / 'libcamera'
>> >
>> >   pycamera = shared_module('_libcamera',
>> >                            pycamera_sources,
>>
>> There was a similar patch posted some time back:
>>
>> https://lists.libcamera.org/pipermail/libcamera-devel/2022-May/030423.html
>>

Oh, sorry for missing that.  I just started looking into libcamera and this was
the first thing I found when I wanted to build with pycamera.  I guess

>> This doesn't work when cross-compiling.
>
>Tomi, would you be able to resume discussions with the meson developers
>to see how this could be fixed ?
>

I guess this could be worked around in the meson file, but since pycamera
support is experimental I guess you want a cleaner solution and don't have to
work around it for now.  I'll see what can be done with meson.

Have a nice day,
Martin
Laurent Pinchart Aug. 19, 2022, 1:39 a.m. UTC | #4
Hi Martin,

On Thu, Aug 11, 2022 at 05:44:42PM +0200, Martin Kletzander wrote:
> On Thu, Aug 11, 2022 at 05:36:41PM +0300, Laurent Pinchart wrote:
> >On Thu, Aug 11, 2022 at 05:11:07PM +0300, Tomi Valkeinen via libcamera-devel wrote:
> >> On 11/08/2022 13:54, Martin Kletzander via libcamera-devel wrote:
> >> > Building with pycamera fails due to dependency search for 'python3'.  Fix that
> >> > by using meson's python module which searches for the proper files and various
> >> > versions.
> >> >
> >> > Signed-off-by: Martin Kletzander <nert.pinx@gmail.com>
> >> > ---
> >> >   src/py/libcamera/meson.build | 9 +++++----
> >> >   1 file changed, 5 insertions(+), 4 deletions(-)
> >> >
> >> > diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build
> >> > index eb8845388692..cf2e9395de38 100644
> >> > --- a/src/py/libcamera/meson.build
> >> > +++ b/src/py/libcamera/meson.build
> >> > @@ -1,8 +1,9 @@
> >> >   # SPDX-License-Identifier: CC0-1.0
> >> >
> >> > -py3_dep = dependency('python3', required : get_option('pycamera'))
> >> > +pymod = import('python')
> >> > +py3 = pymod.find_installation('python3', required : get_option('pycamera'))
> >> >
> >> > -if not py3_dep.found()
> >> > +if not py3.found()
> >> >       pycamera_enabled = false
> >> >       subdir_done()
> >> >   endif
> >> > @@ -60,7 +61,7 @@ pycamera_sources += custom_target('py_gen_formats',
> >> >
> >> >   pycamera_deps = [
> >> >       libcamera_public,
> >> > -    py3_dep,
> >> > +    py3.dependency(),
> >> >       pybind11_dep,
> >> >   ]
> >> >
> >> > @@ -71,7 +72,7 @@ pycamera_args = [
> >> >       '-DLIBCAMERA_BASE_PRIVATE',
> >> >   ]
> >> >
> >> > -destdir = get_option('libdir') / ('python' + py3_dep.version()) / 'site-packages' / 'libcamera'
> >> > +destdir = get_option('libdir') / ('python' + py3.language_version()) / 'site-packages' / 'libcamera'
> >> >
> >> >   pycamera = shared_module('_libcamera',
> >> >                            pycamera_sources,
> >>
> >> There was a similar patch posted some time back:
> >>
> >> https://lists.libcamera.org/pipermail/libcamera-devel/2022-May/030423.html
> 
> Oh, sorry for missing that.  I just started looking into libcamera and this was
> the first thing I found when I wanted to build with pycamera.  I guess
> 
> >> This doesn't work when cross-compiling.
> >
> > Tomi, would you be able to resume discussions with the meson developers
> > to see how this could be fixed ?
> 
> I guess this could be worked around in the meson file, but since pycamera
> support is experimental I guess you want a cleaner solution and don't have to
> work around it for now.  I'll see what can be done with meson.

Workarounds are OK if no clean solution is possible, but if you could
check with the meson developers (they've been very supportive so far),
that would be great.

Patch
diff mbox series

diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build
index eb8845388692..cf2e9395de38 100644
--- a/src/py/libcamera/meson.build
+++ b/src/py/libcamera/meson.build
@@ -1,8 +1,9 @@ 
 # SPDX-License-Identifier: CC0-1.0
 
-py3_dep = dependency('python3', required : get_option('pycamera'))
+pymod = import('python')
+py3 = pymod.find_installation('python3', required : get_option('pycamera'))
 
-if not py3_dep.found()
+if not py3.found()
     pycamera_enabled = false
     subdir_done()
 endif
@@ -60,7 +61,7 @@  pycamera_sources += custom_target('py_gen_formats',
 
 pycamera_deps = [
     libcamera_public,
-    py3_dep,
+    py3.dependency(),
     pybind11_dep,
 ]
 
@@ -71,7 +72,7 @@  pycamera_args = [
     '-DLIBCAMERA_BASE_PRIVATE',
 ]
 
-destdir = get_option('libdir') / ('python' + py3_dep.version()) / 'site-packages' / 'libcamera'
+destdir = get_option('libdir') / ('python' + py3.language_version()) / 'site-packages' / 'libcamera'
 
 pycamera = shared_module('_libcamera',
                          pycamera_sources,