Repository navigation
feat: add mcpplibs.mwrap.nanobind 3.1.0 modules - #2
Merged
Merged
Conversation
Thin C++23 module wrapper over compat.nanobind 3.1.0: core API, STL casters, ndarray/DLPack, operators and version constants. Adds the default embed template, GCC/LLVM tests, byte-pinned upstream documents and runtime license deployment.
Match only python3XX.lib on Windows, probe both venv and standalone interpreter prefixes, sort include/python3.* by numeric minor, and correct the README literal/typo examples.
Sunrisepeak
requested changes
Nov 30, 2026
Sunrisepeak
reviewed
Nov 30, 2026
Move the four embedded-Python tests to mcpplibs.mtest UTest cases with one interpreter lifetime per process. Remove standard headers that import std provides, build both build.mcpp files with import std, and document the remaining hard-required includes and ndarray initializer_list.
nanobind/ndarray.h is included in the global module fragment, so its own initializer_list inclusion already belongs there. Verified with GCC 16.2.0 and Clang 23.1.3.
Sunrisepeak
requested changes
Dec 1, 2026
Replace tests/python_embed.hpp with tests/support/python_embed.cppm, compiled only by the tests feature and never exported. Drop the test-side Python.h include so behavior/ndarray/side_header keep one side-header include and operators has none. Use mcpp::target_os() instead of _WIN32 in both build.mcpp files and the embed template, and use PyConfig_SetBytesString on every platform.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements
mcpplibs.mwrap.nanobind(3.1.0), a thin C++23 module wrapper over wjakob/nanobindv3.1.0, followingmcpp-index/docs/mwrap.md,mwrap-readme.md, andmwrap-licensing.md.#1using an in-repo branch (feat/mwrap-nanobind) so GitHub Actions CI runs directly andmcpp-plugins(rules-python) can cross-validate against this branch viagit + branch.mcpplibs/mcpp-index#933(compat.robin-map@1.4.1andcompat.nanobind@3.1.0) is merged.@Sunrisepeak): hold merge until multi-platform CI (Linux GCC 16 / LLVM 23, macOS, Windows) is green and cross-validation withmcpp-plugins(rules-python) completes.Highlights
compat.nanobind = "3.1.0"and compilessrc/nb_runtime.cpp(#include <mcpp_nanobind_combined.hpp>) behind the defaultruntimefeature (consumers needing custom ABI flags such asPy_LIMITED_API/NB_SHAREDcan setdefault-features = false).mcpplibs.mwrap.nanobind— public root re-exporting_core,macros,stl, andndarraymcpplibs.mwrap.nanobind.stl— STLtype_casterspecializations (string,vector,map,unordered_map,optional,variant,function, smart pointers,filesystem,chrono, etc.)mcpplibs.mwrap.nanobind.ndarray—nb::ndarray, DLPack types, contiguity/device/framework tags,nb::dtypemcpplibs.mwrap.nanobind.macros—NB_VERSION_*asinline constexprinmcpplibs::mwrap::nanobind::macrosmcpplibs.mwrap.nanobind.operators—nb::selfand ADL operator helpers (kept as an explicit opt-in module rather than implicitly re-exported by the root to avoid GCC 16.1/16.2gen_enumeration_type_diedebug-info ICE when expanding operator templates; full ADL audit runs on Clang 23)<mwrap/nanobind/macros.hpp>— companion header for preprocessor macros (NB_MODULE,NB_TRAMPOLINE,NB_OVERRIDE*,NB_MAKE_OPAQUE), documented and tested with include-before-importbuild.mcpp):MCPP_PYTHON_INCLUDE_DIR→xim:python→MCPP_PYTHON_EXECUTABLE/VIRTUAL_ENV/PATH→ clear diagnosticinclude_dirand never leaklink_lib("python...")into consumers (required for Linux CPython.soextensions); only the package-internaltestsfeature links the embedding librarytemplates/embed/uses unquoted dotted key{{self.name}} = "{{self.version}}", builds cleanly under--strict, and runs an embeddedNB_MODULEdemoLICENSE+NOTICE(mcpp-community), byte-pinnedupstream/nanobind/{LICENSE,README.md}withupstream/** -text,upstream/documents.json,tools/check_documents.py, and[[runtime.deploy]]README.md/README.zh.md+docs/usage.md+ 3-platform CI (Linux GCC 16 & LLVM 23, macOS LLVM 23, Windows LLVM 23)Local Verification
tools/check_documents.py,mcpp build --strict,mcpp test(4/4:behavior,ndarray,operators,side_header),tools/test_template.py(--strictbuild + run) — all PASSmcpp 2026.11.23.1,llvm@23.1.3,MSVC 14.44,Windows SDK 10.0.26100.0):tools/check_documents.py,mcpp build --strict,mcpp test(4/4 including Clang ADL audit) — all PASS