2021-02-02 07:20:09 -05:00
# This file should be sourced, not executed!
#
# This is a port of detect_python.sh. More information are provided there.
2022-02-24 09:25:59 -05:00
set OLDEST_PYTHON_SUPPORTED_MAJOR 3
set OLDEST_PYTHON_SUPPORTED_MINOR 7
2021-02-02 07:20:09 -05:00
2023-07-17 10:55:41 -04:00
set -q ESP_PYTHON ; or set PYLIST python3 python python3.7 python3.8 python3.9 python3.10 python3.11 python3.12
set -q ESP_PYTHON ; or set -x ESP_PYTHON python
2022-03-11 04:56:11 -05:00
2023-07-17 10:55:41 -04:00
for p_cmd in $PYLIST ;
2022-02-24 09:25:59 -05:00
$p_cmd --version > /dev/null 2 > & 1 ; or continue
2021-02-02 07:20:09 -05:00
echo " Checking \" $p_cmd \" ... "
2022-02-24 09:25:59 -05:00
$p_cmd -c " import sys; exit(1) if sys.version_info.major < int(\" $OLDEST_PYTHON_SUPPORTED_MAJOR \") else exit(0); " ; or continue
$p_cmd -c " import sys; exit(1) if sys.version_info.minor < int(\" $OLDEST_PYTHON_SUPPORTED_MINOR \") else exit(0); " ; or continue
2021-02-02 07:20:09 -05:00
2022-02-24 09:25:59 -05:00
set ESP_PYTHON $p_cmd
break
2021-02-02 07:20:09 -05:00
end
2022-02-24 09:25:59 -05:00
test -n " $ESP_PYTHON " ; or echo " Python $OLDEST_PYTHON_SUPPORTED_MAJOR . $OLDEST_PYTHON_SUPPORTED_MINOR + is not installed! Please see the documentation for how to install it. "
test -n " $ESP_PYTHON " ; or exit 1
$ESP_PYTHON --version
echo " $ESP_PYTHON has been detected "