uv: Locking and Syncing
10 months ago
- #Python
- #uv
- #dependency management
- Locking resolves project dependencies into a lockfile, while syncing installs packages from the lockfile into the project environment.
- uv automatically locks and syncs projects before running commands, ensuring environments are up-to-date.
- Options like --locked, --frozen, and --no-sync control automatic locking and syncing behavior.
- The lockfile is considered outdated if project metadata changes, but not when new package versions are released.
- Commands like uv lock and uv sync allow explicit lockfile creation and environment syncing.
- Editable installations are enabled by default, allowing changes to reflect without re-syncing.
- Optional dependencies (extras) and development dependencies can be managed with specific flags.
- Upgrading locked package versions requires explicit commands like --upgrade or --upgrade-package.
- The lockfile can be exported to requirements.txt format for integration with other tools.
- Partial installations can be performed for scenarios like Docker layer caching, with flags to omit specific packages.