Allow local version mismatches when validating lockfile (#12285)

## Summary

Closes https://github.com/astral-sh/uv/issues/12282.

## Test Plan

Given:

```toml
[project]
name = "foo"
version = "0.1.0"
description = "Add your description here"
readme = "README.md"
requires-python = ">=3.13.0"
dependencies = ["flash-attn"]

[tool.uv]
environments = ["sys_platform == 'darwin'", "sys_platform == 'linux'"]
constraint-dependencies = ["torch==2.5.1"]

[tool.uv.sources]
flash_attn = [
  { url = "https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.3/flash_attn-2.7.3+cu12torch2.5cxx11abiFalse-cp310-cp310-linux_x86_64.whl", marker = "sys_platform == 'linux' and python_version == '3.10'"},
  { url = "https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.3/flash_attn-2.7.3+cu12torch2.5cxx11abiFalse-cp311-cp311-linux_x86_64.whl", marker = "sys_platform == 'linux' and python_version == '3.11'"},
  { url = "https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.3/flash_attn-2.7.3+cu12torch2.5cxx11abiFalse-cp312-cp312-linux_x86_64.whl", marker = "sys_platform == 'linux' and python_version == '3.12'"},
  { url = "https://github.com/Dao-AILab/flash-attention/releases/download/v2.7.3/flash_attn-2.7.3+cu12torch2.5cxx11abiFalse-cp313-cp313-linux_x86_64.whl", marker = "sys_platform == 'linux' and python_version == '3.13'"}
]
```

Ran `uv lock` on `v0.6.5`. Then verified that `uv lock` fails on
`v0.6.6` on the same lockfile, but this commit succeeds.
This commit is contained in:
Charlie Marsh 2025-03-18 08:12:40 -07:00 committed by GitHub
parent b78f9291fe
commit faf16c1349
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -2874,7 +2874,9 @@ impl PackageWire {
// Consistency check // Consistency check
if let Some(version) = &self.id.version { if let Some(version) = &self.id.version {
for wheel in &self.wheels { for wheel in &self.wheels {
if version != &wheel.filename.version { if *version != wheel.filename.version
&& *version != wheel.filename.version.clone().without_local()
{
return Err(LockError::from(LockErrorKind::InconsistentVersions { return Err(LockError::from(LockErrorKind::InconsistentVersions {
name: self.id.name, name: self.id.name,
version: version.clone(), version: version.clone(),