fix(pybind): nanobind make_iterator compile errors#346
fix(pybind): nanobind make_iterator compile errors#346
Conversation
…bgen - Replace pybind11 includes with nanobind equivalents across all source files - Replace PYBIND11_MODULE with NB_MODULE macro - Replace py::return_value_policy with py::rv_policy - Remove S<T> holder types from py::class_ declarations (nanobind uses #include <nanobind/stl/shared_ptr.h>) - Rewrite as_numpy.h for nanobind's ndarray API - Rewrite json.h type_caster for nanobind's API - Update pyengine.h trampoline class with NB_TRAMPOLINE/NB_OVERRIDE_PURE - Update span.h for nanobind's make_iterator API - Update CMake build files for nanobind - Update XMake build files for nanobind - Update stubgen script to use nanobind.stubgen Co-authored-by: MuGdxy <52098265+MuGdxy@users.noreply.github.com>
- Fix .cast<T>() method calls to py::cast<T>() in utils.cpp and feature_collection.cpp - Fix py::type parameter to py::handle in feature_collection.cpp - Replace def_readwrite with def_rw for nanobind compatibility - Fix make_numpy_empty dtype handling using string literals - Remove duplicate nanobind include in usd/module.cpp - Update documentation references from pybind11 to nanobind Co-authored-by: MuGdxy <52098265+MuGdxy@users.noreply.github.com>
Co-authored-by: MuGdxy <52098265+MuGdxy@users.noreply.github.com>
Co-authored-by: MuGdxy <52098265+MuGdxy@users.noreply.github.com>
Co-authored-by: MuGdxy <52098265+MuGdxy@users.noreply.github.com>
|
@copilot fix the CI problem |
The previous commit incorrectly replaced .venv/ with .venv/_codeql_detected_source_root. This fixes it by keeping .venv/ and adding _codeql_detected_source_root as a separate entry. Also removes the tracked _codeql_detected_source_root symlink. Co-authored-by: MuGdxy <52098265+MuGdxy@users.noreply.github.com>
Investigated the CI. The initial runs had
Note: the pybind module is not built in CI (cmake uses Also fixed a |
|
@copilot dylib provides pkg-config modules: eigen3 provides CMake targets: eigen3 provides pkg-config modules: The package fmt provides CMake targets: libigl provides CMake targets: magic-enum provides CMake targets: The package nlohmann-json provides CMake targets: The package nlohmann-json can be configured to not provide implicit conversions via a custom triplet file: For more information, see the docs here: Octree provides CMake targets: The package spdlog provides CMake targets: tbb provides CMake targets: tbb provides pkg-config modules: tinygltf is header-only and can be used from CMake via: urdfdom provides CMake targets: urdfdom provides pkg-config modules: Completed submission of console-bridge:x64-linux@1.0.2 to 1 binary cache(s) in 12.4 ms -- Configuring incomplete, errors occurred! *** CMake configuration failed ERROR Backend subprocess exited when trying to invoke build_wheel |
nanobind-config.cmake requires find_package(Python COMPONENTS Interpreter Development.Module REQUIRED) to be called before find_package(nanobind). The original pybind11 code used PYBIND11_FINDPYTHON=ON which handled Python finding internally, but nanobind requires it to be done explicitly. Co-authored-by: MuGdxy <52098265+MuGdxy@users.noreply.github.com>
... The CI failure in the "Build Python Wheels" workflow was caused by a missing The error was: The original pybind11 code used Fixed in |
…e conversion nanobind types (bool_, int_, float_, str, list, tuple, dict) have explicit constructors unlike pybind11. The MAKE_NLJSON_SERIALIZER_DESERIALIZER macro's from_json returns py::object which cannot implicitly convert to these types. Use py::borrow<T>() for the explicit conversion. Co-authored-by: MuGdxy <52098265+MuGdxy@users.noreply.github.com>
|
@copilot fix [443/541] /usr/local/bin/g++ -DCPPTRACE_STATIC_DEFINE -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DUIPC_PROJECT_DIR="R"(/project)"" -DUIPC_RUNTIME_CHECK=1 -DUIPC_VERSION_MAJOR=0 -DUIPC_VERSION_MINOR=1 -DUIPC_VERSION_PATCH=0 -Dpyuipc_EXPORTS -DUIPC_RELATIVE_SOURCE_FILE="R"(src/pybind/pyuipc/exception.cpp)"" -I/project/src/pybind/pyuipc/.. -I/opt/python/cp310-cp310/include/python3.10 -I/tmp/build-env-yn72o_gg/lib/python3.10/site-packages/nanobind/include -I/project/include -I/project/src/sanity_check -isystem /tmp/tmp4p_ir4hl/build/vcpkg_installed/x64-linux/include/eigen3 -isystem /tmp/tmp4p_ir4hl/build/vcpkg_installed/x64-linux/include -O3 -DNDEBUG -std=gnu++20 -fPIC -fvisibility=hidden -fno-stack-protector -Os -ffunction-sections -fdata-sections -MD -MT src/pybind/pyuipc/CMakeFiles/pyuipc.dir/exception.cpp.o -MF src/pybind/pyuipc/CMakeFiles/pyuipc.dir/exception.cpp.o.d -o src/pybind/pyuipc/CMakeFiles/pyuipc.dir/exception.cpp.o -c /project/src/pybind/pyuipc/exception.cpp *** CMake build failed ERROR Backend subprocess exited when trying to invoke build_wheel |
Two compilation fixes: 1. as_numpy.h: Replace arr(i,j) with raw pointer access since nanobind ndarray::operator() requires shape<>/ndim<> annotations. 2. transform.cpp, simplicial_complex_io.cpp: Change py::init<>(lambda) to py::init(lambda) - nanobind factory init uses py::init() without empty template args (py::init<>() is only for default constructors). Co-authored-by: MuGdxy <52098265+MuGdxy@users.noreply.github.com>
Fixed in
|
|
@copilot fix it [445/541] /usr/local/bin/g++ -DCPPTRACE_STATIC_DEFINE -DSPDLOG_COMPILED_LIB -DSPDLOG_FMT_EXTERNAL -DUIPC_PROJECT_DIR="R"(/project)"" -DUIPC_RUNTIME_CHECK=1 -DUIPC_VERSION_MAJOR=0 -DUIPC_VERSION_MINOR=1 -DUIPC_VERSION_PATCH=0 -Dpyuipc_EXPORTS -DUIPC_RELATIVE_SOURCE_FILE="R"(src/pybind/pyuipc/pyuipc.cpp)"" -I/project/src/pybind/pyuipc/.. -I/opt/python/cp313-cp313/include/python3.13 -I/tmp/build-env-_0yot813/lib/python3.13/site-packages/nanobind/include -I/project/include -I/project/src/sanity_check -isystem /tmp/tmpecslhels/build/vcpkg_installed/x64-linux/include/eigen3 -isystem /tmp/tmpecslhels/build/vcpkg_installed/x64-linux/include -O3 -DNDEBUG -std=gnu++20 -fPIC -fvisibility=hidden -fno-stack-protector -Os -ffunction-sections -fdata-sections -MD -MT src/pybind/pyuipc/CMakeFiles/pyuipc.dir/pyuipc.cpp.o -MF src/pybind/pyuipc/CMakeFiles/pyuipc.dir/pyuipc.cpp.o.d -o src/pybind/pyuipc/CMakeFiles/pyuipc.dir/pyuipc.cpp.o -c /project/src/pybind/pyuipc/pyuipc.cpp |
…placement new Nanobind doesn't support pybind11's py::init(factory_lambda) pattern. Nanobind's init<Args...> is a class template, not a function accepting callables. Convert all factory constructors to __init__ with placement new, which is nanobind's documented pattern for custom constructors. Files fixed: - transform.cpp: 5 factory inits (Quaternion, AngleAxis, Transform) - simplicial_complex_io.cpp: 2 factory inits - buffer.cpp: 1 factory init Co-authored-by: MuGdxy <52098265+MuGdxy@users.noreply.github.com>
Fixed in |
…args 1. pyuipc.h: Add #include <nanobind/trampoline.h> to provide NB_TRAMPOLINE and NB_OVERRIDE_PURE macros for the trampoline class. 2. engine.cpp: Fix second Engine constructor py::init<> template args from <string_view, string_view, Json&> to <string_view, S<IEngine>, string_view, Json&> to match the actual C++ constructor that takes an overrider parameter. Co-authored-by: MuGdxy <52098265+MuGdxy@users.noreply.github.com>
…d11-to-nanobind-again
- Fix py::module& → py::module_& in new binding headers and sources - Fix #include <pybind11/stl.h> → nanobind/stl/vector.h in animator.cpp - Fix py::array_t<T> → numpy_array<T> in new/modified binding files - Fix py::doc(R"(...)") → R"(...)" (nanobind uses raw const char*) - Fix return types from numpy_array<Float> to py::object Co-authored-by: MuGdxy <52098265+MuGdxy@users.noreply.github.com>
nanobind's ndarray::operator() requires shape<> or ndim<> template annotations which numpy_array<T> (nb::ndarray<nb::numpy, T>) lacks. Use data() pointer arithmetic instead, consistent with existing pattern in as_numpy.h helpers. Co-authored-by: MuGdxy <52098265+MuGdxy@users.noreply.github.com>
Add #include <nanobind/make_iterator.h> to span.h and attribute_slot.cpp. Fix make_iterator call in attribute_slot.cpp from pybind11-style (first, last) to nanobind-style (scope, name, first, last). Fixes CI error: 'make_iterator' is not a member of 'pyuipc::py' Co-authored-by: MuGdxy <52098265+MuGdxy@users.noreply.github.com>
All 8 CI wheel builds fail with
'make_iterator' is not a member of 'pyuipc::py'due to incomplete pybind11→nanobind migration.Two issues:
nanobind/make_iterator.his not transitively included bynanobind/nanobind.h— added tospan.handattribute_slot.cppattribute_slot.cppused pybind11-stylemake_iterator(first, last)instead of nanobind'smake_iterator(scope, name, first, last)Also includes the prior fix replacing
ndarray::operator()with raw pointer arithmetic inaffine_body.cpp, since nanobind requiresshape<>/ndim<>template annotations for indexed access.Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
gitlab.com/usr/local/share/vcpkg/vcpkg /usr/local/share/vcpkg/vcpkg x-download libeigen-eigen-3.4.0.tar.gz --url=REDACTED --sha512=ba75ecb760e32acf4ceaf27115468e65d4f77c44f8d519b5a13e7940af2c03a304ad433368cb6d55431f307c5c39e2666ab41d34442db3cf441638e51f5c3b6a .clean/include /v1.0.2-4c425645-o .clean/src inux-dbg/includeas /usr/local/share-I kg_installed/x64/usr/local/share/vcpkg/buildtrees/cpptrace/src/v1.0.2-4c42564507.clean/include o --64�� .clean/include ees/cpptrace/src-o .clean/src s/cpptrace/x64-lsh -I c/build_test/vcp/usr/local/bin/ninja --version u/13/cc1plus(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.