<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, 26 Oct 2023 at 11:18, Tomi Valkeinen <<a href="mailto:tomi.valkeinen@ideasonboard.com" target="_blank">tomi.valkeinen@ideasonboard.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 26/10/2023 13:15, William Vinnicombe wrote:<br>
> Hi both,<br>
> <br>
> Thanks for your comments - I hadn't considered cross compilation, but <br>
> from looking into it I can see that this change would cause the problems <br>
> you've mentioned. Would it be an acceptable solution to wrap these <br>
> changes within "if meson.is_cross_build() else ..." so that cross <br>
> compilation uses the previous code still, but native compilation uses <br>
> the meson python module? If so, I'll submit a v2 with those changes.<br>
<br>
I don't see why not, presuming it works =). Do you have a <br>
cross-compilation environment (e.g. buildroot) for testing?<br></blockquote><div><br></div><div>I have tested my v2 with buildroot and it seems to be working as expected, so I'll push that to the mailing list now. Although probably worth someone else testing it too, as I don't have much experience with cross-compiling.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
  Tomi<br>
<br>
> <br>
> Thanks,<br>
> <br>
> William<br>
> <br>
> On Thu, 26 Oct 2023 at 06:39, Tomi Valkeinen <br>
> <<a href="mailto:tomi.valkeinen@ideasonboard.com" target="_blank">tomi.valkeinen@ideasonboard.com</a> <br>
> <mailto:<a href="mailto:tomi.valkeinen@ideasonboard.com" target="_blank">tomi.valkeinen@ideasonboard.com</a>>> wrote:<br>
> <br>
>     On 25/10/2023 14:04, Laurent Pinchart wrote:<br>
>      > Hi William,<br>
>      ><br>
>      > (CC'ing Tomi)<br>
>      ><br>
>      > Thank you for the patch.<br>
>      ><br>
>      > On Wed, Oct 25, 2023 at 10:36:49AM +0100, William Vinnicombe via<br>
>     libcamera-devel wrote:<br>
>      >> The existing meson.build file installs the bindings to an<br>
>     architecture<br>
>      >> specific libdir (eg /usr/local/lib/aarch64-linux-gnu/), which is not<br>
>      >> picked up by default python which only looks in the non architecture<br>
>      >> specific libdir (eg /usr/local/lib/python3.11/). It also will always<br>
>      >> build using the system python, rather than building using the same<br>
>      >> python as meson is using. This prevents a user being able to<br>
>     build the<br>
>      >> bindings for a different version of python, without changing their<br>
>      >> system python to that version.<br>
>      >><br>
>      >> Modify the build process to use the meson Python module to build the<br>
>      >> python bindings targets, so it installs them to the correct<br>
>     directories<br>
>      >> for python, and builds them for the version of python that meson is<br>
>      >> running with.<br>
>      >><br>
>      >> Signed-off-by: William Vinnicombe<br>
>     <<a href="mailto:william.vinnicombe@raspberrypi.com" target="_blank">william.vinnicombe@raspberrypi.com</a><br>
>     <mailto:<a href="mailto:william.vinnicombe@raspberrypi.com" target="_blank">william.vinnicombe@raspberrypi.com</a>>><br>
>      >> ---<br>
>      >>   src/py/libcamera/meson.build | 23 ++++++++++++-----------<br>
>      >>   1 file changed, 12 insertions(+), 11 deletions(-)<br>
>      >><br>
>      >> diff --git a/src/py/libcamera/meson.build<br>
>     b/src/py/libcamera/meson.build<br>
>      >> index f58c7198..e9e3f915 100644<br>
>      >> --- a/src/py/libcamera/meson.build<br>
>      >> +++ b/src/py/libcamera/meson.build<br>
>      >> @@ -1,6 +1,8 @@<br>
>      >>   # SPDX-License-Identifier: CC0-1.0<br>
>      >><br>
>      >> -py3_dep = dependency('python3', required : get_option('pycamera'))<br>
>      >> +<br>
>      >> +py = import('python').find_installation('python3', required :<br>
>     get_option('pycamera'))<br>
>      >> +py3_dep = py.dependency(required : get_option('pycamera'))<br>
>      ><br>
>      > Does this still work when cross-compiling ? I recall we tried the<br>
>     meson<br>
>      > python module, and it had problems with cross-compilation. Tomi<br>
>     may know<br>
>      > more.<br>
> <br>
>     Right. When cross-compiling, you don't want that "[the build process]<br>
>     builds them for the version of python that meson is running with", as<br>
>     meson is running (for me) in x86 environment, but the target is arm.<br>
> <br>
>     I'm not sure if there's been any work on fixing all that in the meson<br>
>     side, but the last time I talked to them they didn't have any clear<br>
>     ideas how to fix it.<br>
> <br>
>     Perhaps this can be solved by manually dealing with all the python<br>
>     details in the meson.build file, and adding a meson option so that the<br>
>     user can tell which python to use.<br>
> <br>
>        Tomi<br>
> <br>
<br>
</blockquote></div></div>