mirror of
https://github.com/opencv/opencv.git
synced 2026-07-25 21:33:04 +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:
@@ -45,8 +45,6 @@ foreach(fname ${PYTHON_LOADER_FILES})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
||||
|
||||
if(WIN32)
|
||||
if(CMAKE_GENERATOR MATCHES "Visual Studio")
|
||||
list(APPEND CMAKE_PYTHON_BINARIES_PATH "'${EXECUTABLE_OUTPUT_PATH}/Release'") # TODO: CMAKE_BUILD_TYPE is not defined
|
||||
@@ -126,3 +124,20 @@ if(NOT "${OPENCV_PYTHON_EXTRA_MODULES_PATH}" STREQUAL "")
|
||||
ocv_add_python_files_from_path(${extra_ocv_py_modules_path})
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(${PYTHON}_VERSION_STRING VERSION_GREATER "3.6" AND PYTHON_DEFAULT_VERSION VERSION_GREATER "3.6")
|
||||
add_custom_target(copy_opencv_typing_stubs)
|
||||
# Copy all generated stub files to python_loader directory only if
|
||||
# generation succeeds, this behvoir can't be achieved with default
|
||||
# CMake constructions, because failed generation produces a warning instead of
|
||||
# halts on hard error.
|
||||
add_custom_command(
|
||||
TARGET copy_opencv_typing_stubs
|
||||
COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${PYTHON_SOURCE_DIR}/src2/copy_typings_stubs_on_success.py
|
||||
--stubs_dir ${OPENCV_PYTHON_BINDINGS_DIR}/cv2
|
||||
--output_dir ${__loader_path}/cv2
|
||||
)
|
||||
if(DEFINED OPENCV_PYTHON_INSTALL_PATH)
|
||||
install(DIRECTORY "${OPENCV_PYTHON_BINDINGS_DIR}/cv2" DESTINATION "${OPENCV_PYTHON_INSTALL_PATH}" COMPONENT python)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user