Skip to content

Commit

Permalink
Omit dynamic versions from the lockfile (#10622)
Browse files Browse the repository at this point in the history
## Summary

This PR modifies the lockfile to omit versions for source trees that use
`dynamic` versioning, thereby enabling projects to use dynamic
versioning with `uv.lock`.

Prior to this change, dynamic versioning was largely incompatible with
locking, especially for popular tools like `setuptools_scm` -- in that
case, every commit bumps the version, so every commit invalidates the
committed lockfile.

Closes #7533.
  • Loading branch information
charliermarsh authored Jan 15, 2025
1 parent d20a48a commit 0617fd5
Show file tree
Hide file tree
Showing 28 changed files with 935 additions and 311 deletions.
2 changes: 2 additions & 0 deletions crates/uv-distribution-types/src/dependency_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ impl DependencyMetadata {
requires_dist: metadata.requires_dist.clone(),
requires_python: metadata.requires_python.clone(),
provides_extras: metadata.provides_extras.clone(),
dynamic: false,
})
} else {
// If no version was requested (i.e., it's a direct URL dependency), allow a single
Expand All @@ -70,6 +71,7 @@ impl DependencyMetadata {
requires_dist: metadata.requires_dist.clone(),
requires_python: metadata.requires_python.clone(),
provides_extras: metadata.provides_extras.clone(),
dynamic: false,
})
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/uv-distribution/src/metadata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ pub struct Metadata {
pub requires_python: Option<VersionSpecifiers>,
pub provides_extras: Vec<ExtraName>,
pub dependency_groups: BTreeMap<GroupName, Vec<uv_pypi_types::Requirement>>,
pub dynamic: bool,
}

impl Metadata {
Expand All @@ -67,6 +68,7 @@ impl Metadata {
requires_python: metadata.requires_python,
provides_extras: metadata.provides_extras,
dependency_groups: BTreeMap::default(),
dynamic: metadata.dynamic,
}
}

Expand Down Expand Up @@ -109,6 +111,7 @@ impl Metadata {
requires_python: metadata.requires_python,
provides_extras,
dependency_groups,
dynamic: metadata.dynamic,
})
}
}
Expand Down
Loading

0 comments on commit 0617fd5

Please sign in to comment.