Message ID | 20220516141022.96327-3-tomi.valkeinen@ideasonboard.com |
---|---|
State | Superseded |
Headers | show |
Series |
|
Related | show |
Hi Tomi, Thank you for the patch. On Mon, May 16, 2022 at 05:10:10PM +0300, Tomi Valkeinen wrote: > Add a 'pystubs' build target for building the python stubs. > > For now this needs to be ran manually. I didn't figure out how to > generate the stubs after the libcamera bindings are built. What did you try ? custom_target() seems to be the right function for this, did it fail ? > Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> > --- > src/py/libcamera/meson.build | 14 +++++++++++++- > 1 file changed, 13 insertions(+), 1 deletion(-) > > diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build > index 38f619d0..fbd33139 100644 > --- a/src/py/libcamera/meson.build > +++ b/src/py/libcamera/meson.build > @@ -60,6 +60,18 @@ run_command('ln', '-fsT', '../../../../src/py/libcamera/__init__.py', > > install_data(['__init__.py'], install_dir : destdir) > > -# \todo Generate stubs when building. See https://peps.python.org/pep-0484/#stub-files > +# \todo Generate stubs when building, and install them. > +# See https://peps.python.org/pep-0484/#stub-files > # Note: Depends on pybind11-stubgen. To generate pylibcamera stubs: > # $ PYTHONPATH=build/src/py pybind11-stubgen --no-setup-py -o build/src/py libcamera > +# The target below can be ran manually, but how to create a meson target that > +# is run if pycamera is built? > + > +stubgen = find_program('pybind11-stubgen', required : false) > + > +if stubgen.found() > + run_target('pystubs', > + depends: pycamera, > + env: {'PYTHONPATH': meson.project_build_root() / 'src/py'}, > + command : [stubgen, '--no-setup-py', '-o', meson.project_build_root() / 'src/py', 'libcamera']) Extra space after ':'. 'src/py' should be 'src' / 'py'. > +endif
On 17/05/2022 11:15, Laurent Pinchart wrote: > Hi Tomi, > > Thank you for the patch. > > On Mon, May 16, 2022 at 05:10:10PM +0300, Tomi Valkeinen wrote: >> Add a 'pystubs' build target for building the python stubs. >> >> For now this needs to be ran manually. I didn't figure out how to >> generate the stubs after the libcamera bindings are built. > > What did you try ? custom_target() seems to be the right function for > this, did it fail ? custom_target() needs a list of output files, which is not obvious here, and it also expects the outputs to be in the build dir of this source directory, which is also not the case. Tomi
diff --git a/src/py/libcamera/meson.build b/src/py/libcamera/meson.build index 38f619d0..fbd33139 100644 --- a/src/py/libcamera/meson.build +++ b/src/py/libcamera/meson.build @@ -60,6 +60,18 @@ run_command('ln', '-fsT', '../../../../src/py/libcamera/__init__.py', install_data(['__init__.py'], install_dir : destdir) -# \todo Generate stubs when building. See https://peps.python.org/pep-0484/#stub-files +# \todo Generate stubs when building, and install them. +# See https://peps.python.org/pep-0484/#stub-files # Note: Depends on pybind11-stubgen. To generate pylibcamera stubs: # $ PYTHONPATH=build/src/py pybind11-stubgen --no-setup-py -o build/src/py libcamera +# The target below can be ran manually, but how to create a meson target that +# is run if pycamera is built? + +stubgen = find_program('pybind11-stubgen', required : false) + +if stubgen.found() + run_target('pystubs', + depends: pycamera, + env: {'PYTHONPATH': meson.project_build_root() / 'src/py'}, + command : [stubgen, '--no-setup-py', '-o', meson.project_build_root() / 'src/py', 'libcamera']) +endif
Add a 'pystubs' build target for building the python stubs. For now this needs to be ran manually. I didn't figure out how to generate the stubs after the libcamera bindings are built. Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> --- src/py/libcamera/meson.build | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-)