From c53d0e29a751cce4882ce1cf8ee9e9cb94caf46a Mon Sep 17 00:00:00 2001 From: Matthias Hochsteger Date: Tue, 26 Mar 2024 19:22:16 +0100 Subject: [PATCH] Fix/enable stub files for pip package - set PYTHONPATH when generating stub files - also generate for pyngcore - build python packages with stub files --- python/CMakeLists.txt | 8 ++++++-- setup.py | 4 ++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index fabe9c53..c95c4430 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -42,8 +42,12 @@ else() 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) + install(CODE "\ + set(ENV{PYTHONPATH} ${CMAKE_INSTALL_PREFIX}/${NG_INSTALL_DIR_PYTHON})\n \ + execute_process(COMMAND ${Python3_EXECUTABLE} -m pybind11_stubgen --ignore-all-errors netgen)\n \ + execute_process(COMMAND ${Python3_EXECUTABLE} -m pybind11_stubgen --ignore-all-errors pyngcore)\n \ + ") + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../stubs/ DESTINATION ${NG_INSTALL_DIR_PYTHON} COMPONENT netgen) endif() endif() endif(BUILD_STUB_FILES) diff --git a/setup.py b/setup.py index 26dbd900..4314ec3b 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ from skbuild import setup import skbuild.cmaker from subprocess import check_output -setup_requires = [] +setup_requires = ['pybind11-stubgen==2.5'] def install_filter(cmake_manifest): print(cmake_manifest) @@ -98,7 +98,7 @@ cmake_args += [ '-DUSE_OCC=ON', '-DBUILD_FOR_CONDA=ON', f'-DNETGEN_PYTHON_PACKAGE_NAME={name}', - '-DBUILD_STUB_FILES=OFF', + '-DBUILD_STUB_FILES=ON', ] pyprefix = pathlib.Path(sys.prefix).as_posix()