mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 03:00:14 +08:00
Merge pull request #24837 from asmorkalov:as/python_limited_api_version
Manage Python Limited API version externally
This commit is contained in:
commit
1bde621a08
@ -1866,6 +1866,7 @@ if(BUILD_opencv_python3)
|
||||
else()
|
||||
status(" Libraries:" HAVE_opencv_python3 THEN "${PYTHON3_LIBRARIES}" ELSE NO)
|
||||
endif()
|
||||
status(" Limited API:" PYTHON3_LIMITED_API THEN "YES (ver ${PYTHON3_LIMITED_API_VERSION})" ELSE NO)
|
||||
status(" numpy:" PYTHON3_NUMPY_INCLUDE_DIRS THEN "${PYTHON3_NUMPY_INCLUDE_DIRS} (ver ${PYTHON3_NUMPY_VERSION})" ELSE "NO (Python3 wrappers can not be generated)")
|
||||
status(" install path:" HAVE_opencv_python3 THEN "${__INSTALL_PATH_PYTHON3}" ELSE "-")
|
||||
endif()
|
||||
|
@ -291,6 +291,12 @@ find_python("${OPENCV_PYTHON3_VERSION}" "${MIN_VER_PYTHON3}" PYTHON3_LIBRARY PYT
|
||||
PYTHON3_INCLUDE_DIR PYTHON3_INCLUDE_DIR2 PYTHON3_PACKAGES_PATH
|
||||
PYTHON3_NUMPY_INCLUDE_DIRS PYTHON3_NUMPY_VERSION)
|
||||
|
||||
# Problem in numpy >=1.15 <1.17
|
||||
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")
|
||||
endif()
|
||||
|
||||
if(PYTHON_DEFAULT_EXECUTABLE)
|
||||
set(PYTHON_DEFAULT_AVAILABLE "TRUE")
|
||||
|
@ -46,6 +46,7 @@ if(${PYTHON}_LIMITED_API)
|
||||
# support only python3.3+
|
||||
ocv_assert(${PYTHON}_VERSION_MAJOR EQUAL 3 AND ${PYTHON}_VERSION_MINOR GREATER 2)
|
||||
target_compile_definitions(${the_module} PRIVATE CVPY_DYNAMIC_INIT)
|
||||
target_compile_definitions(${the_module} PRIVATE PYTHON3_LIMITED_API_VERSION=${PYTHON3_LIMITED_API_VERSION})
|
||||
if(WIN32)
|
||||
string(REPLACE
|
||||
"python${${PYTHON}_VERSION_MAJOR}${${PYTHON}_VERSION_MINOR}.lib"
|
||||
|
@ -2,15 +2,6 @@ if(NOT PYTHON3_INCLUDE_PATH OR NOT PYTHON3_NUMPY_INCLUDE_DIRS)
|
||||
ocv_module_disable(python3)
|
||||
endif()
|
||||
|
||||
# Problem in numpy >=1.15 <1.17
|
||||
if(PYTHON3_LIMITED_API
|
||||
AND NOT PYTHON3_NUMPY_VERSION VERSION_LESS "1.15"
|
||||
AND PYTHON3_NUMPY_VERSION VERSION_LESS "1.17"
|
||||
)
|
||||
message(WARNING "Current NUMPY version (${PYTHON3_NUMPY_VERSION}) is not compatible with LIMITED_API.")
|
||||
set(PYTHON3_LIMITED_API OFF)
|
||||
endif()
|
||||
|
||||
set(the_description "The python3 bindings")
|
||||
set(MODULE_NAME python3)
|
||||
set(MODULE_INSTALL_SUBDIR python3)
|
||||
|
@ -13,7 +13,10 @@
|
||||
// #define Py_DEBUG
|
||||
|
||||
#if defined(CVPY_DYNAMIC_INIT) && !defined(Py_DEBUG)
|
||||
# define Py_LIMITED_API 0x03030000
|
||||
# ifndef PYTHON3_LIMITED_API_VERSION
|
||||
# define PYTHON3_LIMITED_API_VERSION 0x03060000
|
||||
# endif
|
||||
# define Py_LIMITED_API PYTHON3_LIMITED_API_VERSION
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
|
Loading…
Reference in New Issue
Block a user