Fix/enable stub files for pip package

- set PYTHONPATH when generating stub files
- also generate for pyngcore
- build python packages with stub files
This commit is contained in:
Matthias Hochsteger 2024-03-26 19:22:16 +01:00
parent f96ccabeb6
commit c53d0e29a7
2 changed files with 8 additions and 4 deletions

View File

@ -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)

View File

@ -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()