Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

[PyAPI][CMAKE] Fixed pyversion detection (#32905)

Mikhail Ryzhovd241586e66fa
diff --git a/cmake/developer_package/packaging/packaging.cmake b/cmake/developer_package/packaging/packaging.cmake
index e695349c1e9..c8a8cae2c71 100644
--- a/cmake/developer_package/packaging/packaging.cmake
+++ b/cmake/developer_package/packaging/packaging.cmake
@@ -138,7 +138,7 @@ function(ov_get_pyversion pyversion)
find_package(Python3 QUIET COMPONENTS Interpreter Develoment.Module)
if(Python3_Interpreter_FOUND)
set(_pyversion "python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}")
- if(Python3_SOABI AND Python3_SOABI MATCHES "cpython-[0-9]+t-")
+ if(Python3_SOABI AND (Python3_SOABI MATCHES "cpython-[0-9]+t-" OR Python3_SOABI MATCHES "cp[0-9]+t-"))
set(_pyversion "${_pyversion}t")
endif()
set(${pyversion} "${_pyversion}" PARENT_SCOPE)
diff --git a/src/bindings/python/CMakeLists.txt b/src/bindings/python/CMakeLists.txt
index 830df464d48..13439135f50 100644
--- a/src/bindings/python/CMakeLists.txt
+++ b/src/bindings/python/CMakeLists.txt
@@ -214,10 +214,7 @@ add_subdirectory(src/pyopenvino)
macro(ov_define_setup_py_packaging_vars)
# Python3_VERSION_MAJOR and Python3_VERSION_MINOR are defined inside pybind11
- set(pyversion python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR})
- if(Python3_SOABI AND Python3_SOABI MATCHES "cpython-[0-9]+t-")
- set(pyversion "${pyversion}t")
- endif()
+ ov_get_pyversion(pyversion)
# define version (syncronize with tools/openvino_dev/CMakeLists.txt)
if(DEFINED ENV{CI_BUILD_DEV_TAG} AND NOT "$ENV{CI_BUILD_DEV_TAG}" STREQUAL "")
diff --git a/src/bindings/python/src/pyopenvino/CMakeLists.txt b/src/bindings/python/src/pyopenvino/CMakeLists.txt
index 28c3659a5b3..31c392d469f 100644
--- a/src/bindings/python/src/pyopenvino/CMakeLists.txt
+++ b/src/bindings/python/src/pyopenvino/CMakeLists.txt
@@ -7,11 +7,7 @@ if(NOT DEFINED OpenVINO_SOURCE_DIR)
find_package(OpenVINODeveloperPackage REQUIRED)
endif()
-# Python3_VERSION_MAJOR and Python3_VERSION_MINOR are defined by FindPython3
-set(pyversion python${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR})
-if(Python3_SOABI AND Python3_SOABI MATCHES "cpython-[0-9]+t-")
- set(pyversion "${pyversion}t")
-endif()
+ov_get_pyversion(pyversion)
if(OV_GENERATOR_MULTI_CONFIG)
set(PYTHON_BRIDGE_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/$<CONFIG>/python/openvino)