tools: Prefer python3 during install and export

Install and export script should work on systems without "python"
executable.

Closes https://github.com/espressif/esp-idf/pull/6471

Closes https://github.com/espressif/esp-idf/issues/6532

Related to https://github.com/espressif/esp-idf/issues/6421 and
https://github.com/espressif/arduino-esp32/issues/4717
This commit is contained in:
Roland Dobai
2021-02-02 13:20:09 +01:00
parent e22de81955
commit 47f67f8b81
11 changed files with 90 additions and 100 deletions

25
tools/detect_python.fish Normal file
View File

@@ -0,0 +1,25 @@
# This file should be sourced, not executed!
#
# This is a port of detect_python.sh. More information are provided there.
set -x ESP_PYTHON python
for p_cmd in python python3;
echo "Checking \"$p_cmd\" ..."
set res ($p_cmd -c "import sys; print(sys.version_info.major)")
if [ "$res" = "3" ]
set -x ESP_PYTHON $p_cmd
break
end
end
$ESP_PYTHON --version
if [ $status -ne 0 ]
echo "\"$ESP_PYTHON\" is not installed! Please see the documentation for how to install it."
# The following exit skips the rest of this file but won't exit fish where the script was sourced. This is not a
# fatal issue.
exit 1
end
echo "\"$ESP_PYTHON\" has been detected"