Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added lines for a proper work using pylint and an autocomplete in IDE #579

Merged
merged 3 commits into from Nov 17, 2021
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 17 additions & 0 deletions setup.py
Expand Up @@ -377,6 +377,23 @@ def _classify_installed_files_override(

print("Copying files from CMake output")

# lines for a proper work using pylint and an autocomplete in IDE
with open("%spython/cv2/__init__.py"
% cmake_install_dir, 'r') as opencv_init:
opencv_init_lines = opencv_init.readlines()
extra_imports = ('\nfrom .cv2 import *\nfrom .cv2 import _registerMatType\nfrom . import mat_wrapper\nfrom . import gapi'
'\nfrom . import misc\nfrom . import utils\nfrom . import data\n')
free_line_after_imports = 6
opencv_init_lines.insert(free_line_after_imports, extra_imports)
opencv_init_data = ""
for line in opencv_init_lines:
opencv_init_replacement = line.replace('importlib.import_module("cv2")', 'importlib.import_module("cv2.cv2")')
opencv_init_data = opencv_init_data + opencv_init_replacement

with open("%spython/cv2/__init__.py"
% cmake_install_dir, 'w') as opencv_final_init:
opencv_final_init.write(opencv_init_data)

# add lines from the old __init__.py file to the config file
with open('scripts/__init__.py', 'r') as custom_init:
custom_init_data = custom_init.read()
Expand Down