[libcamera-devel] [PATCH] py: Fix CameraManager.version property

Laurent Pinchart laurent.pinchart at ideasonboard.com
Wed Apr 5 06:53:09 CEST 2023


On Wed, Apr 05, 2023 at 07:51:03AM +0300, Laurent Pinchart via libcamera-devel wrote:
> Hi Tomi,
> 
> Thank you for the patch.
> 
> On Thu, Mar 30, 2023 at 08:39:56PM +0300, Tomi Valkeinen via libcamera-devel wrote:
> > The current CameraManager.version doesn't work at all (raises a
> > TypeError), as that's not how you use expose C++ static methods as
> > Python class methods.
> > 
> > Fix it.
> > 
> > Signed-off-by: Tomi Valkeinen <tomi.valkeinen at ideasonboard.com>
> > Reported-by: @meawoppl:matrix.org
> 
> We can't include people without an e-mail address into the conversation,
> defeating the point of the Reported-by tag a bit. I'm inclined to drop
> it.
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

Also, could you extend the python bindings unit test to access
CameraManager.verion ?

> > ---
> >  src/py/libcamera/py_main.cpp | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/src/py/libcamera/py_main.cpp b/src/py/libcamera/py_main.cpp
> > index d14e18e2..c55495cc 100644
> > --- a/src/py/libcamera/py_main.cpp
> > +++ b/src/py/libcamera/py_main.cpp
> > @@ -105,7 +105,7 @@ PYBIND11_MODULE(_libcamera, m)
> >  			return cm;
> >  		})
> >  
> > -		.def_property_readonly("version", &PyCameraManager::version)
> > +		.def_property_readonly_static("version", [](py::object /* self */) { return PyCameraManager::version(); })
> >  		.def("get", &PyCameraManager::get, py::keep_alive<0, 1>())
> >  		.def_property_readonly("cameras", &PyCameraManager::cameras)
> >  

-- 
Regards,

Laurent Pinchart


More information about the libcamera-devel mailing list