Skip to content

Commit

Permalink
[PyOV] Cython bug cleanup (#19546)
Browse files Browse the repository at this point in the history
* Revert "Bump cython in cmake (#19473)"

This reverts commit 35a1840.

* Disable cmake check

* Robust detection of Cython version (#19537)

---------

Co-authored-by: Ilya Lavrenov <[email protected]>
  • Loading branch information
p-wysocki and ilya-lavrenov authored Sep 2, 2023
1 parent 7f1c7c7 commit e701484
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 19 deletions.
10 changes: 2 additions & 8 deletions .ci/openvino-onnx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,11 @@ RUN apt-get update && apt-get -y --no-install-recommends install \
python3-dev \
pybind11-dev \
python3-virtualenv \
python3-venv \
cython3 \
tox && \
apt-get clean autoclean && \
apt-get autoremove -y

RUN python3 -m venv ~/.venv
RUN . ~/.venv/bin/activate
RUN which python3
RUN python3 -m pip install "cython>=3.0.0" --break-system-packages

# Build OpenVINO
COPY . /openvino/
WORKDIR /openvino/build
Expand All @@ -70,8 +65,7 @@ RUN cmake .. \
-DENABLE_OV_PYTORCH_FRONTEND=ON \
-DENABLE_OV_TF_FRONTEND=OFF \
-DENABLE_OPENVINO_DEBUG=OFF \
-DCMAKE_INSTALL_PREFIX=/openvino/dist \
-DPYTHON_EXECUTABLE=`which python3`
-DCMAKE_INSTALL_PREFIX=/openvino/dist
RUN ninja install

# Run tests via tox
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Babel==2.11.0
beautifulsoup4==4.9.3
certifi==2023.7.22
colorama==0.4.6
Cython==3.0.2
Cython==0.29.33
docutils==0.16
idna==3.4
imagesize==1.2.0
Expand Down
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)

# TODO: Reenable once Windows issue is resolved
# # Check Cython version
# if(CYTHON_VERSION VERSION_LESS "3.0.0")
# message(FATAL_ERROR "OpenVINO Python API needs at least Cython version 3.0.0, 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)
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 )
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Cython>=3.0.0
cython>=0.29.32

0 comments on commit e701484

Please sign in to comment.