Skip to content

Commit 4507a47

Browse files
committed
Handle setup with and without PYTHON3_LIMITED_API.
1 parent f9de34e commit 4507a47

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

setup.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,14 @@ def _classify_installed_files_override(
395395
# add lines from the old __init__.py file to the config file
396396
with open(os.path.join(os.path.dirname(os.path.abspath(__file__)), 'scripts', '__init__.py'), 'r') as custom_init:
397397
custom_init_data = custom_init.read()
398-
with open('%spython/cv2/config-%s.py'
399-
% (cmake_install_dir, sys.version_info[0]), 'w') as opencv_init_config:
398+
399+
# OpenCV generates config with different name for case with PYTHON3_LIMITED_API=ON
400+
config_py = os.path.join(cmake_install_dir 'python', 'cv2', 'config-%s.%s.py'
401+
% (sys.version_info[0], sys.version_info[1]))
402+
if not os.path.exists(config_py):
403+
config_py = os.path.join(cmake_install_dir 'python', 'cv2', 'config-%s.py' % sys.version_info[0])
404+
405+
with open(config_py, 'w') as opencv_init_config:
400406
opencv_init_config.write(custom_init_data)
401407

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

0 commit comments

Comments
 (0)