package/python-pybind11: new package
PATCH 1/2 package/python-pybind11: new package
From: Adam Duskett <[email protected]>
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. Its goals and syntax are similar to the excellent Boost.Python library by David Abrahams:
To minimize boilerplate code in traditional extension modules by inferring type information using compile-time introspection.
--- DEVELOPERS | 1 + package/Config.in | 1 + package/python-pybind11/Config.in | 23 ++++++++++++++++++++ package/python-pybind11/python-pybind11.hash | 5 +++++ package/python-pybind11/python-pybind11.mk | 15 +++++++++++++ 5 files changed, 45 insertions(+) create mode 100644 package/python-pybind11/Config.in create mode 100644 package/python-pybind11/python-pybind11.hash create mode 100644 package/python-pybind11/python-pybind11.mk
DEVELOPERS +1 -0
@@ -64,6 +64,7 @@ F: package/python-flask-sqlalchemy/ F: package/python-mutagen/ F: package/python-pip/ F: package/python-psycopg2/ +F: package/python-pybind11/ F: package/python-sqlalchemy/ F: package/python-sqlparse/ F: package/python-visitor/
package/Config.in +1 -0
@@ -1021,6 +1021,7 @@ menu "External python modules" source "package/python-pyasn-modules/Config.in" source "package/python-pyasn1/Config.in" source "package/python-pyasn1-modules/Config.in" + source "package/python-pybind11/Config.in" source "package/python-pycairo/Config.in" source "package/python-pycares/Config.in" source "package/python-pycli/Config.in"
package/python-pybind11/Config.in new file +23 -0
@@ -0,0 +1,23 @@ +config BR2_PACKAGE_PYTHON_PYBIND11 + bool "python-pybind11" + depends on BR2_INSTALL_LIBSTDCPP + depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8 # C++11 + depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_64735 # exception_ptr + 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. Its goals and syntax are + similar to the excellent Boost.Python library by David + Abrahams: + To minimize boilerplate code in traditional extension modules + by inferring type information using compile-time + introspection. + + https://github.com/pybind/pybind11 + +comment "python-pybind11 needs a toolchain w/ C++, gcc >= 4.8" + depends on !BR2_INSTALL_LIBSTDCPP + depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_4_8 + +comment "python-pybind11 needs exception_ptr" + depends on BR2_TOOLCHAIN_HAS_GCC_BUG_64735
package/python-pybind11/python-pybind11.hash new file +5 -0
@@ -0,0 +1,5 @@ +# md5, sha256 from https://pypi.org/pypi/pybind11/json +md5 23fdca8191b16ce3e7f38fb9e4252b2d pybind11-2.4.3.tar.gz +sha256 72e6def53fb491f7f4e92692029d2e7bb5a0783314f20d80222735ff10a75758 pybind11-2.4.3.tar.gz +# Locally computed sha256 checksums +sha256 9a37ea54aa3cf12c7f3292799f20822ffd4b9b7142b36a7a9997b28c39264dc9 LICENSE
package/python-pybind11/python-pybind11.mk new file +15 -0
@@ -0,0 +1,15 @@ +################################################################################ +# +# python-pybind11 +# +################################################################################ + +PYTHON_PYBIND11_VERSION = 2.4.3 +PYTHON_PYBIND11_SOURCE = pybind11-$(PYTHON_PYBIND11_VERSION).tar.gz +PYTHON_PYBIND11_SITE = https://files.pythonhosted.org/packages/aa/91/deb6743e79e22ab01502296570b39b8404f10cc507a6692d612a7fee8d51 +PYTHON_PYBIND11_SETUP_TYPE = setuptools +PYTHON_PYBIND11_LICENSE = BSD-3-Clause +PYTHON_PYBIND11_LICENSE_FILES = LICENSE +PYTHON_PYBIND11_INSTALL_STAGING = YES + +$(eval $(python-package))
Signature · 1 line
2.23.0
PATCH 2/2 support/testing: add python-pybind11 test
From: Adam Duskett <[email protected]>
This test is a simple integration test of the python-pybind11 package.
It consists of the following:
- The python-pybind11-addition-example package compiles a simple cpp file which adds two given numbers together and returns the results and installs the compiled file to /root/
This example is from the following URL:
https://pybind11.readthedocs.io/en/stable/basics.html
- The python-pybind11-addition-example package installs the sample_python_pybind11.py file which imports the above-compiled file and adds 1 and 2 together to /root/
- Execute the sample_python_pybind11.py in an emulator with the expected output of 3 and an exit code of 0.
--- .gitlab-ci.yml | 2 + DEVELOPERS | 2 + .../br2-external/python-pybind11/Config.in | 1 + .../python-pybind11/external.desc | 1 + .../br2-external/python-pybind11/external.mk | 1 + .../Config.in | 5 ++ .../pybind11_addition_example.cpp | 9 +++ .../python-pybind11-addition-example.mk | 39 ++++++++++ .../sample_python_pybind11.py | 5 ++ .../tests/package/test_python_pybind11.py | 76 +++++++++++++++++++ 10 files changed, 141 insertions(+) create mode 100644 support/testing/tests/package/br2-external/python-pybind11/Config.in create mode 100644 support/testing/tests/package/br2-external/python-pybind11/external.desc create mode 100644 support/testing/tests/package/br2-external/python-pybind11/external.mk create mode 100644 support/testing/tests/package/br2-external/python-pybind11/package/python-pybind11-addition-example/Config.in create mode 100644 support/testing/tests/package/br2-external/python-pybind11/package/python-pybind11-addition-example/pybind11_addition_example.cpp create mode 100644 support/testing/tests/package/br2-external/python-pybind11/package/python-pybind11-addition-example/python-pybind11-addition-example.mk create mode 100644 support/testing/tests/package/br2-external/python-pybind11/package/python-pybind11-addition-example/sample_python_pybind11.py create mode 100644 support/testing/tests/package/test_python_pybind11.py
.gitlab-ci.yml +2 -0
@@ -454,6 +454,8 @@ tests.package.test_python_passlib.TestPythonPy2Passlib: { extends: .runtime_test tests.package.test_python_passlib.TestPythonPy3Passlib: { extends: .runtime_test } tests.package.test_python_pexpect.TestPythonPy2Pexpect: { extends: .runtime_test } tests.package.test_python_pexpect.TestPythonPy3Pexpect: { extends: .runtime_test } +tests.package.test_python_pybind11.TestPythonPy2Pybind11: { extends: .runtime_test } +tests.package.test_python_pybind11.TestPythonPy3Pybind11: { extends: .runtime_test } tests.package.test_python_pynacl.TestPythonPy2Pynacl: { extends: .runtime_test } tests.package.test_python_pynacl.TestPythonPy3Pynacl: { extends: .runtime_test } tests.package.test_python_pyyaml.TestPythonPy2Pyyaml: { extends: .runtime_test }
DEVELOPERS +2 -0
@@ -76,6 +76,8 @@ F: package/setools/ F: package/sngrep/ F: package/spidermonkey/ F: package/systemd/ +F: support/testing/tests/package/br2-external/python-pybind11/ +F: support/testing/tests/package/test_python_pybind11.py N: Adam Heinrich <[email protected]> F: package/jack1/
support/testing/tests/package/br2-external/python-pybind11/Config.in new file +1 -0
@@ -0,0 +1 @@ +source "$BR2_EXTERNAL_PYTHON_PYBIND11_PATH/package/python-pybind11-addition-example/Config.in"
support/testing/tests/package/br2-external/python-pybind11/external.desc new file +1 -0
@@ -0,0 +1 @@ +name: PYTHON_PYBIND11
support/testing/tests/package/br2-external/python-pybind11/external.mk new file +1 -0
@@ -0,0 +1 @@ +include $(sort $(wildcard $(BR2_EXTERNAL_PYTHON_PYBIND11_PATH)/package/*/*.mk))
support/testing/tests/package/br2-external/python-pybind11/package/python-pybind11-addition-example/Config.in new file +5 -0
@@ -0,0 +1,5 @@ +config BR2_PACKAGE_PYTHON_PYBIND11_ADDITION_EXAMPLE + bool "python-pybind11 addition example" + depends on BR2_PACKAGE_PYTHON_PYBIND11 + help + Simple class for testing python-pybind11
support/testing/tests/package/br2-external/python-pybind11/package/python-pybind11-addition-example/pybind11_addition_example.cpp new file +9 -0
@@ -0,0 +1,9 @@ +#include <pybind11/pybind11.h> + +int add(int i, int j) { + return i + j; +} + +PYBIND11_MODULE(pybind11_addition_example, m) { + m.def("add", &add, "A function which adds two numbers"); +}
support/testing/tests/package/br2-external/python-pybind11/package/python-pybind11-addition-example/python-pybind11-addition-example.mk new file +39 -0
@@ -0,0 +1,39 @@ +################################################################################ +# +# python-pybind11_addition_example +# +################################################################################ + +PYTHON_PYBIND11_ADDITION_EXAMPLE_DEPENDENCIES = python-pybind11 + +ifeq ($(BR2_PACKAGE_PYTHON),y) +PYTHON_PYBIND11_ADDITION_EXAMPLE_INCLUDES=`$(STAGING_DIR)/usr/bin/python2-config --includes` +PYTHON_PYBIND11_ADDITION_EXAMPLE_SUFFIX=`$(STAGING_DIR)/usr/bin/python2-config --extension-suffix` +else +PYTHON_PYBIND11_ADDITION_EXAMPLE_INCLUDES=`$(STAGING_DIR)/usr/bin/python3-config --includes` +PYTHON_PYBIND11_ADDITION_EXAMPLE_SUFFIX=`$(STAGING_DIR)/usr/bin/python3-config --extension-suffix` +endif +PYTHON_PYBIND11_ADDITION_EXAMPLE_OUTPUT=pybind11_addition_example$(PYTHON_PYBIND11_ADDITION_EXAMPLE_SUFFIX) + +define PYTHON_PYBIND11_ADDITION_EXAMPLE_BUILD_CMDS + $(INSTALL) -D $(PYTHON_PYBIND11_ADDITION_EXAMPLE_PKGDIR)/pybind11_addition_example.cpp \ + $(@D)/pybind11_addition_example.cpp + + $(INSTALL) -D $(PYTHON_PYBIND11_ADDITION_EXAMPLE_PKGDIR)/sample_python_pybind11.py \ + $(@D)/sample_python_pybind11.py + + cd $(@D); \ + $(TARGET_CXX) -std=c++11 -fPIC -shared \ + $(PYTHON_PYBIND11_ADDITION_EXAMPLE_INCLUDES) pybind11_addition_example.cpp \ + -o $(PYTHON_PYBIND11_ADDITION_EXAMPLE_OUTPUT) +endef + +define PYTHON_PYBIND11_ADDITION_EXAMPLE_INSTALL_TARGET_CMDS + $(INSTALL) -D -m 755 $(@D)/$(PYTHON_PYBIND11_ADDITION_EXAMPLE_OUTPUT) \ + $(TARGET_DIR)/root/$(PYTHON_PYBIND11_ADDITION_EXAMPLE_OUTPUT) + + $(INSTALL) -D -m 755 $(@D)/sample_python_pybind11.py \ + $(TARGET_DIR)/root/sample_python_pybind11.py +endef + +$(eval $(generic-package))
support/testing/tests/package/br2-external/python-pybind11/package/python-pybind11-addition-example/sample_python_pybind11.py new file +5 -0
@@ -0,0 +1,5 @@ +#!/usr/bin/env python +import pybind11_addition_example + +print(pybind11_addition_example.add(1, 2)) +
support/testing/tests/package/test_python_pybind11.py new file +76 -0
76 lines not on this page · raw message
Signature · 1 line
2.23.0
PATCH 1/2 package/python-pybind11: new package
In reply to aduskett at gmail.comHello,
Quoted 95 lines · On Sat, Nov 30, 2019 at 2:12 AM <[email protected]> wrote:
From: Adam Duskett <[email protected]>
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. Its goals and syntax are similar to the excellent Boost.Python library by David Abrahams:
To minimize boilerplate code in traditional extension modules by inferring type information using compile-time introspection.Signed-off-by Adam Duskett <[email protected]>--- DEVELOPERS | 1 + package/Config.in | 1 + package/python-pybind11/Config.in | 23 ++++++++++++++++++++ package/python-pybind11/python-pybind11.hash | 5 +++++ package/python-pybind11/python-pybind11.mk | 15 +++++++++++++ 5 files changed, 45 insertions(+) create mode 100644 package/python-pybind11/Config.in create mode 100644 package/python-pybind11/python-pybind11.hash create mode 100644 package/python-pybind11/python-pybind11.mkDEVELOPERS +1
-0@@ -64,6 +64,7 @@ F: package/python-flask-sqlalchemy/ F: package/python-mutagen/ F: package/python-pip/ F: package/python-psycopg2/ +F: package/python-pybind11/ F: package/python-sqlalchemy/ F: package/python-sqlparse/ F: package/python-visitor/package/Config.in +1
-0@@ -1021,6 +1021,7 @@ menu "External python modules" source "package/python-pyasn-modules/Config.in" source "package/python-pyasn1/Config.in" source "package/python-pyasn1-modules/Config.in" + source "package/python-pybind11/Config.in" source "package/python-pycairo/Config.in" source "package/python-pycares/Config.in" source "package/python-pycli/Config.in"package/python-pybind11/Config.in new file +23
-0@@ -0,0 +1,23 @@ +config BR2_PACKAGE_PYTHON_PYBIND11 + bool "python-pybind11" + depends on BR2_INSTALL_LIBSTDCPP + depends on BR2_TOOLCHAIN_GCC_AT_LEAST_4_8 # C++11 + depends on !BR2_TOOLCHAIN_HAS_GCC_BUG_64735 # exception_ptr + 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. Its goals and syntax are + similar to the excellent Boost.Python library by David + Abrahams: + To minimize boilerplate code in traditional extension modules + by inferring type information using compile-time + introspection. + + https://github.com/pybind/pybind11 + +comment "python-pybind11 needs a toolchain w/ C++, gcc >= 4.8" + depends on !BR2_INSTALL_LIBSTDCPP + depends on !BR2_TOOLCHAIN_GCC_AT_LEAST_4_8 + +comment "python-pybind11 needs exception_ptr" + depends on BR2_TOOLCHAIN_HAS_GCC_BUG_64735package/python-pybind11/python-pybind11.hash new file +5
-0@@ -0,0 +1,5 @@ +# md5, sha256 from https://pypi.org/pypi/pybind11/json +md5 23fdca8191b16ce3e7f38fb9e4252b2d pybind11-2.4.3.tar.gz +sha256 72e6def53fb491f7f4e92692029d2e7bb5a0783314f20d80222735ff10a75758 pybind11-2.4.3.tar.gz +# Locally computed sha256 checksums +sha256 9a37ea54aa3cf12c7f3292799f20822ffd4b9b7142b36a7a9997b28c39264dc9 LICENSEpackage/python-pybind11/python-pybind11.mk new file +3
-0@@ -0,0 +1,15 @@ +################################################################################ +# +# python-pybind11
package/python-pybind11/python-pybind11.mk line 13
Quoted 10 lines
package/python-pybind11/python-pybind11.mk new file +10
-0+# +################################################################################ + +PYTHON_PYBIND11_VERSION = 2.4.3 +PYTHON_PYBIND11_SOURCE = pybind11-$(PYTHON_PYBIND11_VERSION).tar.gz +PYTHON_PYBIND11_SITE = https://files.pythonhosted.org/packages/aa/91/deb6743e79e22ab01502296570b39b8404f10cc507a6692d612a7fee8d51 +PYTHON_PYBIND11_SETUP_TYPE = setuptools +PYTHON_PYBIND11_LICENSE = BSD-3-Clause +PYTHON_PYBIND11_LICENSE_FILES = LICENSE +PYTHON_PYBIND11_INSTALL_STAGING = YES
Don't we want to add PYTHON_PYBIND11_INSTALL_TARGET = NO?
This package installs only headers and is used only when compiling the sources.
Quoted 9 lines
package/python-pybind11/python-pybind11.mk new file +2
-1+ +$(eval $(python-package)) --2.23.0
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
Regards,
Asaf.