-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Don't allow local versions when a non-local version is pinned #16480
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
See #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 (#16368).
|
So
Will now install a new package? I'm a little worried that specific case will break use-cases where people are using local versions for non-accelerator purposes. Does this change |
Yes
Do you have a specific example?
All cases of using For |
Unfortunately no. I think the user story would be roughly that the override a dependency in their requirements file with some local version then perform a sync with the requirements file and expect their locally patched version to be retained. |
|
Another case where we observe this is https://github.com/karpathy/nanochat (
It's arguable that you don't actually want the PyPI version, but it seems counterintuitive that |
See #16368
Current behavior of
uv sync:1.0.0+cpu, Installed:1.0.0: Install new package1.0.0+cpu, Installed:1.0.0+cu128: Install new package1.0.0, Installed:1.0.0+cpu: Keep installed packageThe 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 syncin 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 (#16368).Fix #16368