mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 10:47:19 +02:00
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:
@ -703,7 +703,7 @@ def main() -> None:
|
|||||||
try:
|
try:
|
||||||
os.getcwd()
|
os.getcwd()
|
||||||
except FileNotFoundError as e:
|
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:
|
try:
|
||||||
cli = init_cli(verbose_output=checks_output)
|
cli = init_cli(verbose_output=checks_output)
|
||||||
|
@ -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
|
Menuconfig target is build_target extended with the style argument for setting the value for the environment
|
||||||
variable.
|
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:
|
if sys.version_info[0] < 3:
|
||||||
# The subprocess lib cannot accept environment variables as "unicode".
|
# The subprocess lib cannot accept environment variables as "unicode".
|
||||||
# This encoding step is required only in Python 2.
|
# This encoding step is required only in Python 2.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# coding=utf-8
|
# 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
|
# 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
|
# Reinstallation of the virtual environment could help if pip was installed for the main Python
|
||||||
reinstall = True
|
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):
|
if reinstall and os.path.exists(idf_python_env_path):
|
||||||
warn('Removing the existing Python environment in {}'.format(idf_python_env_path))
|
warn('Removing the existing Python environment in {}'.format(idf_python_env_path))
|
||||||
shutil.rmtree(idf_python_env_path)
|
shutil.rmtree(idf_python_env_path)
|
||||||
|
Reference in New Issue
Block a user