UV Integration Architecture
This document explains how Angreal integrates with UV and why we chose a binary-first approach.
Angreal uses UV (a fast Python package installer) as an external binary rather than a library. This approach provides several benefits:
- Stability: UV’s binary interface is stable and well-documented
- Simplicity: Subprocess-based integration is straightforward to implement
- Performance: UV operations are already extremely fast (10-50x faster than Python equivalents)
- Future-Proofing: Can easily switch UV versions without code changes
UV is automatically installed when:
- First Use: Any UV operation triggers installation check
- Module Import: The Python venv module ensures UV is available on import
graph TD A[Check UV Availability] --> B{UV Installed?} B -->|Yes| C[Use Existing UV] B -->|No| D[Detect Platform] D --> E{Platform} E -->|Unix/macOS| F[Install via curl] E -->|Windows| G[Install via PowerShell] F --> H[Verify Installation] G --> H H --> I[Ready to Use]
Unix/macOS:
curl -LsSf https://astral.sh/uv/install.sh | sh
Windows:
irm https://astral.sh/uv/install.ps1 | iex
If auto-installation fails:
- Clear error messages are shown to the user
- Manual installation instructions are provided
- Network timeouts are handled gracefully
-
Native Rust Library Integration
- Pros: Tighter integration, no subprocess overhead
- Cons: Complex dependency management, potential version conflicts
- Decision: Rejected due to complexity and maintenance overhead
-
Python Library Integration
- Pros: Familiar Python API
- Cons: Defeats the performance purpose, adds dependency complexity
- Decision: Rejected as it negates UV’s performance benefits
- Isolation: UV’s internal implementation changes don’t affect Angreal
- Maintenance: Easier to update UV independently
- Reliability: Clear separation of concerns between Angreal and UV
- Performance: Subprocess overhead is negligible compared to UV’s speed
- Uses official UV installation scripts from astral.sh
- HTTPS-only downloads for security
- Installation verification prevents corrupted binaries
- No shell injection vulnerabilities (uses proper argument arrays)
The binary-first approach allows for:
- Easy UV version updates
- Potential support for multiple package managers
- Simple integration of future UV features