diff --git a/tools/idf.py b/tools/idf.py index 6e5ef03e9d..614b955083 100755 --- a/tools/idf.py +++ b/tools/idf.py @@ -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) diff --git a/tools/idf_py_actions/core_ext.py b/tools/idf_py_actions/core_ext.py index 3068130d64..1f64fd1720 100644 --- a/tools/idf_py_actions/core_ext.py +++ b/tools/idf_py_actions/core_ext.py @@ -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. diff --git a/tools/idf_tools.py b/tools/idf_tools.py index 1cf6f489e0..8865348f6f 100755 --- a/tools/idf_tools.py +++ b/tools/idf_tools.py @@ -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)