File tree Expand file tree Collapse file tree 5 files changed +313
-5
lines changed Expand file tree Collapse file tree 5 files changed +313
-5
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ set(MODULE_NAME "python_bindings_generator")
2
2
set (OPENCV_MODULE_IS_PART_OF_WORLD FALSE )
3
3
ocv_add_module(${MODULE_NAME} INTERNAL )
4
4
5
+ set (OPENCV_PYTHON_STUB_FILE "${CMAKE_CURRENT_BINARY_DIR} /__init__.pyi" CACHE INTERNAL "" )
5
6
set (OPENCV_PYTHON_SIGNATURES_FILE "${CMAKE_CURRENT_BINARY_DIR} /pyopencv_signatures.json" CACHE INTERNAL "" )
6
7
set (OPENCV_PYTHON_BINDINGS_DIR "${CMAKE_CURRENT_BINARY_DIR} " CACHE INTERNAL "" )
7
8
@@ -67,6 +68,7 @@ set(cv2_generated_files
67
68
"${CMAKE_CURRENT_BINARY_DIR} /pyopencv_generated_modules_content.h"
68
69
"${CMAKE_CURRENT_BINARY_DIR} /pyopencv_generated_types.h"
69
70
"${CMAKE_CURRENT_BINARY_DIR} /pyopencv_generated_types_content.h"
71
+ "${OPENCV_PYTHON_STUB_FILE} "
70
72
"${OPENCV_PYTHON_SIGNATURES_FILE} "
71
73
)
72
74
@@ -84,6 +86,13 @@ add_custom_command(
84
86
85
87
add_custom_target (gen_opencv_python_source DEPENDS ${cv2_generated_files} )
86
88
89
+ add_custom_target (package_python_stub DEPENDS gen_opencv_python_source)
90
+
91
+ add_custom_command (
92
+ TARGET package_python_stub
93
+ COMMAND ${CMAKE_COMMAND} -E copy ${OPENCV_PYTHON_STUB_FILE} ${CMAKE_BINARY_DIR} /python_loader/cv2/__init__.pyi
94
+ )
95
+
87
96
set (cv2_custom_hdr "${CMAKE_CURRENT_BINARY_DIR} /pyopencv_custom_headers.h" )
88
97
set (cv2_custom_hdr_str "//user-defined headers\n " )
89
98
foreach (uh ${opencv_userdef_hdrs} )
Original file line number Diff line number Diff line change @@ -24,6 +24,11 @@ if(TARGET gen_opencv_python_source)
24
24
add_dependencies (${the_module} gen_opencv_python_source)
25
25
endif ()
26
26
27
+ if (TARGET package_python_stub AND ${PYTHON} _VERSION_MAJOR EQUAL 3 AND ${PYTHON} _VERSION_MINOR GREATER 4)
28
+ # Python 3.5+
29
+ add_dependencies (${the_module} package_python_stub)
30
+ endif ()
31
+
27
32
ocv_assert(${PYTHON} _VERSION_MAJOR)
28
33
ocv_assert(${PYTHON} _VERSION_MINOR)
29
34
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ def main():
22
22
long_description = long_description ,
23
23
long_description_content_type = "text/markdown" ,
24
24
packages = setuptools .find_packages (),
25
+ package_data = {"cv2" : ["*.pyi" , "*.typed" ]},
25
26
maintainer = "OpenCV Team" ,
26
27
install_requires = "numpy" ,
27
28
classifiers = [
Original file line number Diff line number Diff line change @@ -38,6 +38,8 @@ foreach(fname ${PYTHON_LOADER_FILES})
38
38
endif ()
39
39
endforeach ()
40
40
41
+ file (TOUCH "${__loader_path} /cv2/py.typed" )
42
+
41
43
if (NOT OpenCV_FOUND) # Ignore "standalone" builds of Python bindings
42
44
if (WIN32 )
43
45
if (CMAKE_GENERATOR MATCHES "Visual Studio" )
You can’t perform that action at this time.
0 commit comments