From 99df9c0083b2c13a5e55857e7bc1d9651c13211a Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Sat, 29 Jun 2019 20:01:05 +0200 Subject: [PATCH 1/2] auto generate stub files using pybind11_stubgen --- CMakeLists.txt | 7 ++++--- python/CMakeLists.txt | 13 +++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bf7980e3..5527d2ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,6 +28,7 @@ option( ENABLE_CPP_CORE_GUIDELINES_CHECK "Enable cpp core guideline checks on ng option( USE_SPDLOG "Enable spd log logging" OFF) option( DEBUG_LOG "Enable more debug output (may increase computation time) - only works with USE_SPDLOG=ON" OFF) option( CHECK_RANGE "Check array range access, automatically enabled if built in debug mode" OFF) +option( BUILD_STUB_FILES "Build stub files for better autocompletion" ON) option( USE_SUPERBUILD "use ccache" ON) @@ -382,13 +383,13 @@ endif(ENABLE_CPP_CORE_GUIDELINES_CHECK) add_subdirectory(libsrc) add_subdirectory(ng) add_subdirectory(tutorials) -if (USE_PYTHON) - add_subdirectory(python) -endif (USE_PYTHON) add_subdirectory(py_tutorials) add_subdirectory(doc) add_subdirectory(windows) add_subdirectory(nglib) +if (USE_PYTHON) + add_subdirectory(python) +endif (USE_PYTHON) add_subdirectory(tests) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 96a9cdc7..9f4bc635 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -11,3 +11,16 @@ install(FILES DESTINATION ${NG_INSTALL_DIR_PYTHON}/${NG_INSTALL_SUFFIX} COMPONENT netgen ) + +# build stub files for pybind11 packages +if(BUILD_STUB_FILES) +find_program(PYBIND11_STUBS NAMES pybind11-stubgen) +if(PYBIND11_STUBS) + message("-- Found pybind11-stubgen: ${PYBIND11_STUBS}") + install(CODE "execute_process(COMMAND ${PYBIND11_STUBS} --no-setup-py netgen)") + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../stubs/netgen-stubs/ DESTINATION ${NG_INSTALL_DIR_PYTHON}/netgen/) +else(PYBIND11_STUBS) + message(WARNING "pybind11-stubgen not found, if you want to create stub files +for better autocompletion support install it with pip.") +endif(PYBIND11_STUBS) +endif(BUILD_STUB_FILES) From 13fa0acb2b3967577ea6ef154b1743a4e9171311 Mon Sep 17 00:00:00 2001 From: Christopher Lackner Date: Sun, 30 Jun 2019 12:52:08 +0200 Subject: [PATCH 2/2] pass BUILD_STUB_FILES option to superbuild --- cmake/SuperBuild.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/SuperBuild.cmake b/cmake/SuperBuild.cmake index 646de088..06174b10 100644 --- a/cmake/SuperBuild.cmake +++ b/cmake/SuperBuild.cmake @@ -145,6 +145,7 @@ set_vars( NETGEN_CMAKE_ARGS USE_SPDLOG DEBUG_LOG CHECK_RANGE + BUILD_STUB_FILES ) # propagate all variables set on the command line using cmake -DFOO=BAR