mirror of https://github.com/astral-sh/uv
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
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -15078,6 +15078,7 @@ fn lock_explicit_default_index() -> Result<()> {
|
|||
DEBUG Using request timeout of [TIME]
|
||||
DEBUG Found static `requires-dist` for: [TEMP_DIR]/
|
||||
DEBUG No workspace root found, using project root
|
||||
DEBUG Static `requires-dist` for `project==0.1.0 @ editable+.` is out-of-date; falling back to distribution database
|
||||
DEBUG Found static `pyproject.toml` for: project @ file://[TEMP_DIR]/
|
||||
DEBUG No workspace root found, using project root
|
||||
DEBUG Ignoring existing lockfile due to mismatched requirements for: `project==0.1.0`
|
||||
|
|
|
|||
Loading…
Reference in New Issue