Skip to content

Commit

Permalink
Moved back extra module imports
Browse files Browse the repository at this point in the history
  • Loading branch information
asenyaev committed Dec 8, 2021
1 parent a86bbc8 commit 3f6c52e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
7 changes: 2 additions & 5 deletions scripts/config-override.py
@@ -1,13 +1,9 @@
import os

BINARIES_PATHS = [
os.path.join(os.path.join(LOADER_DIR, '../'), 'opencv_python.libs')
] + BINARIES_PATHS
import sys

ci_and_not_headless = False

try:
from . import data
from .version import ci_build, headless

ci_and_not_headless = ci_build and not headless
Expand All @@ -25,3 +21,4 @@
os.environ["QT_QPA_FONTDIR"] = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "qt", "fonts"
)

5 changes: 5 additions & 0 deletions scripts/init-override.py
@@ -0,0 +1,5 @@
from . import data
from . import gapi
from . import mat_wrapper
from . import misc
from . import utils
13 changes: 8 additions & 5 deletions setup.py
Expand Up @@ -366,15 +366,19 @@ def _classify_installed_files_override(

print("Copying files from CMake output")

# rewrite the path to libs in case of docker builds write it's own in config.py
# also defines extra environment for not headless packages
# lines for a proper work using an autocomplete in IDE
with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'scripts', 'init-override.py'), 'r') as init_override:
init_override_data = init_override.read()
with open(os.path.join(cmake_install_dir, "python", "cv2", "__init__.py"), 'a') as opencv_init:
opencv_init.write(init_override_data)

# append extra environment for not headless packages
with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'scripts', 'config-override.py'), 'r') as config_override:
config_override_data = config_override.read()
with open(os.path.join(cmake_install_dir, 'python', 'cv2', 'config.py'), 'w') as opencv_config:
with open(os.path.join(cmake_install_dir, 'python', 'cv2', 'config.py'), 'a') as opencv_config:
opencv_config.write(config_override_data)

for package_name, relpaths_re in cls.package_paths_re.items():
print(package_name, relpaths_re)
if package_name != os.path.join("cv2", "python-%s.%s" % (sys.version_info[0], sys.version_info[1])):
package_dest_reldir = package_name.replace(".", os.path.sep)
else:
Expand Down Expand Up @@ -407,7 +411,6 @@ def _classify_installed_files_override(
print("Copying files from non-default sourcetree locations")

for package_name, paths in cls.files_outside_package.items():
print(package_name, paths)
if package_name != os.path.join("cv2", "python-%s.%s" % (sys.version_info[0], sys.version_info[1])):
package_dest_reldir = package_name.replace(".", os.path.sep)
else:
Expand Down

0 comments on commit 3f6c52e

Please sign in to comment.