1# This file should be sourced, not executed!
2#
3# This is a port of detect_python.sh. More information are provided there.
4
5set -x ESP_PYTHON python
6
7for p_cmd in python python3;
8    echo "Checking \"$p_cmd\" ..."
9
10    set res ($p_cmd -c "import sys; print(sys.version_info.major)")
11    if [ "$res" = "3" ]
12        set -x ESP_PYTHON $p_cmd
13        break
14    end
15end
16
17$ESP_PYTHON --version
18if [ $status -ne 0 ]
19    echo "\"$ESP_PYTHON\" is not installed! Please see the documentation for how to install it."
20    # The following exit skips the rest of this file but won't exit fish where the script was sourced. This is not a
21    # fatal issue.
22    exit 1
23end
24
25echo "\"$ESP_PYTHON\" has been detected"
26