Skip to content

Commit

Permalink
Tools: Fix silent failure about the incompatible Python
Browse files Browse the repository at this point in the history
  • Loading branch information
dobairoland committed Feb 16, 2022
1 parent 0d03c17 commit a93e372
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 9 deletions.
3 changes: 3 additions & 0 deletions export.bat
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ if not "%MISSING_REQUIREMENTS%" == "" goto :__error_missing_requirements
set IDF_PATH=%~dp0
set IDF_PATH=%IDF_PATH:~0,-1%

echo Checking Python compatibility
python.exe "%IDF_PATH%\tools\python_version_checker.py"

set "IDF_TOOLS_PY_PATH=%IDF_PATH%\tools\idf_tools.py"
set "IDF_TOOLS_JSON_PATH=%IDF_PATH%\tools\tools.json"
set "IDF_TOOLS_EXPORT_CMD=%IDF_PATH%\export.bat"
Expand Down
3 changes: 3 additions & 0 deletions export.fish
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ function __main
echo "Detecting the Python interpreter"
source "$IDF_PATH"/tools/detect_python.fish

echo "Checking Python compatibility"
"$ESP_PYTHON" "$IDF_PATH"/tools/python_version_checker.py

echo "Adding ESP-IDF tools to PATH..."
# Call idf_tools.py to export tool paths
set -x IDF_TOOLS_EXPORT_CMD "$IDF_PATH"/export.fish
Expand Down
3 changes: 3 additions & 0 deletions export.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ $IDF_PATH = $PSScriptRoot
Write-Output "Setting IDF_PATH: $IDF_PATH"
$env:IDF_PATH = $IDF_PATH

Write-Output "Checking Python compatibility"
python $IDF_PATH/tools/python_version_checker.py

Write-Output "Adding ESP-IDF tools to PATH..."
$OLD_PATH = $env:PATH.split($S) | Select-Object -Unique # array without duplicates
# using idf_tools.py to get $envars_array to set
Expand Down
3 changes: 3 additions & 0 deletions export.sh
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ __main() {
echo "Detecting the Python interpreter"
. "${IDF_PATH}/tools/detect_python.sh"

echo "Checking Python compatibility"
"$ESP_PYTHON" "${IDF_PATH}/tools/python_version_checker.py"

__verbose "Adding ESP-IDF tools to PATH..."
# Call idf_tools.py to export tool paths
export IDF_TOOLS_EXPORT_CMD=${IDF_PATH}/export.sh
Expand Down
3 changes: 3 additions & 0 deletions install.fish
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ set -x IDF_PATH $basedir
echo "Detecting the Python interpreter"
source "$IDF_PATH"/tools/detect_python.fish

echo "Checking Python compatibility"
"$ESP_PYTHON" "$IDF_PATH"/tools/python_version_checker.py

set TARGETS ("$ESP_PYTHON" "$IDF_PATH"/tools/install_util.py extract targets $argv) || exit 1

echo "Installing ESP-IDF tools"
Expand Down
3 changes: 3 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ export IDF_PATH
echo "Detecting the Python interpreter"
. "${IDF_PATH}/tools/detect_python.sh"

echo "Checking Python compatibility"
"${ESP_PYTHON}" "${IDF_PATH}/tools/python_version_checker.py"

TARGETS=`"${ESP_PYTHON}" "${IDF_PATH}/tools/install_util.py" extract targets "$@"`

echo "Installing ESP-IDF tools"
Expand Down
1 change: 1 addition & 0 deletions tools/ci/executable-list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ tools/ldgen/test/test_output_commands.py
tools/mass_mfg/mfg_gen.py
tools/mkdfu.py
tools/mkuf2.py
tools/python_version_checker.py
tools/set-submodules-to-github.sh
tools/test_apps/system/no_embedded_paths/check_for_file_paths.py
tools/test_idf_monitor/run_test_idf_monitor.py
Expand Down
9 changes: 0 additions & 9 deletions tools/install_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,6 @@
import argparse
from itertools import chain

try:
import python_version_checker

# check the Python version before it will fail with an exception on syntax or package incompatibility.
python_version_checker.check()
except RuntimeError as e:
print(e)
raise SystemExit(1)


def action_extract_features(args: str) -> None:
"""
Expand Down
6 changes: 6 additions & 0 deletions tools/python_version_checker.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env python
#
# SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
#
# SPDX-License-Identifier: Apache-2.0
Expand Down Expand Up @@ -37,3 +39,7 @@ def check(): # type: () -> None
_ver_to_str(OLDEST_PYTHON_SUPPORTED), _ver_to_str(sys.version_info[:3])
)
)


if __name__ == '__main__':
check()

0 comments on commit a93e372

Please sign in to comment.