mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 07:13:02 +04:00
Merge pull request #20370 from ddacw:stub-gen-next
Python typing stub generation #20370 Add stub generation to `gen2.py`, addressing #14590. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or other license that is incompatible with OpenCV - [x] The PR is proposed to proper branch - [x] There is reference to original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -76,11 +76,14 @@ set(cv2_generated_files
|
||||
|
||||
string(REPLACE ";" "\n" opencv_hdrs_ "${opencv_hdrs}")
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/headers.txt" "${opencv_hdrs_}")
|
||||
file(GLOB_RECURSE typing_stubs_generation_files "${PYTHON_SOURCE_DIR}/src2/typing_stubs_generation/*.py")
|
||||
add_custom_command(
|
||||
OUTPUT ${cv2_generated_files}
|
||||
COMMAND "${PYTHON_DEFAULT_EXECUTABLE}" "${PYTHON_SOURCE_DIR}/src2/gen2.py" "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_BINARY_DIR}/headers.txt"
|
||||
DEPENDS "${PYTHON_SOURCE_DIR}/src2/gen2.py"
|
||||
"${PYTHON_SOURCE_DIR}/src2/hdr_parser.py"
|
||||
"${typing_stubs_generation_files}"
|
||||
"${PYTHON_SOURCE_DIR}/src2/typing_stubs_generator.py"
|
||||
# not a real build dependency (file(WRITE) result): ${CMAKE_CURRENT_BINARY_DIR}/headers.txt
|
||||
${opencv_hdrs}
|
||||
COMMENT "Generate files for Python bindings and documentation"
|
||||
@@ -88,6 +91,10 @@ add_custom_command(
|
||||
|
||||
add_custom_target(gen_opencv_python_source DEPENDS ${cv2_generated_files})
|
||||
|
||||
if(TARGET copy_opencv_typing_stubs)
|
||||
add_dependencies(copy_opencv_typing_stubs gen_opencv_python_source)
|
||||
endif()
|
||||
|
||||
set(cv2_custom_hdr "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_custom_headers.h")
|
||||
set(cv2_custom_hdr_str "//user-defined headers\n")
|
||||
foreach(uh ${opencv_userdef_hdrs})
|
||||
|
||||
Reference in New Issue
Block a user