Use target python packages (#19928)

This commit is contained in:
Ilya Lavrenov
2023-09-20 11:16:15 +04:00
committed by GitHub
parent 7fe195a459
commit c67c0663fc

View File

@@ -33,7 +33,7 @@ function(ov_check_python_build_conditions)
endif()
# Try to find python3 and its libs
find_host_package(PythonInterp 3 ${find_package_mode})
find_package(PythonInterp 3 ${find_package_mode})
if(PYTHONINTERP_FOUND)
if(PYTHON_VERSION_MINOR GREATER_EQUAL 11)
set(pybind11_min_version 2.9.2)
@@ -56,14 +56,14 @@ function(ov_check_python_build_conditions)
if(EXISTS ${pybind11_tools_dir})
list(APPEND CMAKE_MODULE_PATH ${pybind11_tools_dir})
else()
find_host_package(pybind11 ${pybind11_min_version} QUIET)
find_package(pybind11 ${pybind11_min_version} QUIET)
if(pybind11_FOUND)
list(APPEND CMAKE_MODULE_PATH "${pybind11_DIR}")
endif()
endif()
# use libraries with the same version as python itself
set(PYBIND11_PYTHON_VERSION ${PYTHON_VERSION_STRING})
find_host_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} EXACT ${find_package_mode})
find_package(PythonLibsNew ${PYBIND11_PYTHON_VERSION} EXACT ${find_package_mode})
set(PYTHONLIBSNEW_FOUND ${PYTHONLIBS_FOUND} PARENT_SCOPE)
endfunction()
# try to find python libraries
@@ -71,7 +71,7 @@ function(ov_check_python_build_conditions)
if(PYTHONLIBSNEW_FOUND)
# clear Python_ADDITIONAL_VERSIONS to find only python library matching PYTHON_EXECUTABLE
unset(Python_ADDITIONAL_VERSIONS CACHE)
find_host_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT ${find_package_mode})
find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT ${find_package_mode})
endif()
if(NOT PYTHONLIBS_FOUND)
message(${message_mode} "Python development libraries are not found. OpenVINO Python API will be turned off (ENABLE_PYTHON is OFF)")