-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpython.cmake
More file actions
64 lines (56 loc) · 1.83 KB
/
Copy pathpython.cmake
File metadata and controls
64 lines (56 loc) · 1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Check and install python3
execute_process(
COMMAND python3 --version
RESULT_VARIABLE PYTHON_EXIT_CODE
OUTPUT_QUIET
ERROR_QUIET
)
if (PYTHON_EXIT_CODE EQUAL 0)
message(STATUS "python3 is installed and working.")
else ()
message(STATUS "Attempting to install python...")
execute_process(
COMMAND apt update
RESULT_VARIABLE APT_UPDATE_RESULT
OUTPUT_VARIABLE APT_UPDATE_OUT
ERROR_VARIABLE APT_UPDATE_ERR
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND apt install -y python3.10
RESULT_VARIABLE APT_PYTHON_RESULT
OUTPUT_VARIABLE APT_PYTHON_OUT
ERROR_VARIABLE APT_PYTHON_ERR
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
)
message(STATUS "${APT_PYTHON_OUT}")
if (NOT APT_PYTHON_RESULT EQUAL 0)
message(WARNING "Failed to install python: ${APT_PYTHON_ERR}")
endif ()
endif ()
# Check and install python venv module
execute_process(
COMMAND python3.10 -m venv --help
RESULT_VARIABLE VENV_CHECK_RESULT
OUTPUT_QUIET
ERROR_QUIET
)
if (VENV_CHECK_RESULT EQUAL 0)
message(STATUS "python3.10 venv module is available.")
else ()
message(STATUS "Attempting to install python venv module...")
execute_process(
COMMAND apt install -y python3.10-venv
RESULT_VARIABLE APT_VENV_RESULT
OUTPUT_VARIABLE APT_VENV_OUT
ERROR_VARIABLE APT_VENV_ERR
OUTPUT_STRIP_TRAILING_WHITESPACE
ERROR_STRIP_TRAILING_WHITESPACE
)
message(STATUS "${APT_VENV_OUT}")
if (NOT APT_VENV_RESULT EQUAL 0)
message(WARNING "Failed to install python venv module: ${APT_VENV_ERR}")
endif ()
endif ()