From bb892bfd9b2ee47e94469a14eeebe6f05c56ba67 Mon Sep 17 00:00:00 2001 From: David Rebbe Date: Thu, 17 Sep 2026 15:27:23 +0000 Subject: [PATCH] Bindings: Python: Support multi-config generators for stubgen --- bindings/python/CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index 957ddc0..02f0eb2 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -57,7 +57,14 @@ install(TARGETS icsneopy LIBRARY DESTINATION icsneopy) find_program(STUBGEN_EXE stubgen) if(STUBGEN_EXE) - add_custom_command(TARGET icsneopy POST_BUILD COMMAND stubgen -v -p icsneopy -o .) + # Multi-config generators put the extension in Release/ or Debug/. Import + # that freshly built module, not a globally installed older icsneopy. + add_custom_command(TARGET icsneopy POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E rm -f "${CMAKE_CURRENT_BINARY_DIR}/icsneopy.pyi" + COMMAND "${STUBGEN_EXE}" -v -p icsneopy -o "${CMAKE_CURRENT_BINARY_DIR}" + WORKING_DIRECTORY "$" + VERBATIM + ) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/icsneopy.pyi py.typed DESTINATION icsneopy) endif()