From a93e3723641c6cfd858805a97a7ef0667862d659 Mon Sep 17 00:00:00 2001 From: Roland Dobai Date: Tue, 15 Feb 2022 18:36:46 +0100 Subject: [PATCH] Tools: Fix silent failure about the incompatible Python --- export.bat | 3 +++ export.fish | 3 +++ export.ps1 | 3 +++ export.sh | 3 +++ install.fish | 3 +++ install.sh | 3 +++ tools/ci/executable-list.txt | 1 + tools/install_util.py | 9 --------- tools/python_version_checker.py | 6 ++++++ 9 files changed, 25 insertions(+), 9 deletions(-) mode change 100644 => 100755 tools/python_version_checker.py diff --git a/export.bat b/export.bat index c54f35049d..1faf0a0678 100644 --- a/export.bat +++ b/export.bat @@ -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" diff --git a/export.fish b/export.fish index 799fa5e872..755b908c00 100644 --- a/export.fish +++ b/export.fish @@ -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 diff --git a/export.ps1 b/export.ps1 index f6fbb9eed0..b1aa6c9624 100644 --- a/export.ps1 +++ b/export.ps1 @@ -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 diff --git a/export.sh b/export.sh index dc7170bd9f..b757481942 100644 --- a/export.sh +++ b/export.sh @@ -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 diff --git a/install.fish b/install.fish index 47b9aeb592..0cb6e694c3 100755 --- a/install.fish +++ b/install.fish @@ -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" diff --git a/install.sh b/install.sh index 0036023908..6c48b25482 100755 --- a/install.sh +++ b/install.sh @@ -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" diff --git a/tools/ci/executable-list.txt b/tools/ci/executable-list.txt index 8b90ef1644..e8e3bf4751 100644 --- a/tools/ci/executable-list.txt +++ b/tools/ci/executable-list.txt @@ -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 diff --git a/tools/install_util.py b/tools/install_util.py index 5b66e09fa2..c2e01c56ec 100644 --- a/tools/install_util.py +++ b/tools/install_util.py @@ -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: """ diff --git a/tools/python_version_checker.py b/tools/python_version_checker.py old mode 100644 new mode 100755 index 740aadc8cd..48a13a90dc --- a/tools/python_version_checker.py +++ b/tools/python_version_checker.py @@ -1,3 +1,5 @@ +#!/usr/bin/env python +# # SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD # # SPDX-License-Identifier: Apache-2.0 @@ -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()