From 36b5b13797bb2c87aa92bd3cfe255cb462fbdf5f Mon Sep 17 00:00:00 2001 From: Kshitij Sisodia Date: Fri, 9 Jun 2023 11:58:26 +0100 Subject: MLECO-4065: Revising scripts to use Python3.9 Revising documentation and scripts to use Python3.9 explicitly to remove the need for installing it system-wide that might break a distro's desktop and pacakge manager utilities. Change-Id: I683b55dd0243d0a726dc94eba2431005d4897c8c Signed-off-by: Kshitij Sisodia --- scripts/cmake/source_gen_utils.cmake | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/cmake/source_gen_utils.cmake b/scripts/cmake/source_gen_utils.cmake index 95b3ba4..6287cb6 100644 --- a/scripts/cmake/source_gen_utils.cmake +++ b/scripts/cmake/source_gen_utils.cmake @@ -284,14 +284,26 @@ function(setup_source_generator) return() endif () + # If environment is not found, find the required Python version + # and create it. + find_package(Python3 3.9 + COMPONENTS Interpreter + REQUIRED) + + if (NOT Python3_FOUND) + message(FATAL_ERROR "Required version of Python3 not found!") + else() + message(STATUS "Python3 (v${Python3_VERSION}) found: ${Python3_EXECUTABLE}") + endif() + message(STATUS "Configuring python environment at ${PYTHON}") execute_process( - COMMAND ${PY_EXEC} -m venv ${DEFAULT_VENV_DIR} + COMMAND ${Python3_EXECUTABLE} -m venv ${DEFAULT_VENV_DIR} RESULT_VARIABLE return_code ) if (NOT return_code STREQUAL "0") - message(FATAL_ERROR "Failed to setup python3 environment. Return code: ${return_code}") + message(FATAL_ERROR "Failed to setup Python3 environment. Return code: ${return_code}") endif () execute_process( -- cgit v1.2.1