nanobind: upgrade to version 2.11.0#534
Conversation
There was a problem hiding this comment.
Pull request overview
Upgrades the vendored nanobind submodule to v2.11.0 (fixing #533), including ABI/runtime changes (module state, vectorcall/immutability), expanded ndarray framework support, and corresponding test/stub/doc updates.
Changes:
- Bump nanobind version to 2.11.0, update ABI internals (ABI v18), and raise minimum supported Python to 3.9+ across build/config/docs.
- Improve/extend stub generation (performance, enum edge cases, module/class prefix/suffix patterns,
--exclude-values) and update reference stubs/tests accordingly. - Add/adjust tests for new runtime/typing/ndarray behavior (JAX/TensorFlow/array-api, specialization, threading races, never-destruct, etc.).
Reviewed changes
Copilot reviewed 114 out of 114 changed files in this pull request and generated 25 comments.
Show a summary per file
| File | Description |
|---|---|
| extern/nanobind/tests/test_typing_ext.pyi.ref | Updates typing stub reference output to match new stubgen/signature behavior. |
| extern/nanobind/tests/test_typing.py | Removes legacy Python-version skip tied to dropped <3.9 support. |
| extern/nanobind/tests/test_typing.cpp | Adjusts typing test module exports/signatures (e.g., AnyTuple, Iterable spelling). |
| extern/nanobind/tests/test_thread.py | Adds threaded shared_ptr access regression test. |
| extern/nanobind/tests/test_thread.cpp | Adds shared_ptr-backed test API to exercise keep_alive/thread races. |
| extern/nanobind/tests/test_tensorflow.py | Adds TensorFlow ndarray interop tests (conditionally skipped when TF missing). |
| extern/nanobind/tests/test_tensorflow.cpp | Adds TensorFlow ndarray return path test module. |
| extern/nanobind/tests/test_stubs.py | Adjusts stub-ref normalization logic for typing_extensions insertion point. |
| extern/nanobind/tests/test_stl_ext.pyi.ref | Updates STL stub reference output (optional arg typing). |
| extern/nanobind/tests/test_stl_bind_map.py | Simplifies expected docstring typing to always use builtin generics. |
| extern/nanobind/tests/test_stl.py | Updates expected docstrings/typing and adds optional(None) assertion. |
| extern/nanobind/tests/test_stl.cpp | Adds optional arg-defaults static_assert; updates GC traversal for Py_TYPE visit. |
| extern/nanobind/tests/test_specialization.py | Adds CPython specialization/immutability tests for nanobind types. |
| extern/nanobind/tests/test_ndarray_ext.pyi.ref | Updates ndarray stub refs (bool_ dtype, new overloads, new APIs/classes). |
| extern/nanobind/tests/test_ndarray.cpp | Extends ndarray tests: array_api/memview returns, new initialize overload, dtype tweaks. |
| extern/nanobind/tests/test_jax.py | Adds JAX ndarray interop tests (conditionally skipped when JAX missing). |
| extern/nanobind/tests/test_jax.cpp | Adds JAX ndarray return path test module. |
| extern/nanobind/tests/test_inter_module_2.cpp | Exposes new increment_shared inter-module API. |
| extern/nanobind/tests/test_inter_module.py | Expands inter-module tests (reload/reimport/subinterpreters behavior). |
| extern/nanobind/tests/test_functions_ext.pyi.ref | Updates function stub reference output and adds module docstring + new API stub. |
| extern/nanobind/tests/test_functions.py | Updates expected signatures/docstrings for builtin generics and adds new test call. |
| extern/nanobind/tests/test_functions.cpp | Adds test_simple function to exercise “simple” vectorcall path with many args. |
| extern/nanobind/tests/test_enum_ext.pyi.ref | Updates enum stub refs; adds enum case with members named name/value. |
| extern/nanobind/tests/test_enum.py | Adds regression test for enums with name/value members. |
| extern/nanobind/tests/test_enum.cpp | Adds enum binding used for stubgen regression coverage. |
| extern/nanobind/tests/test_eigen.py | Adds regression test for zero-sized vectors/stride behavior. |
| extern/nanobind/tests/test_classes_extra.cpp | Adds out-of-line impl for NeverDestruct to test never-destruct binding. |
| extern/nanobind/tests/test_classes_ext.pyi.ref | Updates classes stub refs for new APIs/types (never_destruct, constexpr trampoline, etc.). |
| extern/nanobind/tests/test_classes.py | Updates tests for new class APIs/behavior and typing docstrings. |
| extern/nanobind/tests/test_classes.h | Adds header for NeverDestruct test type with incomplete impl detail. |
| extern/nanobind/tests/test_classes.cpp | Adds/updates bindings for new class behaviors (never_destruct, constexpr trampoline, etc.). |
| extern/nanobind/tests/py_stub_test.pyi.ref | Ensures module docstring is preserved in stub reference output. |
| extern/nanobind/tests/py_stub_test.py | Adds module docstring to verify stubgen preserves it. |
| extern/nanobind/tests/pattern_file.nb | Extends pattern file support to class-level prefix/suffix insertions. |
| extern/nanobind/tests/inter_module.h | Updates inter-module API signatures (check with expected value, increment). |
| extern/nanobind/tests/inter_module.cpp | Implements updated inter-module API (expected value, increment). |
| extern/nanobind/tests/conftest.py | Fixes CLI help text typo for slow-test option. |
| extern/nanobind/tests/CMakeLists.txt | Updates compiler handling, adds extra source for classes test, adds new tests/options. |
| extern/nanobind/src/version.py | Extends version writing to update docs/bazel.rst for stable releases. |
| extern/nanobind/src/stubgen.py | Major stubgen updates (perf, enum/value handling, new flags, class patterns, docstrings). |
| extern/nanobind/src/nb_type.cpp | Updates type internals (dict/weaklist offsets, vectorcall slot handling, module naming). |
| extern/nanobind/src/nb_internals.h | Updates internals types/maps/module-state definitions and helpers. |
| extern/nanobind/src/nb_internals.cpp | Refactors module initialization, adds per-module cached PyObject constants + GC hooks. |
| extern/nanobind/src/nb_func.cpp | Updates function creation/vectorcall internals and arg-annotation handling. |
| extern/nanobind/src/nb_enum.cpp | Updates enum handling to use cached interned strings for perf. |
| extern/nanobind/src/nb_combined.cpp | Only includes free-threaded code when building for Py_GIL_DISABLED. |
| extern/nanobind/src/nb_abi.h | Bumps internal ABI version to 18. |
| extern/nanobind/src/implicit.cpp | Minor style/initialization cleanups in implicit conversion registration. |
| extern/nanobind/src/error.cpp | Simplifies traceback extraction using modern CPython APIs. |
| extern/nanobind/src/common.cpp | Updates vectorcall argument counting; improves delattr for limited API; seq handling tweaks. |
| extern/nanobind/src/init.py | Raises minimum supported Python to 3.9 and bumps version to 2.11.0. |
| extern/nanobind/pyproject.toml | Bumps package version to 2.11.0. |
| extern/nanobind/include/nanobind/typing.h | Adds param_spec() helper. |
| extern/nanobind/include/nanobind/trampoline.h | Makes trampoline constructor constexpr to satisfy MSVC constraints. |
| extern/nanobind/include/nanobind/stl/tuple.h | Switches stub/doc typing name to tuple[...]. |
| extern/nanobind/include/nanobind/stl/pair.h | Switches stub/doc typing name to tuple[...]. |
| extern/nanobind/include/nanobind/stl/optional.h | Marks std::optional as having arg-default semantics for implicit None acceptance. |
| extern/nanobind/include/nanobind/stl/function.h | Switches callable typing name to collections.abc.Callable[...]. |
| extern/nanobind/include/nanobind/stl/filesystem.h | Removes Python<3.9 typing fallback (consistent with new minimum). |
| extern/nanobind/include/nanobind/stl/detail/nb_set.h | Updates Set typing strings to collections.abc/builtin generics. |
| extern/nanobind/include/nanobind/stl/detail/nb_list.h | Updates Sequence/list typing strings to collections.abc/builtin generics. |
| extern/nanobind/include/nanobind/stl/detail/nb_dict.h | Updates Mapping/dict typing strings to collections.abc/builtin generics. |
| extern/nanobind/include/nanobind/stl/detail/nb_array.h | Fixes temp decref placement and updates Sequence/list typing strings. |
| extern/nanobind/include/nanobind/stl/chrono.h | Removes Python<3.9 typing fallback (consistent with new minimum). |
| extern/nanobind/include/nanobind/ndarray.h | Extends DLPack dtype codes; adds array_api framework tag. |
| extern/nanobind/include/nanobind/nb_types.h | Updates typing names; adds guidance comment; modernizes constructors/type names. |
| extern/nanobind/include/nanobind/nb_traits.h | Adds has_arg_defaults trait used for implicit optional(None) behavior. |
| extern/nanobind/include/nanobind/nb_python.h | Raises minimum Python version check to 3.9. |
| extern/nanobind/include/nanobind/nb_lib.h | Adds DLPack version constants; refactors init/module exec API; signature tweak. |
| extern/nanobind/include/nanobind/nb_func.h | Improves call_guard return typing; adds optional/arg-default plumbing. |
| extern/nanobind/include/nanobind/nb_defs.h | Refactors vectorcall/typing macros; adds per-module state + module lifecycle hooks. |
| extern/nanobind/include/nanobind/nb_class.h | Adds never_destruct annotation handling and disables destructor binding accordingly. |
| extern/nanobind/include/nanobind/nb_cast.h | Simplifies typed-name logic to always use modern builtins/collections.abc spellings. |
| extern/nanobind/include/nanobind/nb_call.h | Uses PY_VECTORCALL_ARGUMENTS_OFFSET directly. |
| extern/nanobind/include/nanobind/nb_attr.h | Adds never_destruct, refactors func_data prelim layout, and adjusts arg flag merging. |
| extern/nanobind/include/nanobind/nanobind.h | Bumps version macros and includes . |
| extern/nanobind/include/nanobind/intrusive/ref.h | Fixes comment typo (“Register”). |
| extern/nanobind/include/nanobind/eigen/dense.h | Fixes move construction and adds stride workaround for numpy 2.4 zero-sized vectors. |
| extern/nanobind/ext/robin_map/tests/CMakeLists.txt | Updates required CMake version for upstream robin_map tests. |
| extern/nanobind/ext/robin_map/include/tsl/robin_growth_policy.h | Bumps embedded robin_map patch version. |
| extern/nanobind/ext/robin_map/CMakeLists.txt | Bumps embedded robin_map project version and minimum CMake. |
| extern/nanobind/ext/robin_map/.github/workflows/ci.yml | Updates upstream robin_map CI runners/matrices. |
| extern/nanobind/docs/why.rst | Documentation edits/reordering and wording updates. |
| extern/nanobind/docs/typing.rst | Documents new stubgen flag and class-level prefix/suffix patterns. |
| extern/nanobind/docs/refleaks.rst | Updates GC traversal guidance (always visit Py_TYPE). |
| extern/nanobind/docs/porting.rst | Documents never_destruct as py::nodelete equivalent. |
| extern/nanobind/docs/packaging.rst | Raises documented minimum Python to 3.9 and updates examples. |
| extern/nanobind/docs/ndarray.rst | Documents new array_api/memview frameworks and expanded DLPack behavior. |
| extern/nanobind/docs/index.rst | Raises documented minimum Python to 3.9 and updates supported toolchain list. |
| extern/nanobind/docs/exceptions.rst | Adds std::runtime_error mapping and updates wording. |
| extern/nanobind/docs/classes.rst | Documents never_destruct usage and constraints. |
| extern/nanobind/docs/changelog.rst | Adds detailed 2.11.0 changelog entry and related notes. |
| extern/nanobind/docs/building.rst | Raises documented minimum Python to 3.9 in build instructions. |
| extern/nanobind/docs/bazel.rst | Updates bazel version examples and adds linking mode documentation. |
| extern/nanobind/docs/api_extra.rst | Documents array_api and ParamSpec helper additions. |
| extern/nanobind/docs/api_core.rst | Removes outdated Python 3.8 caveat and documents never_destruct. |
| extern/nanobind/docs/api_bazel.rst | Documents new Bazel macro attributes (linking mode, deps, etc.). |
| extern/nanobind/cmake/nanobind-config.cmake | Enforces Python>=3.9, detects free-threaded via ABI tag, stubgen flag plumbing, robin_map vendoring logic. |
| extern/nanobind/cmake/darwin-ld-pypy.sym | Updates symbol allowlist for newer PyPy builds. |
| extern/nanobind/cmake/darwin-ld-cpython.sym | Updates symbol allowlist for newer CPython builds. |
| extern/nanobind/cmake/collect-symbols.py | Updates symbol collection to modern CPython branches and drops 3.7/3.8. |
| extern/nanobind/cmake/collect-symbols-pypy.py | Extends PyPy symbol collection and adjusts output formatting. |
| extern/nanobind/README.md | Adds testimonials section. |
| extern/nanobind/CMakeLists.txt | Raises find_package minimum Python to 3.9. |
| extern/nanobind/.github/workflows/ci.yml | Updates CI matrix (drop 3.8, new OS/PyPy versions) and adds new jobs (free-threaded, MinGW, Intel). |
| extern/README.md | Updates referenced nanobind version to 2.11.0. |
| VERSION.txt | Bumps repository version stamp. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| warnings.simplefilter("ignore") | ||
| try: | ||
| c = jnp.zeros((3, 5)) | ||
| except: |
There was a problem hiding this comment.
Except block directly handles BaseException.
| warnings.simplefilter("ignore") | ||
| try: | ||
| c = jnp.zeros((3, 5)) | ||
| except: |
There was a problem hiding this comment.
Except block directly handles BaseException.
| import tensorflow.config | ||
| def needs_tensorflow(x): | ||
| return x | ||
| except: |
There was a problem hiding this comment.
Except block directly handles BaseException.
| warnings.simplefilter("ignore") | ||
| try: | ||
| c = tf.zeros((3, 5)) | ||
| except: |
There was a problem hiding this comment.
Except block directly handles BaseException.
Fixes #533.