Skip to content

Commit

Permalink
Handle setup with and without PYTHON3_LIMITED_API.
Browse files Browse the repository at this point in the history
  • Loading branch information
asmorkalov committed Mar 15, 2023
1 parent f9de34e commit 4507a47
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,8 +395,14 @@ def _classify_installed_files_override(
# 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()
with open('%spython/cv2/config-%s.py'
% (cmake_install_dir, sys.version_info[0]), 'w') as opencv_init_config:

# OpenCV generates config with different name for case with PYTHON3_LIMITED_API=ON
config_py = os.path.join(cmake_install_dir 'python', 'cv2', 'config-%s.%s.py'
% (sys.version_info[0], sys.version_info[1]))
if not os.path.exists(config_py):
config_py = os.path.join(cmake_install_dir 'python', 'cv2', 'config-%s.py' % sys.version_info[0])

with open(config_py, 'w') as opencv_init_config:
opencv_init_config.write(custom_init_data)

for package_name, relpaths_re in cls.package_paths_re.items():
Expand Down

0 comments on commit 4507a47

Please sign in to comment.