Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 13 additions & 12 deletions anton/updater.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
"""Auto-update check for Anton."""

from __future__ import annotations

import re
Comment thread
tino097 marked this conversation as resolved.
import re
import shutil
import subprocess
import threading
Expand Down Expand Up @@ -53,22 +52,24 @@ def _check_and_update(result: dict, settings) -> None:
if shutil.which("uv") is None:
return

# Fetch remote __init__.py to get __version__
# Fetch latest release tag from GitHub API
import json
import urllib.request

url = "https://raw.githubusercontent.com/mindsdb/anton/main/anton/__init__.py"
url = "https://api.github.com/repos/mindsdb/anton/releases/latest"
try:
req = urllib.request.Request(url)
req = urllib.request.Request(url, headers={"Accept": "application/vnd.github+json"})
with urllib.request.urlopen(req, timeout=2) as resp:
content = resp.read().decode("utf-8")
data = json.loads(resp.read().decode("utf-8"))
except Exception:
return

# Parse remote version
match = re.search(r'__version__\s*=\s*["\']([^"\']+)["\']', content)
if not match:
latest_tag = data.get("tag_name", "")
if not latest_tag:
return
remote_version_str = match.group(1)

# Strip leading 'v' for version comparison (e.g. "v0.3.1" -> "0.3.1")
remote_version_str = latest_tag.lstrip("v")

# Compare versions
from packaging.version import InvalidVersion, Version
Expand All @@ -84,12 +85,12 @@ def _check_and_update(result: dict, settings) -> None:
if remote_ver <= local_ver:
return

# Newer version available — upgrade
# Newer version available — reinstall from the specific release tag
messages.append(f" Updating anton {local_ver} \u2192 {remote_ver}...")

try:
proc = subprocess.run(
["uv", "tool", "upgrade", "anton"],
["uv", "tool", "install", f"git+https://github.com/mindsdb/anton.git@{latest_tag}", "--force"],
capture_output=True,
timeout=_TOTAL_TIMEOUT,
)
Expand Down
27 changes: 20 additions & 7 deletions install.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -120,25 +120,38 @@ if (-not (Get-Command uv -ErrorAction SilentlyContinue)) {
exit 1
}

# ── 5. Install anton via uv tool ───────────────────────────────────
# ── 5. Resolve latest release tag ─────────────────────────────────
Write-Host " Fetching latest release..."
try {
$release = Invoke-RestMethod "https://api.github.com/repos/mindsdb/anton/releases/latest"
$latestTag = $release.tag_name
$repoUrl = "git+https://github.com/mindsdb/anton.git@$latestTag"
}
catch {
Write-Host "warning: Could not determine latest release tag. Falling back to main branch." -ForegroundColor Yellow
$repoUrl = "git+https://github.com/mindsdb/anton.git"
$latestTag = ""
}

# ── 6. Install anton via uv tool ───────────────────────────────────
Write-Host ""
Write-Host " This will install:"
Write-Host " - anton (from git+https://github.com/mindsdb/anton.git)"
Write-Host " - anton (from $repoUrl)"
Write-Host " - Into an isolated virtual environment managed by uv"
Write-Host " - Python 3.11+ will be downloaded automatically if not present"
Write-Host ""

if (Confirm-Step "Proceed with installation?") {
Write-Host " Installing anton into an isolated venv..."
uv tool install "git+https://github.com/mindsdb/anton.git" --force
uv tool install $repoUrl --force
Write-Host " Installed anton"
}
else {
Write-Host " Installation cancelled."
exit 0
}

