-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
Summary
We have some projects running with an older, pinned uv version in docker containers, but the lock file is updated by developers with the most recent uv version installed. This can lead to problems:
- 0.5.19 added support for omitting dynamic package versions from the lock file. We have some projects with such dynamic versions, but locking with 0.5.19 or newer makes the lock file unreadable by older uv versions.
- If a 0.6.x version was released with explicit backward compatibility conflicts, we'd be further up the creek without a paddle.
We can set required-version to prevent using newer uv versions:
[tool.uv]
required-version = ">=0.5.0,<0.5.19"but then anyone with a newer uv can't update the lockfile as uv currently will exit with an error when encountering a required-version pin that doesn't match its own version. UNLESS they use uv tool run to install the older uv version to do the work:
% uv lock
error: Required uv version `>=0.5.0, <0.5.19` does not match the running version `0.5.25`
% uv tool run --with 'uv>=0.5.0,<0.5.19' uv lock
Resolved 149 packages in 994msCould uv do this directly please? Specifically, when the required-version requirement can't be met by the current uv version, uv finds a version of itself that does match the requirement and run the desired command with that version instead.
Example
When running uv with a version that doesn't satisfy the required-version requirements for the current project, instead of exiting with an error, uv finds a version of itself that does satisfy the requirements:
% cd "$(mktemp -d)"
% uv init
Initialized project `tmp-luczgh2pmf`
% cat >>pyproject.toml <<EOF
heredoc> [tool.uv]
heredoc> required-version=">=0.5.0,<0.5.19"
heredoc> EOF
% uv sync # executes as `uv tool run --with "uv$(yq -r '.tool.uv.required-version // ""' pyproject.toml)" uv sync`
Resolved 1 package in 7ms
Audited in 0.02ms