From 62ebacd27757a754ddce39fe4c12a002cd5b51be Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Thu, 31 Aug 2023 17:04:45 +0200 Subject: [PATCH] pybind11 stubgen v1 needs new call syntax --- python/CMakeLists.txt | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 792b337c..ce71d204 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -26,13 +26,17 @@ install(FILES # build stub files for pybind11 packages if(BUILD_STUB_FILES) -execute_process(COMMAND ${Python3_EXECUTABLE} -c "import pybind11_stubgen; print(pybind11_stubgen.__file__)" OUTPUT_VARIABLE stubgen_path RESULT_VARIABLE pybind11_stubgen) +execute_process(COMMAND ${Python3_EXECUTABLE} -c "from importlib.metadata import version; print(version('pybind11-stubgen'))" OUTPUT_VARIABLE stubgen_version RESULT_VARIABLE pybind11_stubgen) if(pybind11_stubgen AND NOT ${pybind11_stubgen} EQUAL 0) message(WARNING "pybind11-stubgen not found, if you want to create stub files for better autocompletion support install it with pip.") else() - message("-- Found pybind11-stubgen: ${stubgen_path}") - install(CODE "execute_process(COMMAND ${Python3_EXECUTABLE} -m pybind11_stubgen --no-setup-py --ignore-invalid=all netgen)") - install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../stubs/netgen-stubs/ DESTINATION ${NG_INSTALL_DIR_PYTHON}/netgen/ COMPONENT netgen) + if(stubgen_version LESS "1.0") + message(WARNING "pybind11-stubgen version is too old, if you want to create stub files for better autocompletion support upgrade it with pip.") + else() + message("-- Found pybind11-stubgen version: ${stubgen_version}") + install(CODE "execute_process(COMMAND ${Python3_EXECUTABLE} -m pybind11_stubgen --ignore-all-errors netgen)") + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../stubs/netgen/ DESTINATION ${NG_INSTALL_DIR_PYTHON}/netgen/ COMPONENT netgen) + endif() endif() endif(BUILD_STUB_FILES)