Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Robust detection of Cython version #19537

Merged
merged 1 commit into from
Sep 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 )