[libcamera-devel,RFC,1/4] Add pybind11 submodule

Message ID 20200918152019.784315-2-tomi.valkeinen@iki.fi
State Superseded
Headers show
Series
  • prototype python bindings
Related show

Commit Message

Tomi Valkeinen Sept. 18, 2020, 3:20 p.m. UTC
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
---
 .gitmodules  | 3 +++
 ext/pybind11 | 1 +
 2 files changed, 4 insertions(+)
 create mode 100644 .gitmodules
 create mode 160000 ext/pybind11

Comments

Kieran Bingham Sept. 18, 2020, 3:33 p.m. UTC | #1
Hi Tomi,

Thank you very much for your work on python bindings, this is very exciting.


On 18/09/2020 16:20, Tomi Valkeinen wrote:
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>

I haven't had chance to go through everything yet, but for pulling in
the pybind11 dependency, I suspect this should be handled through the
meson dependecy/wrap framework.

	https://mesonbuild.com/Wrap-dependency-system-manual.html

I've never used it, so I'm not quite sure how that works yet - but I
don't think we should expect users to have to wrangle the git submodules
themselves before starting a build.

--
Kieran



> ---
>  .gitmodules  | 3 +++
>  ext/pybind11 | 1 +
>  2 files changed, 4 insertions(+)
>  create mode 100644 .gitmodules
>  create mode 160000 ext/pybind11
> 
> diff --git a/.gitmodules b/.gitmodules
> new file mode 100644
> index 0000000..c6d1083
> --- /dev/null
> +++ b/.gitmodules
> @@ -0,0 +1,3 @@
> +[submodule "ext/pybind11"]
> +	path = ext/pybind11
> +	url = https://github.com/pybind/pybind11.git
> diff --git a/ext/pybind11 b/ext/pybind11
> new file mode 160000
> index 0000000..3b1dbeb
> --- /dev/null
> +++ b/ext/pybind11
> @@ -0,0 +1 @@
> +Subproject commit 3b1dbebabc801c9cf6f0953a4c20b904d444f879
>
Kieran Bingham Sept. 18, 2020, 3:38 p.m. UTC | #2
Hello again,

On 18/09/2020 16:33, Kieran Bingham wrote:
> Hi Tomi,
> 
> Thank you very much for your work on python bindings, this is very exciting.
> 
> 
> On 18/09/2020 16:20, Tomi Valkeinen wrote:
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
> 
> I haven't had chance to go through everything yet, but for pulling in
> the pybind11 dependency, I suspect this should be handled through the
> meson dependecy/wrap framework.
> 
> 	https://mesonbuild.com/Wrap-dependency-system-manual.html
> 
> I've never used it, so I'm not quite sure how that works yet - but I
> don't think we should expect users to have to wrangle the git submodules
> themselves before starting a build.
> 

There appears to be a somewhat officialish pybind11 'wrap' here:
https://github.com/mesonbuild/pybind11/blob/2.3.0/upstream.wrap

Although,

https://github.com/mesonbuild/meson/issues/4677#issuecomment-457949493

Implies that it can be handled natively through the meson build
system/python integrations ... Not sure I understood the right path yet:

> project('pybindtest', 'cpp', default_options : ['cpp_std=c++11',])
> pymod = import('python')
> py = pymod.find_installation('python3')
> py.extension_module('example', sources : 'example.cpp', dependencies : dependency('python3'))

I'll try to explore it next week if you haven't had chance to investigate.
--
Regards

Kieran


> --
> Kieran
> 
> 
> 
>> ---
>>  .gitmodules  | 3 +++
>>  ext/pybind11 | 1 +
>>  2 files changed, 4 insertions(+)
>>  create mode 100644 .gitmodules
>>  create mode 160000 ext/pybind11
>>
>> diff --git a/.gitmodules b/.gitmodules
>> new file mode 100644
>> index 0000000..c6d1083
>> --- /dev/null
>> +++ b/.gitmodules
>> @@ -0,0 +1,3 @@
>> +[submodule "ext/pybind11"]
>> +	path = ext/pybind11
>> +	url = https://github.com/pybind/pybind11.git
>> diff --git a/ext/pybind11 b/ext/pybind11
>> new file mode 160000
>> index 0000000..3b1dbeb
>> --- /dev/null
>> +++ b/ext/pybind11
>> @@ -0,0 +1 @@
>> +Subproject commit 3b1dbebabc801c9cf6f0953a4c20b904d444f879
>>
>
Tomi Valkeinen Sept. 18, 2020, 3:46 p.m. UTC | #3
On 18/09/2020 18:38, Kieran Bingham wrote:

> Although,
> 
> https://github.com/mesonbuild/meson/issues/4677#issuecomment-457949493
> 
> Implies that it can be handled natively through the meson build
> system/python integrations ... Not sure I understood the right path yet:
> 
>> project('pybindtest', 'cpp', default_options : ['cpp_std=c++11',])
>> pymod = import('python')
>> py = pymod.find_installation('python3')
>> py.extension_module('example', sources : 'example.cpp', dependencies : dependency('python3'))
> 
> I'll try to explore it next week if you haven't had chance to investigate.

This doesn't work (I asked on meson irc channel), as the python module 
does not support cross-compiling.

  Tomi
Tomi Valkeinen Sept. 18, 2020, 6:36 p.m. UTC | #4
On 18/09/2020 18:33, Kieran Bingham wrote:
> Hi Tomi,
> 
> Thank you very much for your work on python bindings, this is very exciting.
> 
> 
> On 18/09/2020 16:20, Tomi Valkeinen wrote:
>> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@iki.fi>
> 
> I haven't had chance to go through everything yet, but for pulling in
> the pybind11 dependency, I suspect this should be handled through the
> meson dependecy/wrap framework.
> 
> 	https://mesonbuild.com/Wrap-dependency-system-manual.html
> 
> I've never used it, so I'm not quite sure how that works yet - but I
> don't think we should expect users to have to wrangle the git submodules
> themselves before starting a build.

This works too. I pushed a version using wrap (from WrapDB, 
https://wrapdb.mesonbuild.com/pybind11) and subproject to:

https://github.com/tomba/libcamera py-subproj

I'm not sure if I like it or not... I rather like it that git handles 
the subproject, and shows if it's up to date or not. I'm not sure how 
meson wraps and subprojects work with e.g. bisecting. But wrap is 
probably more mesonic way to do it.

  Tomi

Patch

diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..c6d1083
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@ 
+[submodule "ext/pybind11"]
+	path = ext/pybind11
+	url = https://github.com/pybind/pybind11.git
diff --git a/ext/pybind11 b/ext/pybind11
new file mode 160000
index 0000000..3b1dbeb
--- /dev/null
+++ b/ext/pybind11
@@ -0,0 +1 @@ 
+Subproject commit 3b1dbebabc801c9cf6f0953a4c20b904d444f879