Skip to content

Commit

Permalink
Merge branch 'feature/idf_path_order_check' into 'master'
Browse files Browse the repository at this point in the history
feat(tools): Added IDF path order check for Windows platform

Closes IDF-2430

See merge request espressif/esp-idf!26629
  • Loading branch information
dobairoland committed Oct 25, 2023
2 parents 9f6bf3b + cde207e commit d78d008
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/idf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
9 changes: 9 additions & 0 deletions tools/idf_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down

0 comments on commit d78d008

Please sign in to comment.