Skip to content

Commit caf3f74

Browse files
tenpercentclaude
andcommitted
Use uv run as default execution path for automatic dependency management
- Automatically detect and use uv if available in container - Fall back to python3 if uv not found (backward compatible) - Leverage PEP 723 metadata for zero-config dependency installation - Update documentation with uv installation instructions Benefits: - Zero manual dependency installation with uv - Isolated dependency environment (no system pollution) - Fast dependency caching for subsequent runs - Automatic dependency resolution from PEP 723 metadata Tested with: - uv 0.9.25: Auto-installs jinja2 from PEP 723 metadata - python3: Falls back when uv unavailable (requires python3-jinja2) Installation: docker exec <container> bash -c "curl -LsSf https://astral.sh/uv/install.sh | sh" Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 7e091c0 commit caf3f74

2 files changed

Lines changed: 54 additions & 19 deletions

File tree

.claude/skills/ck-build-analysis

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,28 @@ echo "Generating analysis report..."
179179
docker cp "${SCRIPT_DIR}/analyze_build_trace.py" "${CONTAINER_NAME}:/tmp/analyze_build_trace.py"
180180
docker cp "${SCRIPT_DIR}/templates" "${CONTAINER_NAME}:/tmp/ck_build_analysis_templates"
181181

182-
# Run analysis
183-
docker exec "${CONTAINER_NAME}" python3 /tmp/analyze_build_trace.py \
184-
"${TRACE_FILE}" \
185-
"/workspace/${OUTPUT_FILE}" \
186-
"${TARGET}" \
187-
"${GRANULARITY}" \
188-
"${BUILD_TIME}" \
189-
"/tmp/ck_build_analysis_templates"
182+
# Check if uv is available and use it for PEP 723 dependency management
183+
# Check both PATH and common install locations
184+
if docker exec "${CONTAINER_NAME}" bash -c "command -v uv >/dev/null 2>&1 || test -x \$HOME/.local/bin/uv"; then
185+
echo "Using uv run for automatic dependency management..."
186+
# Ensure uv is in PATH (handles ~/.local/bin installation)
187+
docker exec "${CONTAINER_NAME}" bash -c "export PATH=\"\$HOME/.local/bin:\$PATH\" && uv run --no-project /tmp/analyze_build_trace.py \
188+
${TRACE_FILE} \
189+
/workspace/${OUTPUT_FILE} \
190+
${TARGET} \
191+
${GRANULARITY} \
192+
${BUILD_TIME} \
193+
/tmp/ck_build_analysis_templates"
194+
else
195+
echo "uv not found, using python3 (requires python3-jinja2 pre-installed)..."
196+
docker exec "${CONTAINER_NAME}" python3 /tmp/analyze_build_trace.py \
197+
"${TRACE_FILE}" \
198+
"/workspace/${OUTPUT_FILE}" \
199+
"${TARGET}" \
200+
"${GRANULARITY}" \
201+
"${BUILD_TIME}" \
202+
"/tmp/ck_build_analysis_templates"
203+
fi
190204

191205
# Copy report back to host
192206
docker cp "${CONTAINER_NAME}:/workspace/${OUTPUT_FILE}" "${PROJECT_ROOT}/${OUTPUT_FILE}"

.claude/skills/ck-build-analysis.md

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ The report includes:
113113

114114
## Implementation Details
115115

116-
### PEP 723 Compliance
116+
### PEP 723 Compliance with Automatic Dependency Management
117117

118118
The analysis script (`analyze_build_trace.py`) is PEP 723 compliant with inline dependency metadata:
119119

@@ -126,26 +126,47 @@ The analysis script (`analyze_build_trace.py`) is PEP 723 compliant with inline
126126
# ///
127127
```
128128

129-
This allows tools like `pipx run` or `uv run` to automatically manage dependencies:
129+
**The skill automatically uses `uv run` if available**, which provides:
130+
- ✅ Zero-configuration dependency management
131+
- ✅ Automatic installation of jinja2 from PEP 723 metadata
132+
- ✅ Isolated dependency environment (no system pollution)
133+
- ✅ Fast caching for subsequent runs
130134

135+
### Installation Options
136+
137+
**Option 1: Install uv (Recommended)**
131138
```bash
132-
# Run standalone with pipx (auto-installs dependencies)
133-
pipx run .claude/skills/analyze_build_trace.py trace.json report.md target 100 22 templates/
139+
# Install uv in the Docker container (one-time setup)
140+
docker exec ck_<container_name> bash -c "curl -LsSf https://astral.sh/uv/install.sh | sh"
141+
```
134142

135-
# Or with uv
136-
uv run .claude/skills/analyze_build_trace.py trace.json report.md target 100 22 templates/
143+
After installing `uv`, the skill will automatically use it for dependency management.
144+
145+
**Option 2: Use system python3 + jinja2**
146+
```bash
147+
# If uv is not available, install jinja2 manually
148+
docker exec ck_<container_name> apt-get install -y python3-jinja2
137149
```
138150

151+
The skill automatically detects which method is available and uses the appropriate one.
152+
139153
### Components
140154

141155
- **ck-build-analysis** - Main bash script that orchestrates Docker, CMake, and analysis
142156
- **analyze_build_trace.py** - PEP 723 compliant Python script for trace analysis
143157
- **templates/build_analysis_report.md.jinja** - Jinja2 template for report generation
144158

145-
### Requirements
159+
### Standalone Usage
146160

147-
In Docker container:
148-
- `python3-jinja2` (installed via `apt-get install python3-jinja2`)
161+
The Python script can also be run independently:
149162

150-
For standalone use:
151-
- Python 3.8+ with `jinja2>=3.0.0` (auto-managed if using `pipx` or `uv`)
163+
```bash
164+
# With uv (recommended - auto-installs dependencies)
165+
uv run .claude/skills/analyze_build_trace.py trace.json report.md target 100 22 templates/
166+
167+
# With pipx (alternative - auto-installs dependencies)
168+
pipx run .claude/skills/analyze_build_trace.py trace.json report.md target 100 22 templates/
169+
170+
# With python3 (requires jinja2 pre-installed)
171+
python3 .claude/skills/analyze_build_trace.py trace.json report.md target 100 22 templates/
172+
```

0 commit comments

Comments
 (0)