diff --git a/CMake/FindPythonModule.cmake b/CMake/FindPythonModule.cmake index 190b85f210d94cdfe71a71188a13f5af5336ff0a..613350e8c797ead67d056feb7d43fc239b107227 100644 --- a/CMake/FindPythonModule.cmake +++ b/CMake/FindPythonModule.cmake @@ -61,7 +61,7 @@ macro(find_python_module _module) cmake_parse_arguments(PYTHON_${_MODULE}_FIND "REQUIRED" - "HINTS" + "HINTS;VERSION" "" ${ARGN} ) @@ -75,6 +75,7 @@ macro(find_python_module _module) # Try to import the python module we need to find, and get its file path. if(PYTHON_EXECUTABLE) set(ENV{PYTHONPATH} ${PYTHON_${_MODULE}_FIND_HINTS}:$ENV{PYTHONPATH}) + set(_cmd "from __future__ import print_function; import ${_module}; print(${_module}.__file__)") execute_process( COMMAND "${PYTHON_EXECUTABLE}" "-c" "${_cmd}" @@ -83,6 +84,19 @@ macro(find_python_module _module) ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE) + set(_cmd "from __future__ import print_function; import ${_module}; print(${_module}.__version__)") + if(${PYTHON_${_MODULE}_FIND_VERSION}) # Check the version of the module + execute_process( + COMMAND "${PYTHON_EXECUTABLE}" "-c" "${_cmd}" + RESULT_VARIABLE _result_version + OUTPUT_VARIABLE _output_version + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + message(STATUS "requested version ${PYTHON_${_module}_FIND_VERSION}") + if(${_output_version} VERSION_LESS ${PYTHON_${_MODULE}_FIND_VERSION} ) + message(FATAL_ERROR "The installed version of PYTHON_${_MODULE} is <= ${PYTHON_${_MODULE}_FIND_VERSION}" ) + endif() + endif() # Set PYTHON_<MODULE> variable in the cache, if <module> was found. if(_result EQUAL 0) set(PYTHON_${_MODULE} ${_output} CACHE FILEPATH diff --git a/LCU/Maintenance/DBInterface/CMakeLists.txt b/LCU/Maintenance/DBInterface/CMakeLists.txt index 22ab80dd164b01f66333280d8d4e8933d634fa49..996a180509068adda96bb7f1a17f1516ec75e507 100644 --- a/LCU/Maintenance/DBInterface/CMakeLists.txt +++ b/LCU/Maintenance/DBInterface/CMakeLists.txt @@ -12,7 +12,7 @@ find_python_module(django REQUIRED) find_python_module(psycopg2 REQUIRED) find_python_module(rest_framework REQUIRED) #sudo pip install djangorestframework find_python_module(requests REQUIRED) -find_python_module(celery REQUIRED) +find_python_module(celery REQUIRED VERSION 4) find_python_module(django_filters REQUIRED)