From f0a6984e8580f5c7e0885bd6053c592e37f6491a Mon Sep 17 00:00:00 2001 From: Aleksandr Meshchriakov Date: Tue, 24 Mar 2026 14:27:30 +0100 Subject: [PATCH] fix(ci): support sudo in python bootstrap --- scripts/ensure-ci-python.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/scripts/ensure-ci-python.sh b/scripts/ensure-ci-python.sh index b85a35b..2f98a7c 100755 --- a/scripts/ensure-ci-python.sh +++ b/scripts/ensure-ci-python.sh @@ -16,12 +16,19 @@ if command -v "${PYTHON_BIN}" >/dev/null 2>&1; then exit 0 fi +APT_RUNNER=() +if [[ "$(id -u)" -ne 0 ]]; then + APT_RUNNER=(sudo) +fi + export DEBIAN_FRONTEND=noninteractive -apt-get update -apt-get install -y software-properties-common -add-apt-repository -y ppa:deadsnakes/ppa -apt-get update -apt-get install -y "${PYTHON_BIN}" "${PYTHON_BIN}-venv" +"${APT_RUNNER[@]}" apt-get update +if ! "${APT_RUNNER[@]}" apt-get install -y "${PYTHON_BIN}" "${PYTHON_BIN}-venv"; then + "${APT_RUNNER[@]}" apt-get install -y software-properties-common + "${APT_RUNNER[@]}" add-apt-repository -y ppa:deadsnakes/ppa + "${APT_RUNNER[@]}" apt-get update + "${APT_RUNNER[@]}" apt-get install -y "${PYTHON_BIN}" "${PYTHON_BIN}-venv" +fi command -v "${PYTHON_BIN}"