mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 10:58:28 +00:00
Sort extras and groups when comparing lockfile requirements (#10856)
## Summary The linked issue actually isn't a bug on main anymore, but it does require us to take the "slow" path, since setuptools seems to reorder the extras. This PR adds another normalization step which lets us take the fast path: https://github.com/astral-sh/uv/issues/10855.
This commit is contained in:
parent
d454f9c34b
commit
e02f061ea9
2 changed files with 14 additions and 5 deletions
|
@ -15,7 +15,7 @@ use petgraph::visit::EdgeRef;
|
|||
use rustc_hash::{FxHashMap, FxHashSet};
|
||||
use serde::Serializer;
|
||||
use toml_edit::{value, Array, ArrayOfTables, InlineTable, Item, Table, Value};
|
||||
use tracing::trace;
|
||||
use tracing::debug;
|
||||
use url::Url;
|
||||
|
||||
use uv_cache_key::RepositoryUrl;
|
||||
|
@ -1310,15 +1310,15 @@ impl Lock {
|
|||
let satisfied = metadata.is_some_and(|metadata| {
|
||||
match satisfies_requires_dist(metadata, package, root) {
|
||||
Ok(SatisfiesResult::Satisfied) => {
|
||||
trace!("Static `Requires-Dist` for `{}` is up-to-date", package.id);
|
||||
debug!("Static `requires-dist` for `{}` is up-to-date", package.id);
|
||||
true
|
||||
},
|
||||
Ok(..) => {
|
||||
trace!("Static `Requires-Dist` for `{}` is out-of-date; falling back to distribution database", package.id);
|
||||
debug!("Static `requires-dist` for `{}` is out-of-date; falling back to distribution database", package.id);
|
||||
false
|
||||
},
|
||||
Err(..) => {
|
||||
trace!("Static `Requires-Dist` for `{}` is invalid; falling back to distribution database", package.id);
|
||||
debug!("Static `requires-dist` for `{}` is invalid; falling back to distribution database", package.id);
|
||||
false
|
||||
},
|
||||
}
|
||||
|
@ -4131,7 +4131,15 @@ fn normalize_url(mut url: Url) -> UrlString {
|
|||
/// 2. Ensures that the lock and install paths are appropriately framed with respect to the
|
||||
/// current [`Workspace`].
|
||||
/// 3. Removes the `origin` field, which is only used in `requirements.txt`.
|
||||
fn normalize_requirement(requirement: Requirement, root: &Path) -> Result<Requirement, LockError> {
|
||||
fn normalize_requirement(
|
||||
mut requirement: Requirement,
|
||||
root: &Path,
|
||||
) -> Result<Requirement, LockError> {
|
||||
// Sort the extras and groups for consistency.
|
||||
requirement.extras.sort();
|
||||
requirement.groups.sort();
|
||||
|
||||
// Normalize the requirement source.
|
||||
match requirement.source {
|
||||
RequirementSource::Git {
|
||||
mut repository,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue