Skip to content

Commit

Permalink
Robust detection of Cython version (openvinotoolkit#19537)
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov authored and p-wysocki committed Sep 1, 2023
1 parent b1a7b28 commit cc2b8c6
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
12 changes: 5 additions & 7 deletions src/bindings/python/src/compatibility/openvino/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ endif()

include (cmake/UseCython.cmake)

# Ticket 119312
# # Check Cython version
# if(CYTHON_VERSION VERSION_LESS "0.29")
# message(FATAL_ERROR "OpenVINO Python API needs at least Cython version 0.29, found version ${CYTHON_VERSION}")
# else()
# message(STATUS "Found Cython version ${CYTHON_VERSION}")
# endif()
if(CYTHON_VERSION VERSION_LESS 0.29)
message(FATAL_ERROR "OpenVINO Python API needs at least Cython version 0.29, found version ${CYTHON_VERSION}")
else()
message(STATUS "Found Cython version ${CYTHON_VERSION}")
endif()

set(pyversion python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,30 @@ include( FindPackageHandleStandardArgs )
FIND_PACKAGE_HANDLE_STANDARD_ARGS( Cython REQUIRED_VARS CYTHON_EXECUTABLE )

# Find Cython version
execute_process(COMMAND ${CYTHON_EXECUTABLE} -V ERROR_VARIABLE CYTHON_OUTPUT OUTPUT_QUIET)
string(REGEX REPLACE "^Cython version ([0-9]+\\.[0-9]+(\\.[0-9]+)?).*" "\\1" CYTHON_VERSION "${CYTHON_OUTPUT}")
execute_process(COMMAND ${CYTHON_EXECUTABLE} -V
ERROR_VARIABLE CYTHON_OUTPUT
OUTPUT_VARIABLE CYTHON_ERROR_MESSAGE
RESULT_VARIABLE CYTHON_EXIT_CODE
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(CYTHON_EXIT_CODE EQUAL 0)
if(NOT CYTHON_OUTPUT)
set(CYTHON_OUTPUT "${CYTHON_ERROR_MESSAGE}")
endif()
string(REGEX REPLACE "^Cython version ([0-9]+\\.[0-9]+(\\.[0-9]+)?).*" "\\1" CYTHON_VERSION "${CYTHON_OUTPUT}")
else()
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY)
set(CYTHON_MESSAGE_MODE TRACE)
endif()
if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED)
set(CYTHON_MESSAGE_MODE FATAL_ERROR)
endif()
message(${CYTHON_MESSAGE_MODE} "Failed to detect cython version: ${CYTHON_ERROR_MESSAGE}")
unset(CYTHON_MESSAGE_MODE)
endif()

unset(CYTHON_OUTPUT)
unset(CYTHON_EXIT_CODE)
unset(CYTHON_ERROR_MESSAGE)

mark_as_advanced( CYTHON_EXECUTABLE CYTHON_VERSION )

0 comments on commit cc2b8c6

Please sign in to comment.