diff --git a/tools/kconfig/bootstrap_venv.sh b/tools/kconfig/bootstrap_venv.sh index a1830b9c3..9342100f9 100755 --- a/tools/kconfig/bootstrap_venv.sh +++ b/tools/kconfig/bootstrap_venv.sh @@ -11,9 +11,11 @@ if [[ ! -f "${REQ}" ]]; then exit 1 fi -if [[ -x "${VENV}/bin/python" ]] && "${VENV}/bin/python" -c "import kconfiglib" 2>/dev/null; then +if [[ -x "${VENV}/bin/python" ]] && "${VENV}/bin/python" -c 'import kconfiglib, sys; __import__("tomllib" if sys.version_info >= (3, 11) else "tomli")' 2>/dev/null; then exit 0 fi -python3 -m venv "${VENV}" +if [[ ! -x "${VENV}/bin/pip" ]]; then + python3 -m venv "${VENV}" +fi "${VENV}/bin/pip" install -q -r "${REQ}" diff --git a/tools/kconfig/kconfig_cli.py b/tools/kconfig/kconfig_cli.py index ffef3f699..a2964b240 100644 --- a/tools/kconfig/kconfig_cli.py +++ b/tools/kconfig/kconfig_cli.py @@ -7,9 +7,13 @@ import os import re import sys -import tomllib from pathlib import Path +try: + import tomllib +except ModuleNotFoundError: + import tomli as tomllib + _KCONF_ARCH_TO_DIR: dict[str, str] = { "ARCH_AARCH64": "aarch64", "ARCH_RISCV64": "riscv64", diff --git a/tools/kconfig/requirements.txt b/tools/kconfig/requirements.txt index 3c91d8914..1e0d7bc4a 100644 --- a/tools/kconfig/requirements.txt +++ b/tools/kconfig/requirements.txt @@ -1,2 +1,3 @@ PySocks>=1.7.1 kconfiglib>=14.1.0 +tomli>=2.0.1; python_version < "3.11"