Skip to content

Commit b534ea2

Browse files
authored
Merge pull request #853 from asmorkalov/as/add_pyi_to_package
Try to add pyi files to package
2 parents 474a1cc + e4da6a0 commit b534ea2

File tree

4 files changed

+20
-5
lines changed

4 files changed

+20
-5
lines changed

opencv

Submodule opencv updated 688 files

opencv_contrib

Submodule opencv_contrib updated 70 files

opencv_extra

Submodule opencv_extra updated 186 files

setup.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,10 @@ def main():
129129
+
130130
[
131131
r"python/cv2/.*config.*.py"
132-
],
132+
]
133+
+
134+
[ r"python/cv2/py.typed" ] if sys.version_info >= (3, 6) else []
135+
,
133136
"cv2.data": [ # OPENCV_OTHER_INSTALL_PATH
134137
("etc" if os.name == "nt" else "share/opencv4") + r"/haarcascades/.*\.xml"
135138
],
@@ -392,7 +395,6 @@ def _classify_installed_files_override(
392395
p.replace(os.path.sep, "/") for p in install_relpaths
393396
]
394397
relpaths_zip = list(zip(fslash_install_relpaths, install_relpaths))
395-
del install_relpaths, fslash_install_relpaths
396398

397399
final_install_relpaths = []
398400

@@ -411,6 +413,19 @@ def _classify_installed_files_override(
411413
with open(config_py, 'w') as opencv_init_config:
412414
opencv_init_config.write(custom_init_data)
413415

416+
if sys.version_info >= (3, 6):
417+
for p in install_relpaths:
418+
if p.endswith(".pyi"):
419+
target_rel_path = os.path.relpath(p, "python/cv2")
420+
cls._setuptools_wrap._copy_file(
421+
os.path.join(cmake_install_dir, p),
422+
os.path.join(cmake_install_dir, "cv2", target_rel_path),
423+
hide_listing=False,
424+
)
425+
final_install_relpaths.append(os.path.join("cv2", target_rel_path))
426+
427+
del install_relpaths, fslash_install_relpaths
428+
414429
for package_name, relpaths_re in cls.package_paths_re.items():
415430
package_dest_reldir = package_name.replace(".", os.path.sep)
416431
for relpath_re in relpaths_re:

0 commit comments

Comments
 (0)