mirror of
https://github.com/trailofbits/algo.git
synced 2025-09-06 12:03:38 +02:00
Improve uv installation feedback and Docker dependency locking
- Track and display which installation method succeeded for uv - Add --locked flag to Docker uv sync for stricter dependency enforcement - Users now see "uv installed successfully via Homebrew\!" etc. This addresses code review feedback about installation transparency and dependency management strictness. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
8450e63b56
commit
73d8e99b98
2 changed files with 16 additions and 9 deletions
|
@ -25,7 +25,7 @@ COPY --from=ghcr.io/astral-sh/uv:latest /uv /bin/uv
|
||||||
|
|
||||||
# Copy dependency files and install in single layer for better optimization
|
# Copy dependency files and install in single layer for better optimization
|
||||||
COPY pyproject.toml uv.lock ./
|
COPY pyproject.toml uv.lock ./
|
||||||
RUN uv sync --frozen --no-dev
|
RUN uv sync --frozen --locked --no-dev
|
||||||
|
|
||||||
# Copy application code
|
# Copy application code
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
23
algo
23
algo
|
@ -2,31 +2,34 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Track which installation method succeeded
|
||||||
|
UV_INSTALL_METHOD=""
|
||||||
|
|
||||||
# Function to install uv via package managers (most secure)
|
# Function to install uv via package managers (most secure)
|
||||||
install_uv_via_package_manager() {
|
install_uv_via_package_manager() {
|
||||||
echo "Attempting to install uv via system package manager..."
|
echo "Attempting to install uv via system package manager..."
|
||||||
|
|
||||||
if command -v brew &> /dev/null; then
|
if command -v brew &> /dev/null; then
|
||||||
echo "Using Homebrew..."
|
echo "Using Homebrew..."
|
||||||
brew install uv && return 0
|
brew install uv && UV_INSTALL_METHOD="Homebrew" && return 0
|
||||||
elif command -v apt &> /dev/null && apt list uv 2>/dev/null | grep -q uv; then
|
elif command -v apt &> /dev/null && apt list uv 2>/dev/null | grep -q uv; then
|
||||||
echo "Using apt..."
|
echo "Using apt..."
|
||||||
sudo apt update && sudo apt install -y uv && return 0
|
sudo apt update && sudo apt install -y uv && UV_INSTALL_METHOD="apt" && return 0
|
||||||
elif command -v dnf &> /dev/null; then
|
elif command -v dnf &> /dev/null; then
|
||||||
echo "Using dnf..."
|
echo "Using dnf..."
|
||||||
sudo dnf install -y uv 2>/dev/null && return 0
|
sudo dnf install -y uv 2>/dev/null && UV_INSTALL_METHOD="dnf" && return 0
|
||||||
elif command -v pacman &> /dev/null; then
|
elif command -v pacman &> /dev/null; then
|
||||||
echo "Using pacman..."
|
echo "Using pacman..."
|
||||||
sudo pacman -S --noconfirm uv 2>/dev/null && return 0
|
sudo pacman -S --noconfirm uv 2>/dev/null && UV_INSTALL_METHOD="pacman" && return 0
|
||||||
elif command -v zypper &> /dev/null; then
|
elif command -v zypper &> /dev/null; then
|
||||||
echo "Using zypper..."
|
echo "Using zypper..."
|
||||||
sudo zypper install -y uv 2>/dev/null && return 0
|
sudo zypper install -y uv 2>/dev/null && UV_INSTALL_METHOD="zypper" && return 0
|
||||||
elif command -v winget &> /dev/null; then
|
elif command -v winget &> /dev/null; then
|
||||||
echo "Using winget..."
|
echo "Using winget..."
|
||||||
winget install --id=astral-sh.uv -e && return 0
|
winget install --id=astral-sh.uv -e && UV_INSTALL_METHOD="winget" && return 0
|
||||||
elif command -v scoop &> /dev/null; then
|
elif command -v scoop &> /dev/null; then
|
||||||
echo "Using scoop..."
|
echo "Using scoop..."
|
||||||
scoop install uv && return 0
|
scoop install uv && UV_INSTALL_METHOD="scoop" && return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
@ -61,6 +64,7 @@ install_uv_ubuntu_alternatives() {
|
||||||
if pipx install uv; then
|
if pipx install uv; then
|
||||||
# Add pipx bin directory to PATH
|
# Add pipx bin directory to PATH
|
||||||
export PATH="$HOME/.local/bin:$PATH"
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
|
UV_INSTALL_METHOD="pipx"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -70,6 +74,7 @@ install_uv_ubuntu_alternatives() {
|
||||||
echo "Installing uv via snap..."
|
echo "Installing uv via snap..."
|
||||||
if sudo snap install astral-uv --classic; then
|
if sudo snap install astral-uv --classic; then
|
||||||
# Snap binaries should be automatically in PATH via /snap/bin
|
# Snap binaries should be automatically in PATH via /snap/bin
|
||||||
|
UV_INSTALL_METHOD="snap"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
echo "snap installation failed, trying next option..."
|
echo "snap installation failed, trying next option..."
|
||||||
|
@ -111,9 +116,11 @@ install_uv_via_download() {
|
||||||
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "linux-gnu" && -n "${WSL_DISTRO_NAME:-}" ]] || uname -s | grep -q "MINGW\|MSYS"; then
|
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "linux-gnu" && -n "${WSL_DISTRO_NAME:-}" ]] || uname -s | grep -q "MINGW\|MSYS"; then
|
||||||
# Windows (Git Bash/WSL/MINGW) - use versioned installer
|
# Windows (Git Bash/WSL/MINGW) - use versioned installer
|
||||||
powershell -ExecutionPolicy ByPass -c "irm https://github.com/astral-sh/uv/releases/download/0.8.5/uv-installer.ps1 | iex"
|
powershell -ExecutionPolicy ByPass -c "irm https://github.com/astral-sh/uv/releases/download/0.8.5/uv-installer.ps1 | iex"
|
||||||
|
UV_INSTALL_METHOD="official installer (Windows)"
|
||||||
else
|
else
|
||||||
# macOS/Linux - use the versioned script for consistency
|
# macOS/Linux - use the versioned script for consistency
|
||||||
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.8.5/uv-installer.sh | sh
|
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/astral-sh/uv/releases/download/0.8.5/uv-installer.sh | sh
|
||||||
|
UV_INSTALL_METHOD="official installer"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +149,7 @@ if ! command -v uv &> /dev/null; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "✓ uv installed successfully!"
|
echo "✓ uv installed successfully via ${UV_INSTALL_METHOD}!"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Run the appropriate playbook
|
# Run the appropriate playbook
|
||||||
|
|
Loading…
Add table
Reference in a new issue