Skip to content
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

Show full derivation chain when encountering build failures #9108

Merged
merged 1 commit into from
Nov 14, 2024

Conversation

charliermarsh
Copy link
Member

@charliermarsh charliermarsh commented Nov 14, 2024

Summary

This PR adds context to our error messages to explain why a given package was included, if we fail to download or build it.

It's quite a large change, but it motivated some good refactors and improvements along the way.

Closes #8962.

@charliermarsh charliermarsh force-pushed the charlie/chain branch 7 times, most recently from 41f35e9 to 651a074 Compare November 14, 2024 01:06
@charliermarsh charliermarsh changed the base branch from main to charlie/graph November 14, 2024 01:06
@charliermarsh charliermarsh marked this pull request as ready for review November 14, 2024 01:08
@charliermarsh charliermarsh added the error messages Messaging when something goes wrong label Nov 14, 2024
@charliermarsh charliermarsh force-pushed the charlie/chain branch 3 times, most recently from debb749 to cf667fc Compare November 14, 2024 04:50
Copy link
Member

@zanieb zanieb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks great; a review from @BurntSushi seems prudent since I'm not as familiar with the resolver.

Copy link
Member

@BurntSushi BurntSushi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the refactor and this seems like an overall great UX improvement too!

pub enum DistRef<'a> {
Built(&'a BuiltDist),
Source(&'a SourceDist),
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay ref types.

I don't know if you saw it in my conflicting groups PR, but a useful tip if you ever need to use one of these types for key lookups in hashmaps is to use hashbrown and its Equivalent trait.

pub fn version(&self) -> Option<&Version> {
match self {
Self::Built(wheel) => Some(wheel.version()),
Self::Source(source_dist) => source_dist.version(),
}
}

/// Convert this distribution into a reference.
pub fn as_ref(&self) -> DistRef {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh interesting, I thought Clippy didn't like omitting lifetimes like this. e.g., DistRef<'_>.

}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These new helper constructors are a nice refactor!

let mut queue = VecDeque::new();
queue.push_back((target, Vec::new()));

// TODO(charlie): Consider respecting markers here.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without markers, I think this means that you might find the shortest path, but that path might not be possible? Or is there another downside I'm not seeing?

}
}
false
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is neat.

"###);

Ok(())
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I missed it, but do you have a test for the case where the failed dependency is not a direct dependency of the root? I was looking for that to see what the error message looks like.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also was hoping for a longer chain :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's so annoying to test, but yeah, I definitely need to do it.

More

Simplify

Starting to come together

Reverts

Trying to get the lock info from sync

Rewrite resolution into a graph

Add version to ResolvedDist

Fix up graphs

Attach to install everywhere

Attach to install everywhere
@charliermarsh charliermarsh merged commit fe477c3 into main Nov 14, 2024
64 checks passed
@charliermarsh charliermarsh deleted the charlie/chain branch November 14, 2024 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
error messages Messaging when something goes wrong
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Show full dependency chain when uv pip compile encounters an error running setup.py
3 participants