From c0954cf0b280332ef4d0c1f17a68196d17da5e05 Mon Sep 17 00:00:00 2001 From: Frantisek Hrbata Date: Tue, 10 Dec 2024 08:48:43 +0100 Subject: [PATCH] fix(tools): honor IDF_PYTHON_ENV_PATH value The active.py script is currently clearing the IDF_PYTHON_ENV_PATH, preventing it from being set to a custom location for the python virtual environment directory. Although the install script checks to ensure that an existing python virtual environment is not overwritten with one for a different ESP-IDF version than it was originally created for, we should still permit setting a custom path for the python virtual environment. Closes https://github.com/espressif/esp-idf/issues/15006 Signed-off-by: Frantisek Hrbata --- tools/activate.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/activate.py b/tools/activate.py index a23ca1883e..7c325705fb 100755 --- a/tools/activate.py +++ b/tools/activate.py @@ -29,7 +29,6 @@ except ImportError as e: # Get ESP-IDF venv python path idf_tools.g.idf_path = idf_path -os.environ['IDF_PYTHON_ENV_PATH'] = '' # let idf_tools get the pyenv path idf_tools.g.idf_tools_path = os.environ.get('IDF_TOOLS_PATH') or os.path.expanduser(idf_tools.IDF_TOOLS_PATH_DEFAULT) idf_python_env_path, idf_python_export_path, virtualenv_python, idf_version = idf_tools.get_python_env_path() @@ -39,10 +38,12 @@ os.environ['IDF_PYTHON_ENV_PATH'] = idf_python_env_path os.environ['ESP_IDF_VERSION'] = idf_version if not os.path.exists(virtualenv_python): - die(f'ESP-IDF Python virtual environment not found. Please run the install script to set it up before proceeding.') + die((f'ESP-IDF Python virtual environment "{virtualenv_python}" ' + f'not found. Please run the install script to set it up before ' + f'proceeding.')) try: run([virtualenv_python, os.path.join(idf_path, 'tools', 'export_utils', 'activate_venv.py')] + sys.argv[1:], check=True, env=os.environ.copy()) -except (OSError, SubprocessError): - die('\n'.join(['Activation script failed', +except (OSError, SubprocessError) as e: + die('\n'.join(['Activation script failed', str(e), 'To view detailed debug information, set ESP_IDF_EXPORT_DEBUG=1 and run the export script again.']))