Linux command
uv-lock 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
Create or update
uv lock
Upgrade all packages
uv lock --upgrade
Upgrade a specific package
uv lock --upgrade-package [package]
Check if the lockfile is up-to-date
uv lock --check
Lock with a specific Python version
uv lock --python [3.12]
说明
uv lock resolves project dependencies declared in pyproject.toml and writes exact pinned versions to a uv.lock file. The lockfile ensures reproducible installations across environments. Run after modifying pyproject.toml dependencies. Locking is automatic when running uv sync, uv run, or uv add, but can be run explicitly to update the lockfile without installing packages.
参数
- --upgrade
- Allow all packages to be upgraded to their latest compatible versions.
- --upgrade-package _pkg_
- Allow a specific package to be upgraded.
- --check
- Check if the lockfile is up-to-date; error if it needs updating.
- --frozen
- Use the existing lockfile without checking if it is up-to-date.
- --locked
- Assert that the lockfile matches pyproject.toml; error otherwise.
- --no-sources
- Ignore the tool.uv.sources table when resolving dependencies.
- --python _VERSION_
- Resolve for a specific Python version.
FAQ
What is the uv-lock command used for?
uv lock resolves project dependencies declared in pyproject.toml and writes exact pinned versions to a uv.lock file. The lockfile ensures reproducible installations across environments. Run after modifying pyproject.toml dependencies. Locking is automatic when running uv sync, uv run, or uv add, but can be run explicitly to update the lockfile without installing packages.
How do I run a basic uv-lock example?
Run `uv lock` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does --upgrade do in uv-lock?
Allow all packages to be upgraded to their latest compatible versions.