mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +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:
@@ -1,9 +1,19 @@
|
||||
import os
|
||||
import sys
|
||||
import platform
|
||||
import setuptools
|
||||
|
||||
SCRIPT_DIR=os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
SCRIPT_DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
|
||||
def collect_module_typing_stub_files(root_module_path):
|
||||
stub_files = []
|
||||
for module_path, _, files in os.walk(root_module_path):
|
||||
stub_files.extend(
|
||||
map(lambda p: os.path.join(module_path, p),
|
||||
filter(lambda f: f.endswith(".pyi"), files))
|
||||
)
|
||||
return stub_files
|
||||
|
||||
|
||||
def main():
|
||||
os.chdir(SCRIPT_DIR)
|
||||
@@ -13,6 +23,13 @@ def main():
|
||||
|
||||
long_description = 'Open Source Computer Vision Library Python bindings' # TODO
|
||||
|
||||
root_module_path = os.path.join(SCRIPT_DIR, "cv2")
|
||||
py_typed_path = os.path.join(root_module_path, "py.typed")
|
||||
if os.path.isfile(py_typed_path):
|
||||
typing_stub_files = collect_module_typing_stub_files(root_module_path)
|
||||
if len(typing_stub_files) > 0:
|
||||
typing_stub_files.append(py_typed_path)
|
||||
|
||||
setuptools.setup(
|
||||
name=package_name,
|
||||
version=package_version,
|
||||
@@ -22,6 +39,9 @@ def main():
|
||||
long_description=long_description,
|
||||
long_description_content_type="text/markdown",
|
||||
packages=setuptools.find_packages(),
|
||||
package_data={
|
||||
"cv2": typing_stub_files
|
||||
},
|
||||
maintainer="OpenCV Team",
|
||||
install_requires="numpy",
|
||||
classifiers=[
|
||||
@@ -55,5 +75,6 @@ def main():
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user