diff mbox series

[meta-python,7/7] python3-nanobind: Add recipe

Message ID 20250129114039.3562870-7-leon.anavi@konsulko.com
State Under Review
Headers show
Series [meta-python,1/7] python3-scikit-build-core: Use PYTHON_INCLUDE_DIR | expand

Commit Message

Leon Anavi Jan. 29, 2025, 11:40 a.m. UTC
Add recipe for nanobind, tiny and efficient C++/Python bindings.

Changelog for version 2.4.0:

- Added a function annotation :cpp:class:`nb::call_policy\<Policy\>()
  <call_policy>` which supports custom function wrapping logic,
  calling Policy::precall() before the bound function and
  Policy::postcall() after. This is a low-level interface intended
  for advanced users. The precall and postcall hooks are able to
  observe the Python objects forming the function arguments and
  return value, and the precall hook can change the arguments.
- :cpp:func:`nb::make_iterator <make_iterator>` now accepts its
  iterator arguments by value, rather than by forwarding reference,
  in order to eliminate the hazard of storing a dangling C++
  iterator reference in the returned Python iterator object.
- The std::variant type_caster now does two passes when converting
  from Python. The first pass is done without implicit conversions.
  This fixes an issue where std::variant<U, T> might cast a Python
  object wrapping a T to a U if there is an implicit conversion
  available from T to U.
- Restored support for constructing types with an overloaded
  __new__ that takes no arguments, which regressed with the
  constructor vector call acceleration that was added in nanobind
  2.2.0.
- Bindings for augmented assignment operators (as generated, for
  example, by .def(nb::self += nb::self)) now return the same
  object in Python in the typical case where the C++ operator
  returns a reference to *this. Previously, after a += b, a would
  be replaced with a copy.
- Added an overload to :cpp:func:`nb::isinstance <isinstance>`
  which tests if a Python object is an instance of a Python class.
  This is in addition to the existing overload, which tests if a
  Python object is an instance of a bound C++ class.
- Added support for overriding static properties, such as those
  defined using def_prop_ro_static, in subclasses. Previously this
  would fail with an error.
- Other minor fixes and improvements.

This work was sponsored by GOVCERT.LU.

Signed-off-by: Leon Anavi <leon.anavi@konsulko.com>
---
 .../python/python3-nanobind_2.4.0.bb          | 26 +++++++++++++++++++
 1 file changed, 26 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-nanobind_2.4.0.bb
diff mbox series

Patch

diff --git a/meta-python/recipes-devtools/python/python3-nanobind_2.4.0.bb b/meta-python/recipes-devtools/python/python3-nanobind_2.4.0.bb
new file mode 100644
index 0000000000..a151d6db4e
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-nanobind_2.4.0.bb
@@ -0,0 +1,26 @@ 
+SUMMARY = "nanobind: tiny and efficient C++/Python bindings"
+DESCRIPTION = "nanobind: tiny and efficient C++/Python bindings"
+HOMEPAGE = "https://github.com/wjakob/nanobind"
+LICENSE = "BSD-3-Clause"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=7646f9ee25e49eaf53f89a10665c568c"
+
+SRC_URI[sha256sum] = "a0392dee5f58881085b2ac8bfe8e53f74285aa4868b1472bfaf76cfb414e1c96"
+
+inherit pypi python_setuptools_build_meta cmake lib_package
+
+EXTRA_OECMAKE += "-DNB_TEST=OFF"
+
+DEPENDS += "\
+    python3-scikit-build-native \
+    python3-scikit-build-core-native \
+    ninja-native \
+"
+
+do_install:append() {
+    install -d ${D}${base_libdir}/cmake/${PN}
+    install -m 0644 ${S}/cmake/* ${D}${base_libdir}/cmake/${PN}/
+}
+
+FILES:${PN} += "${prefix_native}/* ${prefix_native}/${PN}/* ${base_libdir}/cmake/*"
+
+BBCLASSEXTEND = "native nativesdk"