2.6 KiB
2.6 KiB
Version Management
This project uses automatic version synchronization between the .env file and pyproject.toml.
Overview
The version is maintained in the .env file as the single source of truth, and automatically synchronized to pyproject.toml using the provided script.
Files Involved
.env: ContainsVERSION="x.y.z"- the authoritative version sourcepyproject.toml: Containsversion = "x.y.z"in the[project]sectionuv.lock: Lock file updated automatically to reflect version changesscripts/update_version.py: Python script that reads from.envand updates both files
Usage
Manual Update
# Update pyproject.toml version from .env (and sync uv.lock)
python scripts/update_version.py
# Or use the Makefile target
make update-version
# Skip uv.lock update if needed
python scripts/update_version.py --skip-uv-lock
make update-version-only
Automatic Update
The script can be integrated into your development workflow in several ways:
- Before builds: Run
make update-versionbefore building - In CI/CD: Add the script to your deployment pipeline
- As a pre-commit hook: Add to
.pre-commit-config.yaml(optional)
Workflow
- Update the version: Edit the
VERSIONvariable in.env - Synchronize: Run
make update-versionorpython scripts/update_version.py - Verify: All files now have the same version (
.env,pyproject.toml,uv.lock) - Commit: All files can be committed together
Examples
# Change version in .env
echo 'VERSION="1.14.0"' > .env # (update just the VERSION line)
# Sync to pyproject.toml and uv.lock
make update-version
# Result: All files now have version 1.14.0
Script Features
- Comprehensive updates: Updates both
pyproject.tomlanduv.lockautomatically - Precise targeting: Only updates the
versionfield in the[project]section - Safe operation: Leaves other version fields untouched (
minversion,target-version, etc.) - Flexible options: Can skip
uv.lockupdate with--skip-uv-lockflag - Error handling: Validates file existence, uv installation, and command success
- Safety checks: Shows current vs new version before changing
- Idempotent: Safe to run multiple times
- Minimal dependencies: Only uses Python standard library + uv
- Clear output: Shows exactly what changed
Integration
The script is designed to be:
- Fast: Minimal overhead for CI/CD pipelines
- Reliable: Robust error handling and validation
- Flexible: Can be called from Make, CI, or manually
- Maintainable: Clear code with type hints and documentation