fix(tools): Tool curses import check

Verify that curses tool can be successfully imported on unix systems

When detected:
- installing esp-idf -> reinstall python environment
- using idf.py menuconfig -> raise error with hint message

Closes https://github.com/espressif/esp-idf/issues/11643
This commit is contained in:
Marek Fiala
2023-06-28 10:44:27 +02:00
committed by BOT
parent 5995cab9c1
commit 206c46325a
3 changed files with 16 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
#!/usr/bin/env python
# coding=utf-8
#
# SPDX-FileCopyrightText: 2019-2022 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2019-2023 Espressif Systems (Shanghai) CO LTD
#
# SPDX-License-Identifier: Apache-2.0
#
@@ -2079,6 +2079,13 @@ def action_install_python_env(args): # type: ignore
# Reinstallation of the virtual environment could help if pip was installed for the main Python
reinstall = True
if sys.platform != 'win32':
try:
subprocess.check_call([virtualenv_python, '-c', 'import curses'], stdout=sys.stdout, stderr=sys.stderr)
except subprocess.CalledProcessError:
warn('curses can not be imported, new virtual environment will be created.')
reinstall = True
if reinstall and os.path.exists(idf_python_env_path):
warn('Removing the existing Python environment in {}'.format(idf_python_env_path))
shutil.rmtree(idf_python_env_path)