mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-07 20:00:53 +00:00
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:
@@ -285,3 +285,15 @@ check_doc_links:
|
||||
- test "${CI_COMMIT_REF_NAME}" = "master" || exit 0
|
||||
- cd docs
|
||||
- make linkcheck
|
||||
|
||||
test_detect_python:
|
||||
extends: .host_test_template
|
||||
image: $CI_DOCKER_REGISTRY/linux-shells:1
|
||||
script:
|
||||
- cd ${IDF_PATH}
|
||||
- shellcheck -s sh tools/detect_python.sh
|
||||
- shellcheck -s bash tools/detect_python.sh
|
||||
- shellcheck -s dash tools/detect_python.sh
|
||||
- "bash -c '. tools/detect_python.sh && echo Our Python: ${ESP_PYTHON?Python is not set}'"
|
||||
- "dash -c '. tools/detect_python.sh && echo Our Python: ${ESP_PYTHON?Python is not set}'"
|
||||
- "zsh -c '. tools/detect_python.sh && echo Our Python: ${ESP_PYTHON?Python is not set}'"
|
||||
|
24
tools/detect_python.sh
Normal file
24
tools/detect_python.sh
Normal file
@@ -0,0 +1,24 @@
|
||||
# This file should be sourced, not executed!
|
||||
#
|
||||
# This is a helper script for detecting Python executables in the PATH. It is intended to be used for determining
|
||||
# which Python should be used with idf_tools.py for installing tools and exporting environment variables.
|
||||
#
|
||||
# 1. The script will set variable ESP_PYTHON to "python" if it is of version 3.
|
||||
# 2. Otherwise, "python3" will be exported if it exists.
|
||||
# 3. The script will fall-back to "python" as the last resort and fail if it doesn't exist.
|
||||
|
||||
ESP_PYTHON=python
|
||||
|
||||
for p_cmd in python python3
|
||||
do
|
||||
echo "Checking \"$p_cmd\" ..."
|
||||
|
||||
if [ "$($p_cmd -c "import sys; print(sys.version_info.major)")" = 3 ]; then
|
||||
ESP_PYTHON=$p_cmd
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
$ESP_PYTHON --version || { echo "\"$ESP_PYTHON\" is not installed! Please see the documentation for how to install it."; exit 1; }
|
||||
|
||||
echo "\"$ESP_PYTHON\" has been detected"
|
Reference in New Issue
Block a user