Tools: Allow custom Python installation path with IDF_PYTHON_ENV_PATH

IDF_PYTHON_ENV_PATH is the path where the Python environment is created
and used. By default it is inside IDF_TOOLS_PATH. IDF_PYTHON_ENV_PATH
was exported by idf_tools.py but was not imported back. This fixes the
issue and ESP-IDF will honor the value of IDF_PYTHON_ENV_PATH.

Closes https://github.com/espressif/esp-idf/issues/10489
This commit is contained in:
Roland Dobai
2023-02-14 16:14:54 +01:00
parent 6f0bea38cd
commit afe554c753
3 changed files with 26 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
# SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
# SPDX-License-Identifier: Apache-2.0
import inspect
@@ -6,6 +6,7 @@ import os
import shutil
import subprocess
import sys
import tempfile
import unittest
from typing import List
@@ -80,5 +81,25 @@ class TestPythonInstall(unittest.TestCase):
self.assertIn(REQ_CORE, output)
class TestCustomPythonPathInstall(TestPythonInstall):
def setUp(self): # type: () -> None
self.CUSTOM_PYTHON_DIR = tempfile.mkdtemp()
self.addCleanup(shutil.rmtree, self.CUSTOM_PYTHON_DIR)
os.environ['IDF_PYTHON_ENV_PATH'] = self.CUSTOM_PYTHON_DIR
def test_default_arguments(self): # type: () -> None
output = self.run_idf_tools(['check-python-dependencies'])
self.assertIn(f"{self.CUSTOM_PYTHON_DIR}/bin/python doesn't exist", output)
self.assertNotIn(PYTHON_DIR, output)
output = self.run_idf_tools(['install-python-env'])
self.assertIn(self.CUSTOM_PYTHON_DIR, output)
self.assertNotIn(PYTHON_DIR, output)
output = self.run_idf_tools(['check-python-dependencies'])
self.assertIn(self.CUSTOM_PYTHON_DIR, output)
if __name__ == '__main__':
unittest.main()