[libcamera-devel] [PATCH] py: libcamera: Improve python binding installation

Tomi Valkeinen tomi.valkeinen at ideasonboard.com
Thu Oct 26 07:39:25 CEST 2023


On 25/10/2023 14:04, Laurent Pinchart wrote:
> Hi William,
> 
> (CC'ing Tomi)
> 
> Thank you for the patch.
> 
> On Wed, Oct 25, 2023 at 10:36:49AM +0100, William Vinnicombe via libcamera-devel wrote:
>> The existing meson.build file installs the bindings to an architecture
>> specific libdir (eg /usr/local/lib/aarch64-linux-gnu/), which is not
>> picked up by default python which only looks in the non architecture
>> specific libdir (eg /usr/local/lib/python3.11/). It also will always
>> build using the system python, rather than building using the same
>> python as meson is using. This prevents a user being able to build the
>> bindings for a different version of python, without changing their
>> system python to that version.
>>
>> Modify the build process to use the meson Python module to build the
>> python bindings targets, so it installs them to the correct directories
>> for python, and builds them for the version of python that meson is
>> running with.
>>
>> Signed-off-by: William Vinnicombe <william.vinnicombe at raspberrypi.com>
>> ---
>>   src/py/libcamera/meson.build | 23 ++++++++++++-----------
>>   1 file changed, 12 insertions(+), 11 deletions(-)
>>
>> diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build
>> index f58c7198..e9e3f915 100644
>> --- a/src/py/libcamera/meson.build
>> +++ b/src/py/libcamera/meson.build
>> @@ -1,6 +1,8 @@
>>   # SPDX-License-Identifier: CC0-1.0
>>   
>> -py3_dep = dependency('python3', required : get_option('pycamera'))
>> +
>> +py = import('python').find_installation('python3', required : get_option('pycamera'))
>> +py3_dep = py.dependency(required : get_option('pycamera'))
> 
> Does this still work when cross-compiling ? I recall we tried the meson
> python module, and it had problems with cross-compilation. Tomi may know
> more.

Right. When cross-compiling, you don't want that "[the build process] 
builds them for the version of python that meson is running with", as 
meson is running (for me) in x86 environment, but the target is arm.

I'm not sure if there's been any work on fixing all that in the meson 
side, but the last time I talked to them they didn't have any clear 
ideas how to fix it.

Perhaps this can be solved by manually dealing with all the python 
details in the meson.build file, and adding a meson option so that the 
user can tell which python to use.

  Tomi



More information about the libcamera-devel mailing list