Closed nicholasjng closed 1 month ago
@wjakob I briefly skimmed your PR again and found some new logic in the CMakeLists.txt
regarding SO files - do I need to put -ft
as an extension for free-threaded builds, or is that only internal to libnanobind?
Hm, looks like nanobind module initialization in C++ fails for Python <3.12.
I'm currently on the train (with horrendous wifi), will investigate later today.
It was the same regression for extensions without files in setuptools 73 that wrecked Google Benchmark earlier. Pinning to setuptools<73
in nanobind example's pyproject.toml
solves the problem.
I'm currently unable to verify if free-threading works here, since rules_python has not yet merged any 3.13 toolchain support, much less included them in a release. When that happens, I can add 3.13 to the nanobind example test matrix.
With that in mind, I hope to release nanobind_bazel
v2.2.0 this week - since we're now even again with nanobind itself, I'm thinking of aligning it again with nanobind's SemVer, and releasing .bzl.N
tags for development progress, effectively treating them as .devN
tags in nanobind. The reason, of course, being that this decoupled SemVer behavior is just too unexpected and confusing for users.
EDIT: Side note, --free_threading
with an older interpreter raises a good error:
ERROR: /Users/nicholasjunge/Workspaces/c++/nanobind_example/src/BUILD:14:19: Compiling src/nanobind_example_ext.cpp failed: (Exit 1): cc_wrapper.sh failed: error executing CppCompile command (from target //src:nanobind_example_ext.so) external/bazel_tools~cc_configure_extension~local_config_cc/cc_wrapper.sh -U_FORTIFY_SOURCE -fstack-protector -Wall -Wthread-safety -Wself-assign -Wunused-but-set-parameter -Wno-free-nonheap-object ... (remaining 67 arguments skipped)
Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
In file included from src/nanobind_example_ext.cpp:1:
In file included from external/nanobind_bazel~~internal_configure_extension~nanobind/include/nanobind/nanobind.h:40:
external/nanobind_bazel~~internal_configure_extension~nanobind/include/nanobind/nb_defs.h:151:6: error: "Free-threaded extensions require a free-threaded version of Python"
# error "Free-threaded extensions require a free-threaded version of Python"
Contains a flag for the
NB_FREE_THREADED
define, which goes into the compilation of libnanobind.Closes #37.