feat(tools): Added IDF path order check for Windows platform

This relates to old GH issue: https://github.com/espressif/esp-idf/issues/5994
pull/12525/head
Jakub Kocka 2023-10-23 10:51:26 +02:00
rodzic 767595a22f
commit cde207e996
2 zmienionych plików z 18 dodań i 0 usunięć

Wyświetl plik

@ -105,6 +105,15 @@ def check_environment() -> List:
debug_print_idf_version()
raise SystemExit(1)
# Check used Python interpreter
checks_output.append('Checking used Python interpreter...')
try:
python_venv_path = os.environ['IDF_PYTHON_ENV_PATH']
if python_venv_path and not sys.executable.startswith(python_venv_path):
print_warning(f'WARNING: Python interpreter "{sys.executable}" used to start idf.py is not from installed venv "{python_venv_path}"')
except KeyError:
print_warning('WARNING: The IDF_PYTHON_ENV_PATH is missing in environmental variables!')
return checks_output

Wyświetl plik

@ -1802,6 +1802,15 @@ def action_export(args): # type: ignore
if paths_to_export:
export_vars['PATH'] = path_sep.join(to_shell_specific_paths(paths_to_export) + [old_path])
# Correct PATH order check for Windows platform
# idf-exe has to be before \tools in PATH
if sys.platform == 'win32':
paths_to_check = rf"{export_vars['PATH']}{os.environ['PATH']}"
try:
if paths_to_check.index(r'\tools;') < paths_to_check.index(r'\idf-exe'):
warn('The PATH is not in correct order (idf-exe should be before esp-idf\\tools)')
except ValueError:
fatal(f'Both of the directories (..\\idf-exe\\.. and ..\\tools) has to be in the PATH:\n\n{paths_to_check}\n')
if export_vars:
# if not copy of export_vars is given to function, it brekas the formatting string for 'export_statements'