Auto-install uv for zero-configuration dependency management

- Automatically install uv if not found in container
- Eliminates manual dependency setup
- No fallback to python3 + manual jinja2 installation needed
- First run installs uv (~5 seconds), subsequent runs use cached version
- Update documentation to reflect automatic installation

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Max Podkorytov
2026-01-13 23:19:24 -06:00
parent 13655f2757
commit 52037f96f1
2 changed files with 23 additions and 43 deletions

View File

@@ -166,29 +166,23 @@ echo "Generating analysis report..."
docker cp "${SCRIPT_DIR}/analyze_build_trace.py" "${CONTAINER_NAME}:/tmp/analyze_build_trace.py"
docker cp "${SCRIPT_DIR}/templates" "${CONTAINER_NAME}:/tmp/ck_build_analysis_templates"
# Check if uv is available and use it for PEP 723 dependency management
# Check both PATH and common install locations
if docker exec "${CONTAINER_NAME}" bash -c "command -v uv >/dev/null 2>&1 || test -x \$HOME/.local/bin/uv"; then
echo "Using uv run for automatic dependency management..."
# Ensure uv is in PATH (handles ~/.local/bin installation)
docker exec "${CONTAINER_NAME}" bash -c "export PATH=\"\$HOME/.local/bin:\$PATH\" && uv run --no-project /tmp/analyze_build_trace.py \
${TRACE_FILE} \
/workspace/${OUTPUT_FILE} \
${TARGET} \
${GRANULARITY} \
${BUILD_TIME} \
/tmp/ck_build_analysis_templates"
else
echo "uv not found, using python3 (requires python3-jinja2 pre-installed)..."
docker exec "${CONTAINER_NAME}" python3 /tmp/analyze_build_trace.py \
"${TRACE_FILE}" \
"/workspace/${OUTPUT_FILE}" \
"${TARGET}" \
"${GRANULARITY}" \
"${BUILD_TIME}" \
"/tmp/ck_build_analysis_templates"
# Check if uv is available, install if needed, and use for PEP 723 dependency management
if ! docker exec "${CONTAINER_NAME}" bash -c "command -v uv >/dev/null 2>&1 || test -x \$HOME/.local/bin/uv"; then
echo "uv not found, installing..."
docker exec "${CONTAINER_NAME}" bash -c "curl -LsSf https://astral.sh/uv/install.sh | sh" >/dev/null 2>&1
echo "uv installed successfully"
fi
echo "Using uv run for automatic dependency management..."
# Ensure uv is in PATH (handles ~/.local/bin installation)
docker exec "${CONTAINER_NAME}" bash -c "export PATH=\"\$HOME/.local/bin:\$PATH\" && uv run --no-project /tmp/analyze_build_trace.py \
${TRACE_FILE} \
/workspace/${OUTPUT_FILE} \
${TARGET} \
${GRANULARITY} \
${BUILD_TIME} \
/tmp/ck_build_analysis_templates"
# Copy report back to host
docker cp "${CONTAINER_NAME}:/workspace/${OUTPUT_FILE}" "${PROJECT_ROOT}/${OUTPUT_FILE}"

View File

@@ -126,29 +126,18 @@ The analysis script (`analyze_build_trace.py`) is PEP 723 compliant with inline
# ///
```
**The skill automatically uses `uv run` if available**, which provides:
**The skill automatically installs and uses `uv`**, which provides:
- ✅ Zero-configuration dependency management
- ✅ Automatic installation of jinja2 from PEP 723 metadata
- ✅ Isolated dependency environment (no system pollution)
- ✅ Fast caching for subsequent runs
### Installation Options
**No manual setup required!** The first time you run the skill, it will:
1. Detect if `uv` is installed in the container
2. If not, automatically install it (takes ~5 seconds)
3. Use `uv run` to execute the analysis with auto-managed dependencies
**Option 1: Install uv (Recommended)**
```bash
# Install uv in the Docker container (one-time setup)
docker exec ck_<container_name> bash -c "curl -LsSf https://astral.sh/uv/install.sh | sh"
```
After installing `uv`, the skill will automatically use it for dependency management.
**Option 2: Use system python3 + jinja2**
```bash
# If uv is not available, install jinja2 manually
docker exec ck_<container_name> apt-get install -y python3-jinja2
```
The skill automatically detects which method is available and uses the appropriate one.
On subsequent runs, `uv` will already be available and dependencies will be cached.
### Components
@@ -161,12 +150,9 @@ The skill automatically detects which method is available and uses the appropria
The Python script can also be run independently:
```bash
# With uv (recommended - auto-installs dependencies)
# With uv (recommended - auto-installs dependencies from PEP 723 metadata)
uv run .claude/skills/analyze_build_trace.py trace.json report.md target 100 22 templates/
# With pipx (alternative - auto-installs dependencies)
# With pipx (alternative - also auto-installs dependencies)
pipx run .claude/skills/analyze_build_trace.py trace.json report.md target 100 22 templates/
# With python3 (requires jinja2 pre-installed)
python3 .claude/skills/analyze_build_trace.py trace.json report.md target 100 22 templates/
```