Skip to content

Disable ft build in cmake#1271

Merged
wjakob merged 2 commits intowjakob:masterfrom
awni:disable_ft_cmake
Jan 27, 2026
Merged

Disable ft build in cmake#1271
wjakob merged 2 commits intowjakob:masterfrom
awni:disable_ft_cmake

Conversation

@awni
Copy link
Contributor

@awni awni commented Jan 21, 2026

@wjakob wdyt about something like this (codex did it)? It queries the active interpreter for Py_GIL_DISABLED and sets a new build flag NB_PY_GIL_DISABLED which it uses to add nb_ft.cpp to the target or not.

@wjakob
Copy link
Owner

wjakob commented Jan 21, 2026

I don't think you an extra call to Python if the build is free-threaded. The nanobind CMake build system already knows this through the ABI tag.

@awni
Copy link
Contributor Author

awni commented Jan 21, 2026

Done.. much cleaner. I think you can review it.

@awni awni marked this pull request as ready for review January 21, 2026 16:59
@hpkfft
Copy link
Contributor

hpkfft commented Jan 21, 2026

Do we still want to have FREE_THREADED as an argument to nanobind_add_module()?
Maybe simpler (easier to understand) if not?
Just a thought....


To answer my own question: yes, we want to keep the argument.
It is possible to build an extension using free-threaded Python and not specify FREE_THREADED.
In this case, the GIL is re-enabled at runtime when Python imports the extension.

@wjakob
Copy link
Owner

wjakob commented Jan 27, 2026

THanks. This looks good now. I will make a minor touchup and reduce the length of the variable name.

@wjakob wjakob merged commit 4e86049 into wjakob:master Jan 27, 2026
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants