Back to home page

EIC code displayed by LXR

 
 

    


Warning, /acts/cmake/ActsPybindStubs.cmake is written in an unsupported language. File is not indexed.

0001 include_guard(GLOBAL)
0002 
0003 # Generate stubs for a user-facing Python module using pybind11-stubgen.
0004 # _module:       dotted Python module name (e.g. acts, acts.examples, detray.core)
0005 # _cmake_target: primary CMake target whose .so must exist before stub generation
0006 # [extra_deps]:  additional CMake targets that must be built first (e.g. ActsPythonBindings)
0007 function(acts_pybind_generate_stubs _module _cmake_target)
0008     if(NOT ACTS_GENERATE_PYTHON_STUBS)
0009         return()
0010     endif()
0011     include(ActsEnsureUv)
0012     set(_extra_deps ${ARGN})
0013     string(REPLACE "." "/" _module_path ${_module})
0014     set(_stub_file "${CMAKE_BINARY_DIR}/python/${_module_path}/__init__.pyi")
0015     add_custom_command(
0016         OUTPUT ${_stub_file}
0017         COMMAND
0018             ${CMAKE_COMMAND} -E env "PYTHONPATH=${CMAKE_BINARY_DIR}/python"
0019             ${uv_exe} tool run --python ${Python_EXECUTABLE} --with numpy
0020             pybind11-stubgen ${_module} --exit-code --output-dir
0021             ${CMAKE_BINARY_DIR}/python --ignore-invalid-expressions ".*"
0022             --ignore-invalid-identifiers "GeoModelTree::FpvConstLink"
0023             --ignore-unresolved-names ".*"
0024         DEPENDS ${_cmake_target} ${_extra_deps}
0025         COMMENT "Generating stubs for ${_module}"
0026         VERBATIM
0027     )
0028     add_custom_target(${_cmake_target}Stubs ALL DEPENDS ${_stub_file})
0029 endfunction()