File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ {
2+ "python-envs.defaultEnvManager" : " ms-python.python:conda" ,
3+ "python-envs.defaultPackageManager" : " ms-python.python:conda"
4+ }
Original file line number Diff line number Diff line change @@ -29,6 +29,21 @@ FetchContent_Declare(
2929 GIT_SHALLOW TRUE
3030)
3131
32+ # nanobind caches NB_SUFFIX (the .pyd/.so extension tag) in CMakeCache.txt.
33+ # When the active Python interpreter changes (e.g. cp312 → cp311) the cached
34+ # value becomes stale because nanobind uses "set(... CACHE INTERNAL)" without
35+ # FORCE, so it never overwrites an existing entry. We query the interpreter
36+ # here and force-write the cache entry so that the generated library always
37+ # carries the correct tag regardless of previous configure runs.
38+ execute_process (
39+ COMMAND "${Python_EXECUTABLE} " "-c"
40+ "import sysconfig; print(sysconfig.get_config_var('EXT_SUFFIX'))"
41+ OUTPUT_VARIABLE _pystark_ext_suffix
42+ OUTPUT_STRIP_TRAILING_WHITESPACE
43+ )
44+ set (NB_SUFFIX "${_pystark_ext_suffix} " CACHE INTERNAL "" FORCE )
45+ set (NB_SUFFIX_S "${_pystark_ext_suffix} " CACHE INTERNAL "" FORCE )
46+
3247FetchContent_MakeAvailable (nanobind)
3348
3449# Source files
Original file line number Diff line number Diff line change @@ -18,6 +18,14 @@ using namespace nb::literals;
1818
1919#include < cstring>
2020
21+ // ssize_t is a POSIX type not provided by MSVC's standard headers.
22+ // Python's headers define Py_ssize_t; make ssize_t an alias so that nanobind's
23+ // ndarray.h (template <ssize_t... Is> struct shape) and our own templates
24+ // compile cleanly on Windows.
25+ #if defined(_MSC_VER) && !defined(ssize_t)
26+ using ssize_t = Py_ssize_t;
27+ #endif
28+
2129
2230// Type shortcuts
2331#include < stark>
You can’t perform that action at this time.
0 commit comments