Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
fix(install): download Python from Astral's CDN when an older uv would use GitHub (#2291)
Call White5ec89658cd68
diff --git a/docs/plans/release-download-mirror.md b/docs/plans/release-download-mirror.mdindex 2ea8a7e13..a706eae2a 100644--- a/docs/plans/release-download-mirror.md+++ b/docs/plans/release-download-mirror.md@@ -146,12 +146,18 @@ archives download through `core.dependency_network.fetch_to_path`:2. Cache Rule, then real-file tests from the three mainland carriers at theevening peak.3. Clients, one at a time: desktop updater (done), then runtime and Show- Runtime downloads (done), then `install.sh` and `install.ps1`. Each tries the- mirror first, then GitHub, with a connect timeout and a stall watchdog,- resumes with `Range` when switching source, and remembers the last source- that worked. The references are the desktop shell's- `avibe_runtime_host::download` (Rust) and Client downloads above (Python).+ Runtime downloads (done). Each tries the mirror first, then GitHub, with a+ connect timeout and a stall watchdog, resumes with `Range` when switching+ source, and remembers the last source that worked. The references are the+ desktop shell's `avibe_runtime_host::download` (Rust) and Client downloads+ above (Python).4. Install-script third-party dependencies (the uv installer and- python-build-standalone) through `UV_INSTALLER_GITHUB_BASE_URL` and- `UV_PYTHON_INSTALL_MIRROR`, if step 2 shows GitHub is still their- bottleneck. PyPI and npm keep using their existing mainland mirrors.+ python-build-standalone). The install scripts fetch no Avibe release+ assets; their GitHub traffic is uv and the Python it installs. The uv+ installer tries Astral's CDN (`releases.astral.sh`) before GitHub, and so+ does uv 0.10.8 and later for Python. For earlier uv the scripts pass that+ CDN as `UV_PYTHON_INSTALL_MIRROR` to the install step only, and never when+ the user already chose a Python source: a configured mirror turns off newer+ uv's GitHub fallback. Mirror either into R2 only if step 2 shows+ `releases.astral.sh` is slow from mainland carriers. PyPI and npm keep+ using their existing mainland mirrors.diff --git a/install.ps1 b/install.ps1index f95f25347..001b68e1b 100644--- a/install.ps1+++ b/install.ps1@@ -10,6 +10,10 @@ $REPO = "avibe-bot/avibe"$PACKAGE_NAME = "avibe-os"$TSINGHUA_INDEX_URL = "https://pypi.tuna.tsinghua.edu.cn/simple"$NODE_MINIMUM_REQUIREMENT = "20.19+ or 22.12+"+# uv 0.10.8 and later fetch managed Python from Astral's CDN and fall back to+# GitHub; earlier uv fetches it from GitHub only. Get-UvPythonInstallMirror+# gives earlier uv the CDN for the install step unless the user chose a source.+$ASTRAL_PYTHON_INSTALL_MIRROR = "https://releases.astral.sh/github/python-build-standalone/releases/download"function Write-Banner {Write-Host @"@@ -261,6 +265,28 @@ function Install-Uv {}}+# The Python download mirror the install step should give uv, if any. Newer uv+# is left alone: an explicit mirror turns its GitHub fallback off.+function Get-UvPythonInstallMirror {+ if ((Test-Path Env:UV_PYTHON_INSTALL_MIRROR) -or (Test-Path Env:UV_PYTHON_DOWNLOADS_JSON_URL)) {+ return $null+ }+ $version = try { (& uv --version 2>$null) -join " " } catch { "" }+ if (-not ($version -match '^uv (\d+)\.(\d+)\.(\d+)') -or+ [version]"$($Matches[1]).$($Matches[2]).$($Matches[3])" -ge [version]"0.10.8") {+ return $null+ }++ # uv resolves its own config files, so a Python source the user chose there+ # is kept. A config uv cannot load keeps uv's default too.+ $settings = try { (& uv tool install --show-settings $PACKAGE_NAME 2>$null) -join "`n" } catch { "" }+ if (-not $settings -or $LASTEXITCODE -ne 0 -or+ $settings -match 'python_(install_mirror|downloads_json_url): Some\(') {+ return $null+ }+ return $ASTRAL_PYTHON_INSTALL_MIRROR+}+function Invoke-NativeCommand {param([string]$FilePath,@@ -396,7 +422,7 @@ function Activate-LegacyInstallCandidate {}function Invoke-UvToolInstallAttempt {- param([string[]]$Arguments)+ param([string[]]$Arguments, [string]$PythonInstallMirror)$defaultHome = Join-Path $env:USERPROFILE ".avibe"$legacyHome = Join-Path $env:USERPROFILE ".vibe_remote"@@ -439,7 +465,15 @@ function Invoke-UvToolInstallAttempt {$previousSourcePath = $launcherState.SourcePath$env:UV_TOOL_DIR = $generationTools$env:UV_TOOL_BIN_DIR = $generationBin- $result = Invoke-NativeCommand -FilePath "uv" -Arguments (@("tool", "install") + $Arguments)+ if ($PythonInstallMirror) {+ $env:UV_PYTHON_INSTALL_MIRROR = $PythonInstallMirror+ }+ try {+ $result = Invoke-NativeCommand -FilePath "uv" -Arguments (@("tool", "install") + $Arguments)+ } finally {+ # Only an unset variable is ever given the mirror, so unset restores it.+ if ($PythonInstallMirror) { Remove-Item Env:UV_PYTHON_INSTALL_MIRROR -ErrorAction SilentlyContinue }+ }if (-not $result.Success) {Remove-Item -LiteralPath $generationRoot -Recurse -Force -ErrorAction SilentlyContinuereturn $result@@ -533,6 +567,33 @@ function Invoke-UvToolInstallAttempt {function Install-Vibe {Write-Info "Installing avibe-os (Python will be downloaded automatically if needed)..."+ $pythonInstallMirror = Get-UvPythonInstallMirror+ if ($pythonInstallMirror) {+ Write-Info "This uv downloads Python from GitHub; using Astral's CDN for any Python download instead"+ }++ $failure = Install-VibeFromSources -PythonInstallMirror $pythonInstallMirror+ if (-not $failure) {+ return+ }+ # The mirror replaces uv's GitHub source instead of adding one, so when no+ # package source worked through it, try them all once more without it.+ if ($pythonInstallMirror) {+ Write-Info "Retrying without Astral's CDN for the Python download..."+ $failure = Install-VibeFromSources+ if (-not $failure) {+ return+ }+ }++ Write-Error $failure+}++# Try each package source in order. Returns $null once one worked, otherwise the+# failure message to report.+function Install-VibeFromSources {+ param([string]$PythonInstallMirror)+$customPackageSpec = $env:AVIBE_INSTALL_PACKAGE_SPECif (-not $customPackageSpec) {$customPackageSpec = $env:VIBE_INSTALL_PACKAGE_SPEC@@ -540,10 +601,10 @@ function Install-Vibe {if ($customPackageSpec) {Write-Info "Trying custom package spec..."- $result = Invoke-UvToolInstallAttempt -Arguments @($customPackageSpec, "--force")+ $result = Invoke-UvToolInstallAttempt -Arguments @($customPackageSpec, "--force") -PythonInstallMirror $PythonInstallMirrorif ($result.Success) {Write-Success "avibe-os installed successfully (from custom package spec)"- return+ return $null}$failureMessage = "Failed to install avibe-os from custom package spec"@@ -554,7 +615,7 @@ function Install-Vibe {$failureMessage += ":`n$($result.Output)"}- Write-Error $failureMessage+ return $failureMessage}$attempts = @(@@ -575,10 +636,10 @@ function Install-Vibe {foreach ($attempt in $attempts) {Write-Info "Trying $($attempt.Name)..."- $result = Invoke-UvToolInstallAttempt -Arguments $attempt.Arguments+ $result = Invoke-UvToolInstallAttempt -Arguments $attempt.Arguments -PythonInstallMirror $PythonInstallMirrorif ($result.Success) {Write-Success "avibe-os installed successfully (from $($attempt.Name))"- return+ return $null}$failureMessage = "- $($attempt.Name) failed"@@ -593,7 +654,7 @@ function Install-Vibe {$failures += $failureMessage}- Write-Error "Failed to install avibe-os from all sources.`n$($failures -join "`n`n")"+ return "Failed to install avibe-os from all sources.`n$($failures -join "`n`n")"}function Test-Installation {diff --git a/install.sh b/install.shindex fa1583bb7..7a7bbeb0b 100755--- a/install.sh+++ b/install.sh@@ -23,6 +23,11 @@ VIBE_TOOL_BIN_DIR=""# shell happens to have. Upgrades keep every other managed launcher in step.ROOT_TOOL_BIN_DIR="/usr/local/bin"VIBE_CANDIDATE_BIN_PATH=""+# uv 0.10.8 and later fetch managed Python from Astral's CDN and fall back to+# GitHub; earlier uv fetches it from GitHub only. uv_python_install_mirror+# gives earlier uv the CDN for the install step unless the user chose a source.+ASTRAL_PYTHON_INSTALL_MIRROR="https://releases.astral.sh/github/python-build-standalone/releases/download"+UV_INSTALL_PYTHON_MIRROR=""LAUNCH_AFTER_INSTALL=""AVIBE_LAUNCHED=""ORIGINAL_PATH="$PATH"@@ -320,6 +325,37 @@ uv_is_native_for_host() {uv_binary_is_acceptable "$uv_path"}+# Print the Python download mirror the install step should give uv, if any.+# Newer uv is left alone: an explicit mirror turns its GitHub fallback off.+uv_python_install_mirror() {+ if [ -n "${UV_PYTHON_INSTALL_MIRROR+set}" ] || [ -n "${UV_PYTHON_DOWNLOADS_JSON_URL+set}" ]; then+ return 0+ fi++ local version major minor patch_extra+ version="$(uv --version 2>/dev/null || true)"+ version="${version#uv }"+ IFS='.' read -r major minor patch_extra <<EOF+${version%% *}+EOF+ local patch="${patch_extra%%[^0-9]*}"+ case "$major.$minor.$patch" in+ *[!0-9.]*|.*|*..*|*.) return 0 ;;+ esac+ if [ "$major" -ne 0 ] || [ "$minor" -gt 10 ] || { [ "$minor" -eq 10 ] && [ "$patch" -ge 8 ]; }; then+ return 0+ fi++ # uv resolves its own config files, so a Python source the user chose there+ # is kept. A config uv cannot load keeps uv's default too.+ local settings+ settings="$(uv tool install --show-settings "$PACKAGE_NAME" 2>/dev/null)" || return 0+ case "$settings" in+ *"python_install_mirror: Some("*|*"python_downloads_json_url: Some("*) return 0 ;;+ esac+ printf '%s\n' "$ASTRAL_PYTHON_INSTALL_MIRROR"+}+node_version_parts() {local version=""version="$(node --version 2>/dev/null || true)"@@ -498,7 +534,8 @@ uv_tool_install() {fi# Suppress package-manager progress only, not activation/retention diagnostics.- if UV_TOOL_DIR="$generation_tools" UV_TOOL_BIN_DIR="$generation_bin" uv tool install "$@" 2>/dev/null; then+ if env ${UV_INSTALL_PYTHON_MIRROR:+"UV_PYTHON_INSTALL_MIRROR=$UV_INSTALL_PYTHON_MIRROR"} \+ UV_TOOL_DIR="$generation_tools" UV_TOOL_BIN_DIR="$generation_bin" uv tool install "$@" 2>/dev/null; thenVIBE_CANDIDATE_BIN_PATH="$generation_bin/vibe"if [ ! -x "$VIBE_CANDIDATE_BIN_PATH" ]; thenwarn "uv completed but the candidate vibe launcher was not created"@@ -671,15 +708,39 @@ install_vibe() {warn "Could not find a writable directory in PATH; you may need a new shell before 'vibe' is available"fi- if [ -n "$install_package_spec" ]; then- if install_package_candidate "$install_package_spec"; then- success "avibe-os installed successfully (from custom package spec)"+ UV_INSTALL_PYTHON_MIRROR="$(uv_python_install_mirror)"+ if [ -n "$UV_INSTALL_PYTHON_MIRROR" ]; then+ info "This uv downloads Python from GitHub; using Astral's CDN for any Python download instead"+ fi++ if install_vibe_from_sources "$install_package_spec"; then+ return 0+ fi+ # The mirror replaces uv's GitHub source instead of adding one, so when no+ # package source worked through it, try them all once more without it.+ if [ -n "$UV_INSTALL_PYTHON_MIRROR" ]; then+ UV_INSTALL_PYTHON_MIRROR=""+ info "Retrying without Astral's CDN for the Python download..."+ if install_vibe_from_sources "$install_package_spec"; thenreturn 0fi+ fi+ if [ -n "$install_package_spec" ]; thenerror "Failed to install avibe-os from custom package spec: $install_package_spec"fi-+ error "Failed to install avibe-os from all sources"+}++install_vibe_from_sources() {+ local install_package_spec="$1"++ if [ -n "$install_package_spec" ]; then+ install_package_candidate "$install_package_spec" || return 1+ success "avibe-os installed successfully (from custom package spec)"+ return 0+ fi+# uv tool install will auto-download Python if not available# --force: reinstall even if already installed# --refresh: refresh package cache to get latest version@@ -691,7 +752,7 @@ install_vibe() {elif install_package_candidate "git+https://github.com/${REPO}.git"; thensuccess "avibe-os installed successfully (from GitHub)"else- error "Failed to install avibe-os from all sources"+ return 1fi}diff --git a/tests/test_install_script.py b/tests/test_install_script.pyindex 795805e9b..cc8f6ab6a 100644--- a/tests/test_install_script.py+++ b/tests/test_install_script.py@@ -80,6 +80,24 @@ def _write_fake_uv(path: Path, uv_log: Path) -> None:#!/usr/bin/env bashset -euo pipefail+ if [ "$1" = "--version" ] && [ -n "${{VIBE_TEST_UV_VERSION:-}}" ]; then+ echo "$VIBE_TEST_UV_VERSION"+ exit 0+ fi+ if [[ " $* " == *" --show-settings "* ]]; then+ if [ "${{VIBE_TEST_UV_SETTINGS_FAIL:-}}" = "1" ]; then+ exit 2+ fi+ for setting in python_install_mirror python_downloads_json_url; do+ if [ "${{VIBE_TEST_UV_CONFIGURED_SOURCE:-}}" = "$setting" ]; then+ printf ' %s: Some(\\n "https://mirror.example.test/python",\\n ),\\n' "$setting"+ else+ printf ' %s: None,\\n' "$setting"+ fi+ done+ exit 0+ fi+printf '%s' "${{UV_TOOL_BIN_DIR:-}}" > "{uv_log}"printf '%s' "${{UV_TOOL_DIR:-}}" > "{uv_log}.tools"@@ -91,6 +109,13 @@ def _write_fake_uv(path: Path, uv_log: Path) -> None:if [ "$1" != "tool" ] || [ "$2" != "install" ]; thenexit 1fi+ printf '%s\\n' "${{UV_PYTHON_INSTALL_MIRROR-<unset>}}" >> "{uv_log}.python-mirror"+ if [ "${{VIBE_TEST_UV_FAIL_WITH_PYTHON_MIRROR:-}}" = "1" ] && [ -n "${{UV_PYTHON_INSTALL_MIRROR+set}}" ]; then+ exit 1+ fi+ if [ "${{VIBE_TEST_UV_FAIL_WITHOUT_INDEX_URL:-}}" = "1" ] && [[ " $* " != *" --index-url "* ]]; then+ exit 1+ fibin_dir="${{UV_TOOL_BIN_DIR:-$HOME/.local/bin}}"tool_env="${{UV_TOOL_DIR:-$HOME/.local/share/uv/tools}}/avibe-os"@@ -370,6 +395,66 @@ def test_install_script_keeps_vibe_available_on_current_path(tmp_path):assert uv_log.read_text(encoding="utf-8")+ASTRAL_PYTHON_INSTALL_MIRROR = "https://releases.astral.sh/github/python-build-standalone/releases/download"+++ ("uv_version", "env_overrides", "expected_mirrors"),+ [+ ("uv 0.10.7 (8e2c9a1 2026-03-02)", {}, [ASTRAL_PYTHON_INSTALL_MIRROR]),+ ("uv 0.10.8", {}, ["<unset>"]),+ (+ "uv 0.9.8",+ {"UV_PYTHON_INSTALL_MIRROR": "https://mirror.example.test/python"},+ ["https://mirror.example.test/python"],+ ),+ ("uv 0.9.8", {"UV_PYTHON_DOWNLOADS_JSON_URL": "https://mirror.example.test/downloads.json"}, ["<unset>"]),+ ("uv 0.9.8", {"VIBE_TEST_UV_CONFIGURED_SOURCE": "python_install_mirror"}, ["<unset>"]),+ ("uv 0.9.8", {"VIBE_TEST_UV_CONFIGURED_SOURCE": "python_downloads_json_url"}, ["<unset>"]),+ ("uv 0.9.8", {"VIBE_TEST_UV_SETTINGS_FAIL": "1"}, ["<unset>"]),+ (+ "uv 0.9.8",+ {"VIBE_TEST_UV_FAIL_WITH_PYTHON_MIRROR": "1"},+ [ASTRAL_PYTHON_INSTALL_MIRROR] * 3 + ["<unset>"],+ ),+ ("uv 0.9.8", {"VIBE_TEST_UV_FAIL_WITHOUT_INDEX_URL": "1"}, [ASTRAL_PYTHON_INSTALL_MIRROR] * 2),+ ],+ ids=[+ "uv-without-cdn",+ "uv-with-cdn",+ "user-env-mirror",+ "user-env-downloads-json",+ "uv-config-mirror",+ "uv-config-downloads-json",+ "uv-config-unreadable",+ "cdn-down-retries-every-source-without-it",+ "pypi-down-keeps-cdn-for-tsinghua",+ ],+)+def test_install_script_gives_uv_without_a_python_cdn_the_astral_mirror(+ tmp_path, uv_version, env_overrides, expected_mirrors+):+ home_dir = tmp_path / "home"+ home_dir.mkdir()+ path_dir = tmp_path / "path-bin"+ path_dir.mkdir()+ uv_log = tmp_path / "uv-tool-bin-dir.txt"+ _write_fake_uv(path_dir / "uv", uv_log)++ env = os.environ.copy()+ for name in ("UV_PYTHON_INSTALL_MIRROR", "UV_PYTHON_DOWNLOADS_JSON_URL"):+ env.pop(name, None)+ env["HOME"] = str(home_dir)+ env["PATH"] = os.pathsep.join([str(path_dir), "/usr/bin", "/bin"])+ env["VIBE_TEST_UV_VERSION"] = uv_version+ env.update(env_overrides)++ install_result = _install(env)++ assert install_result.returncode == 0, install_result.stdout + install_result.stderr+ assert Path(f"{uv_log}.python-mirror").read_text(encoding="utf-8").splitlines() == expected_mirrors++def test_install_script_canonicalizes_relative_avibe_home(tmp_path):home_dir = tmp_path / "home"home_dir.mkdir()