[Buildroot] [PATCH/next v2 1/2]: pybind11: new package
guillaume.bressaix at gmail.com
guillaume.bressaix at gmail.com
Sat Dec 4 12:05:47 UTC 2021
From: "Guillaume W. Bres" <guillaume.bressaix at gmail.com>
fixes http://autobuild.buildroot.net/results/b89f1de64b308dffa73675f1f31ccb0b7be5a10d
fixes http://autobuild.buildroot.net/results/d0287b7f64f206b0f074908c5780a3632e0cb799
fixes http://autobuild.buildroot.net/results/27efb545a5a719a5581c8f746d3a3555ff4216ce
fixes http://autobuild.buildroot.net/results/d2f0a0ad8f6c7178517df109e7d885dac9134c3a
fixes http://autobuild.buildroot.net/results/b57e9a3279260dae4a590f9421238fcabb2f7cab
fixes http://autobuild.buildroot.net/results/515e6f2fc6b5780260d98d6bb52b541ce4bf1afe
fixes http://autobuild.buildroot.net/results/d89c4ecc81222d4f80c951da2232d2e393fa1c69
list goes on..
---
v2: Reviewed by gwen at trabucayre.com,
Removed some non needed empty lines,
force -DFINDPYTHON=OFF when using pybind11 without python,
handle legacy package properly in a seperate patch
v1: python-pybind was not the right approach and is in failure since
it's been upgraded to V2.6.1.
Building with setup.py now requires a cmake build first.
With this new approach we can build the package with cmake
for python bindings in C++ AND we also have the
C++ bindings in python as an option (depending & requiring the first one).
I make this a host-only package, in the sense that other packages will
require it at build time, and I don't forsee any reasons to have
such a package as a target package.
Signed-off-by: Guillaume W. Bres <guillaume.bressaix at gmail.com>
---
DEVELOPERS | 1 +
package/Config.in | 1 +
package/pybind11/Config.in | 25 +++++++++++++++++++++
package/pybind11/pybind11.hash | 3 +++
package/pybind11/pybind11.mk | 41 ++++++++++++++++++++++++++++++++++
5 files changed, 71 insertions(+)
create mode 100644 package/pybind11/Config.in
create mode 100644 package/pybind11/pybind11.hash
create mode 100644 package/pybind11/pybind11.mk
diff --git a/DEVELOPERS b/DEVELOPERS
index 6f812eb564..8a04efa63f 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -1105,6 +1105,7 @@ F: package/libxcrypt/
F: package/liquid-dsp/
F: package/pixiewps/
F: package/python-pybind/
+F: package/pybind11/
F: package/reaver/
N: Guo Ren <ren_guo at c-sky.com>
diff --git a/package/Config.in b/package/Config.in
index 311004db2c..5749118ee3 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -2006,6 +2006,7 @@ endif
source "package/protobuf/Config.in"
source "package/protobuf-c/Config.in"
source "package/protozero/Config.in"
+ source "package/pybind11/Config.in"
source "package/qhull/Config.in"
source "package/qlibc/Config.in"
source "package/riemann-c-client/Config.in"
diff --git a/package/pybind11/Config.in b/package/pybind11/Config.in
new file mode 100644
index 0000000000..4fc6c5eebc
--- /dev/null
+++ b/package/pybind11/Config.in
@@ -0,0 +1,25 @@
+comment "pybind11 needs a toolchain w/ C++, wchar"
+ depends on !BR2_INSTALL_LIBSTDCPP || !BR2_USE_WCHAR
+
+config BR2_PACKAGE_PYBIND11
+ bool "pybind11"
+ depends on BR2_USE_WCHAR # boost
+ depends on BR2_INSTALL_LIBSTDCPP # boost
+ depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_64735 # boost-thread
+ select BR2_PACKAGE_BOOST
+ help
+ Pybind11 is a lightweight header-only library that exposes C++
+ types in Python and vice versa, mainly to create Python
+ bindings of existing C++ code.
+
+ http://pybind11.readthedocs.org/en/master
+
+if BR2_PACKAGE_PYBIND11
+
+config BR2_PACKAGE_PYBIND11_WITH_PYTHON
+ bool "pybind11-python"
+ depends on BR2_PACKAGE_PYTHON3
+ help
+ Activate support for python
+
+endif
diff --git a/package/pybind11/pybind11.hash b/package/pybind11/pybind11.hash
new file mode 100644
index 0000000000..ab8825bf04
--- /dev/null
+++ b/package/pybind11/pybind11.hash
@@ -0,0 +1,3 @@
+# Locally calculated
+sha256 f1bcc07caa568eb312411dde5308b1e250bd0e1bc020fae855bf9f43209940cc pybind11-2.8.1.tar.gz
+sha256 83965b843b98f670d3a85bd041ed4b372c8ec50d7b4a5995a83ac697ba675dcb LICENSE
diff --git a/package/pybind11/pybind11.mk b/package/pybind11/pybind11.mk
new file mode 100644
index 0000000000..a67ce237ea
--- /dev/null
+++ b/package/pybind11/pybind11.mk
@@ -0,0 +1,41 @@
+################################################################################
+#
+# pybind11
+#
+################################################################################
+
+PYBIND11_VERSION = 2.8.1
+PYBIND11_SITE = $(call github,pybind,pybind11,v$(PYBIND11_VERSION))
+PYBIND11_LICENSE = BSD-3-Clause
+PYBIND11_LICENSE_FILES = LICENSE
+PYBIND11_INSTALL_STAGING = YES
+PYBIND11_SUPPORTS_IN_SOURCE_BUILD = YES
+
+HOST_PYBIND11_CONF_OPTS = \
+ -DBUILD_DOCS=OFF \
+ -DDOWNLOAD_EIGEN=OFF
+
+# pybind11 python support activation
+ifeq ($(BR2_PACKAGE_PYBIND11_WITH_PYTHON),y)
+HOST_PYBIND11_DEPENDENCIES += host-python3
+
+# pybind11 with python requires cmake install in $(@D)
+HOST_PYBIND11_CONF_OPTS += \
+ -DCMAKE_INSTALL_PREFIX=$(@D)/pybind11 \
+ -DPYTHON=$(HOST_DIR)/bin/python3 \
+ -DPYTHON_PREFIX=$(STAGING_DIR)/usr \
+ -DPYBIND_FINDPYTHON=ON \
+ -DPYBIND11_NOPYTHON=OFF
+
+define PYBIND11_PYTHON_BUILD
+ cd $(@D) && $(HOST_DIR)/bin/python setup.py install
+endef
+
+HOST_PYBIND11_POST_INSTALL_HOOKS += PYBIND11_PYTHON_BUILD
+else
+HOST_PYBIND11_CONF_OPTS += \
+ -DPYBIND_FINDPYTHON=OFF \
+ -DPYBIND11_NOPYTHON=ON
+endif
+
+$(eval $(host-cmake-package))
--
2.20.1
More information about the buildroot
mailing list