Commits
Click on a commit to change the comparison rangeDon't allow local versions when a non-local version is pinned
See https://github.com/astral-sh/uv/issues/16368
Current behavior of `uv sync`:
* Requested: `1.0.0+cpu`, Installed: `1.0.0`: Install new package
* Requested: `1.0.0+cpu`, Installed: `1.0.0+cu128`: Install new package
* Requested: `1.0.0`, Installed: `1.0.0+cpu`: Keep installed package
The new behavior is to always reinstall when the local version part is
different, for consistency and to fix torch.
This behavior happens because internally, we translate the version from
the lockfile to an `=={version}` request, and version matching says
local versions are allowed if the specifier has no local version.
This is a (minor) behavior change: When running `uv sync` in a venv with
a package after installing the same package with the same version except
the local version, uv will now remove the installed package and use the
one from the lockfile instead. This seems more correct, as the other
version was not matching the lockfile. There is still a gap as what we
actually want to track is the index URL (or even better, the package
hash), but as that information is not tracked in the venv, checking the
local version is the next bests thing we can do. The main motivation is
fixing torch, our main user of packages with both local and non-local
versions (https://github.com/astral-sh/uv/issues/16368).