setup: add retry for transient network fails on uv install (#37490)

This commit is contained in:
Adeeb Shihadeh
2026-02-28 10:39:13 -08:00
committed by GitHub
parent 870430e19f
commit a27efe5796
+17 -1
View File
@@ -4,6 +4,21 @@ set -e
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
ROOT="$(cd "$DIR/../" && pwd)"
function retry() {
local attempts=$1
shift
for i in $(seq 1 "$attempts"); do
if "$@"; then
return 0
fi
if [ "$i" -lt "$attempts" ]; then
echo " Attempt $i/$attempts failed, retrying in 5s..."
sleep 5
fi
done
return 1
}
function install_ubuntu_deps() {
SUDO=""
@@ -83,7 +98,8 @@ function install_python_deps() {
if ! command -v "uv" > /dev/null 2>&1; then
echo "installing uv..."
curl -LsSf --retry 5 --retry-delay 5 --retry-all-errors https://astral.sh/uv/install.sh | sh
# TODO: outer retry can be removed once https://github.com/axodotdev/cargo-dist/pull/2311 is merged
retry 3 sh -c 'curl --retry 5 --retry-delay 5 --retry-all-errors -LsSf https://astral.sh/uv/install.sh | UV_GITHUB_TOKEN="${GITHUB_TOKEN:-}" sh'
UV_BIN="$HOME/.local/bin"
PATH="$UV_BIN:$PATH"
fi