Skip to content

Commit bd613f1

Browse files
committed
Change Cython version checking to match the way Cython is used (through import, rather than cython executable). Prevents a problem when PYTHON passed in to CMake differs from the default python and cython found in the path. Also, much simpler than finding cython and asking it for the version.
Former-commit-id: 312f1d6
1 parent f22e375 commit bd613f1

File tree

2 files changed

+13
-60
lines changed

2 files changed

+13
-60
lines changed

cmake/FindCython.cmake

-58
This file was deleted.

python/CMakeLists.txt

+13-2
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,24 @@ function(get_filename_components DEST ITEMS PART)
88
set(${DEST} ${${DEST}} PARENT_SCOPE)
99
endfunction()
1010

11+
function(check_cython_version VERSION)
12+
# We use the Cython library directly within Python, make sure it is installed
13+
# and meets the minimum version required.
14+
execute_process(COMMAND ${PYTHON} -c "import Cython; print Cython.__version__;" OUTPUT_VARIABLE CYTHON_VERSION)
15+
if(${CYTHON_VERSION} VERSION_LESS ${VERSION})
16+
message(FATAL_ERROR "DyNet needs at least Cython version ${VERSION}, found verson ${CYTHON_VERSION}")
17+
else()
18+
message(STATUS "Found Cython version ${CYTHON_VERSION}")
19+
endif()
20+
endfunction()
21+
1122
if(!PYTHON)
1223
find_program(PYTHON "python")
1324
endif()
1425

1526
if(PYTHON)
16-
# look for Cython
17-
find_package(Cython REQUIRED)
27+
# Verify Cython is installed with the given minimum version
28+
check_cython_version(0.23)
1829

1930
# Things to copy the files
2031
file(GLOB DepFiles ${CMAKE_CURRENT_SOURCE_DIR}/dynet.py

0 commit comments

Comments
 (0)