1
0
mirror of https://github.com/gnss-sdr/gnss-sdr synced 2024-10-31 23:26:22 +00:00

Try hard to find Python version

This commit is contained in:
Carles Fernandez 2023-10-13 11:38:54 +02:00
parent 30f624e548
commit c47ad2d902
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
2 changed files with 34 additions and 2 deletions

View File

@ -146,7 +146,26 @@ else()
endif()
gnsssdr_python_check_module("python >= ${GNSSSDR_PYTHON_MIN_VERSION}" sys "sys.version.split()[0] >= '${GNSSSDR_PYTHON_MIN_VERSION}'" PYTHON_MIN_VER_FOUND)
gnsssdr_python_check_module("mako >= ${GNSSSDR_MAKO_MIN_VERSION}" mako "mako.__version__ >= '${GNSSSDR_MAKO_MIN_VERSION}'" MAKO_FOUND)
if(PYTHON_VERSION_STRING VERSION_LESS "3.0")
if(NOT MAKO_FOUND)
unset(PYTHON_EXECUTABLE)
unset(PYTHON_VERSION_STRING)
unset(PYTHON_VERSION_MAJOR)
find_program(PYTHON_EXECUTABLE NAMES python3 python)
if(PYTHON_EXECUTABLE)
set(PYTHONINTERP_FOUND TRUE)
execute_process(COMMAND "${PYTHON_EXECUTABLE} --version" OUTPUT_VARIABLE PYTHON_VERSION_STRING_AUX)
string(FIND "${PYTHON_VERSION_STRING_AUX}" " " blank_char_index)
if(blank_char_index GREATER -1)
math(EXPR start_index "${blank_char_index} + 1")
string(SUBSTRING "${PYTHON_VERSION_STRING_AUX}" ${start_index} -1 PYTHON_VERSION_STRING)
string(STRIP ${PYTHON_VERSION_STRING} PYTHON_VERSION_STRING)
string(SUBSTRING "${PYTHON_VERSION_STRING_AUX}" ${start_index} 1 PYTHON_VERSION_MAJOR)
message(STATUS "Found Python: ${PYTHON_EXECUTABLE} (found version: ${PYTHON_VERSION_STRING})")
endif()
endif()
volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND)
endif()
if(MAKO_FOUND AND PYTHON_VERSION_STRING VERSION_LESS "3.0")
gnsssdr_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND)
endif()
endif()

View File

@ -146,11 +146,24 @@ else()
volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND)
if(NOT MAKO_FOUND)
unset(PYTHON_EXECUTABLE)
unset(PYTHON_VERSION_STRING)
find_program(PYTHON_EXECUTABLE NAMES python3 python)
if(PYTHON_EXECUTABLE)
set(PYTHONINTERP_FOUND TRUE)
execute_process(COMMAND ${PYTHON_EXECUTABLE} --version OUTPUT_VARIABLE PYTHON_VERSION_STRING_AUX)
string(FIND "${PYTHON_VERSION_STRING_AUX}" " " blank_char_index)
if(blank_char_index GREATER -1)
math(EXPR start_index "${blank_char_index} + 1")
string(SUBSTRING "${PYTHON_VERSION_STRING_AUX}" ${start_index} -1 PYTHON_VERSION_STRING)
string(STRIP ${PYTHON_VERSION_STRING} PYTHON_VERSION_STRING)
string(SUBSTRING "${PYTHON_VERSION_STRING_AUX}" ${start_index} 1 PYTHON_VERSION_MAJOR)
message(STATUS "Found Python: ${PYTHON_EXECUTABLE} (found version: ${PYTHON_VERSION_STRING})")
endif()
volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND)
if(MAKO_FOUND AND PYTHON_VERSION_STRING VERSION_LESS "3.0")
gnsssdr_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND)
endif()
endif()
endif()
endif()
endif()