From 985506c251bcf47d0665cb4019b7d87cd60cb99c Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Mon, 15 Jan 2024 10:53:14 +0300 Subject: [PATCH] Downgrade LIMITED_API_VERSION, if python3 is older than 3.6. --- cmake/OpenCVDetectPython.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmake/OpenCVDetectPython.cmake b/cmake/OpenCVDetectPython.cmake index 839ec1148d..a23fba6e5a 100644 --- a/cmake/OpenCVDetectPython.cmake +++ b/cmake/OpenCVDetectPython.cmake @@ -295,7 +295,12 @@ find_python("${OPENCV_PYTHON3_VERSION}" "${MIN_VER_PYTHON3}" PYTHON3_LIBRARY PYT OCV_OPTION(PYTHON3_LIMITED_API "Build with Python Limited API (not available with numpy >=1.15 <1.17)" NO VISIBLE_IF PYTHON3_NUMPY_VERSION VERSION_LESS "1.15" OR NOT PYTHON3_NUMPY_VERSION VERSION_LESS "1.17") if(PYTHON3_LIMITED_API) - set(PYTHON3_LIMITED_API_VERSION "0x03060000" CACHE STRING "Minimal Python version for Limited API") + set(_default_ver "0x03060000") + if(PYTHON3_VERSION_STRING VERSION_LESS "3.6") + # fix for older pythons + set(_default_ver "0x030${PYTHON3_VERSION_MINOR}0000") + endif() + set(PYTHON3_LIMITED_API_VERSION ${_default_ver} CACHE STRING "Minimal Python version for Limited API") endif() if(PYTHON_DEFAULT_EXECUTABLE)