# ── 6. Verify the venv was created ─────────────────────────────────
# ── 7. Verify the venv was created ─────────────────────────────────
$uvToolDir = Join-Path $HOME ".local\share\uv\tools\anton"
if (Test-Path $uvToolDir) {
Write-Host " Venv: $uvToolDir"
Expand All @@ -149,7 +162,7 @@ else {
Write-Host " Anton may still work — uv manages the environment internally."
}

# ── 7. Configure firewall for scratchpad internet access ──────────
# ── 8. Configure firewall for scratchpad internet access ──────────
# Anton's scratchpads run Python in per-scratchpad venvs under
# ~/.anton/scratchpad-venvs/<name>/Scripts/python.exe.
# Windows Firewall blocks new executables by default, so we add a
Expand Down Expand Up @@ -215,7 +228,7 @@ else {
Write-Host " netsh advfirewall firewall add rule name=`"Anton Scratchpad`" dir=out action=allow program=`"$scratchpadVenvsDir\<name>\Scripts\python.exe`""
}

# ── 8. Ensure ~/.local/bin is in user PATH ──────────────────────────
# ── 9. Ensure ~/.local/bin is in user PATH ──────────────────────────
$uvBinDir = Join-Path $HOME ".local\bin"
$userPath = [Environment]::GetEnvironmentVariable("Path", "User")

Expand All @@ -234,7 +247,7 @@ else {
Write-Host " Added $uvBinDir to user PATH"
}

# ── 9. Success message ──────────────────────────────────────────────
# ── 10. Success message ──────────────────────────────────────────────
Write-Host ""
Write-Host " ✓ anton installed successfully!" -ForegroundColor Green
Write-Host ""
Expand Down
25 changes: 18 additions & 7 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ BOLD='\033[1m'
RESET='\033[0m'

LOCAL_BIN="$HOME/.local/bin"
REPO_URL="git+https://github.com/mindsdb/anton.git"

FORCE=0
for arg in "$@"; do
Expand Down Expand Up @@ -69,7 +68,19 @@ if ! command -v curl >/dev/null 2>&1; then
exit 1
fi

# ── 3. Find or install uv ──────────────────────────────────────────
# ── 3. Resolve latest release tag ─────────────────────────────────
info " Fetching latest release..."
LATEST_TAG=$(curl -sSf "https://api.github.com/repos/mindsdb/anton/releases/latest" \
| grep '"tag_name"' | head -1 \
| sed 's/.*"tag_name": *"\([^"]*\)".*/\1/')
if [ -z "$LATEST_TAG" ]; then
warn "Could not determine latest release tag. Falling back to main branch."
REPO_URL="git+https://github.com/mindsdb/anton.git"
else
REPO_URL="git+https://github.com/mindsdb/anton.git@${LATEST_TAG}"
fi

# ── 4. Find or install uv ──────────────────────────────────────────
NEED_UV=0

if command -v uv >/dev/null 2>&1; then
Expand Down Expand Up @@ -103,7 +114,7 @@ if [ "$NEED_UV" -eq 1 ]; then
fi
fi

# ── 4. Install anton via uv tool ───────────────────────────────────
# ── 5. Install anton via uv tool ───────────────────────────────────
info ""
info " This will install:"
info " - ${BOLD}anton${RESET} (from ${REPO_URL})"
Expand All @@ -120,7 +131,7 @@ else
exit 0
fi

# ── 5. Verify the venv was created ─────────────────────────────────
# ── 6. Verify the venv was created ─────────────────────────────────
UV_TOOL_DIR="${XDG_DATA_HOME:-$HOME/.local/share}/uv/tools/anton"
if [ -d "$UV_TOOL_DIR" ]; then
info " Venv: ${UV_TOOL_DIR}"
Expand All @@ -130,7 +141,7 @@ else
info " Anton may still work — uv manages the environment internally."
fi

# ── 6. Ensure ~/.local/bin is in PATH ──────────────────────────────
# ── 7. Ensure ~/.local/bin is in PATH ──────────────────────────────
ensure_path() {
# Check if ~/.local/bin is already in PATH
case ":$PATH:" in
Expand Down Expand Up @@ -168,7 +179,7 @@ ensure_path() {

ensure_path

# ── 7. Scratchpad health check ────────────────────────────────────
# ── 8. Scratchpad health check ────────────────────────────────────
# Verify that uv can create a venv — this is what the scratchpad uses at runtime.
# Catches broken Python symlinks, missing venv module, etc. before the user hits it.
info ""
Expand All @@ -190,7 +201,7 @@ else
fi
rm -rf "$HEALTH_DIR" 2>/dev/null

# ── 8. Success message ──────────────────────────────────────────────
# ── 9. Success message ──────────────────────────────────────────────
info ""
info "${GREEN} ✓ anton installed successfully!${RESET}"
info ""
Expand Down
Loading