Merge branch 'bugfix/import_curses_module_check' into 'master'

Tools: curses tool existence check

Closes IDFGH-10387

See merge request espressif/esp-idf!24462
This commit is contained in:
Roland Dobai 2023-07-14 16:58:37 +08:00
commit 88f18aa54a
3 changed files with 16 additions and 2 deletions

View File

@ -703,7 +703,7 @@ def main() -> None:
try:
os.getcwd()
except FileNotFoundError as e:
raise FatalError(f'ERROR: {e}. Working directory cannot be established. Check it\'s existence.')
raise FatalError(f'ERROR: {e}. Working directory cannot be established. Check its existence.')
try:
cli = init_cli(verbose_output=checks_output)

View File

@ -62,6 +62,13 @@ def action_extensions(base_actions: Dict, project_path: str) -> Any:
Menuconfig target is build_target extended with the style argument for setting the value for the environment
variable.
"""
if sys.platform != 'win32':
try:
import curses # noqa: F401
except ImportError:
raise FatalError('\n'.join(
['', "menuconfig failed to import the standard Python 'curses' library.",
'Please re-run the install script which might be able to fix the issue.']))
if sys.version_info[0] < 3:
# The subprocess lib cannot accept environment variables as "unicode".
# This encoding step is required only in Python 2.

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)