diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh index 4eda263..a6f5320 100755 --- a/scripts/install_deps.sh +++ b/scripts/install_deps.sh @@ -51,7 +51,6 @@ check_dependencies() { command -v qemu-img >/dev/null 2>&1 || NEED_INSTALL+=("qemu-utils") command -v sudo >/dev/null 2>&1 || NEED_INSTALL+=("sudo") command -v mkfs.erofs >/dev/null 2>&1 || NEED_INSTALL+=("erofs-utils") - python3 -c "import venv" >/dev/null 2>&1 || NEED_INSTALL+=("python3-venv") } check_dependencies osrel=$(sed -n '/^ID_LIKE=/s/^.*=//p' /etc/os-release) @@ -132,15 +131,22 @@ if [ -n "${NEED_INSTALL[*]}" ]; then if ! ($SUDO "$PM" "${INSTALL_OPTION[@]}" "${NEED_INSTALL[@]}"); then abort; fi fi -PYTHON_VENV_DIR="$(dirname "$PWD")/python3-env" -[ -f "$PYTHON_VENV_DIR/bin/activate" ] || { - echo "Creating python3 virtual env" - python3 -m venv "$PYTHON_VENV_DIR" || abort "Failed to create python3 virtual env" -} -# shellcheck disable=SC1091 -source "$PYTHON_VENV_DIR"/bin/activate || abort "Failed to activate python3 virtual env" -python3 -c "import pkg_resources; pkg_resources.require(open('requirements.txt',mode='r'))" &>/dev/null || { - echo "Installing Python3 dependencies" + +python_version=$(python3 -c 'import sys;print("{0}{1}".format(*(sys.version_info[:2])))') +if [ "$python_version" -ge 311 ]; then + python3 -c "import venv" >/dev/null 2>&1 || if ! ($SUDO "$PM" "${INSTALL_OPTION[@]}" "python3-venv"); then abort; fi + PYTHON_VENV_DIR="$(dirname "$PWD")/python3-env" + [ -f "$PYTHON_VENV_DIR/bin/activate" ] || { + echo "Creating python3 virtual env" + python3 -m venv "$PYTHON_VENV_DIR" || abort "Failed to create python3 virtual env" + } + # shellcheck disable=SC1091 + source "$PYTHON_VENV_DIR"/bin/activate || abort "Failed to activate python3 virtual env" + python3 -c "import pkg_resources; pkg_resources.require(open('requirements.txt',mode='r'))" &>/dev/null || { + echo "Installing Python3 dependencies" + python3 -m pip install -r requirements.txt || abort "Failed to install python3 dependencies" + } + deactivate +else python3 -m pip install -r requirements.txt || abort "Failed to install python3 dependencies" -} -deactivate +fi