Skip to content

Commit

Permalink
Backport Robust detection of Cython version (openvinotoolkit#19537) (o…
Browse files Browse the repository at this point in the history
…penvinotoolkit#19547)

* Robust detection of Cython version (openvinotoolkit#19537)

* Aligned protobuf version in conanfile.txt with onnx recipe (openvinotoolkit#19525)

---------

Co-authored-by: Ilya Lavrenov <[email protected]>
  • Loading branch information
p-wysocki and ilya-lavrenov committed Sep 28, 2023
1 parent 3881079 commit 1a19070
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ endif()
include (cmake/UseCython.cmake)

# Check Cython version
if(CYTHON_VERSION VERSION_LESS "0.29")
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}")
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 1a19070

Please sign in to comment.