Skip to content

Commit

Permalink
Merge pull request #579 from asenyaev/asen/fix_pylin_and_pycharm
Browse files Browse the repository at this point in the history
Added lines for a proper work using pylint and an autocomplete in IDE
  • Loading branch information
asenyaev committed Nov 17, 2021
2 parents 7319276 + 8cb031a commit 053e8cc
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions setup.py
Expand Up @@ -377,6 +377,21 @@ 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(os.path.join(cmake_install_dir, "python", "cv2", "__init__.py"), '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(os.path.join(cmake_install_dir, "python", "cv2", "__init__.py"), '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(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'scripts', '__init__.py'), 'r') as custom_init:
custom_init_data = custom_init.read()
Expand Down

0 comments on commit 053e8cc

Please sign in to comment.