-
Notifications
You must be signed in to change notification settings - Fork 642
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
implement uv pip tree
#3859
implement uv pip tree
#3859
Conversation
CodSpeed Performance ReportMerging #3859 will not alter performanceComparing Summary
|
discovered a bit of an issue - the current implementation goes through all extras when constructing the graph, resulting in a cycle way more often. seems like |
I've actually tried adding support for extras to pipdeptree, and it partially works. However, I haven't found the time to clean it up and submit a pull request. My approach is to first consider all extras, but respect the marker (excluding the extra part). Then, while building the extra map, prune impossible extra branches that lack required packages or are unreachable nodes. However, this approach isn't perfect. It determines extra branches based on the installed packages and tries to infer backwards, leading to situations where it can't determine the root package requesting the extra installation correctly. This can happen when two separate packages have similar extra packages. Another approach for the tree might be to leverage the manifest/lock file, which is also used by multiple package management tools like Cargo, pnpm, Poetry, etc. This might be more accurate. My other concern is the tree display for packages with extras, especially those with multiple extras. How should we handle them: aggregate or split them in the display? |
hmm yeah, given the complexity, maybe we shall go with what pipdeptree does for the time being then? |
ec6763e
to
48f35d4
Compare
0607fdf
to
0c39d00
Compare
handled the case where there's a dependency cycle (test at https://github.com/astral-sh/uv/pull/3859/files#diff-ada61e3d2726ed1b05e633096131a477c895c737c6350b8238d9e81b2745e8eaR165) let me know if there's anything else that y'all think should be changed 🌵 |
@charliermarsh let me know if this is kinda low-prio to get in now - wasn't sure if i should keep rebasing on main 😅 |
Charlie's out next week, if I have time I'll take a look! |
thanks! seems like something strange is going on with windows test after rebasing - will try to take a look more this week... |
So I gave this a try today, just to get a sense for the user experience and the output for a small project looks like this
A things I notice here.
For comparison purposes, here's the
Note they display the tree correctly as I requested. It's nice that they show version requirements as well as the installed version, but I still feel like it's way too hard to read as a default output. It seems entirely fine to add support for that separately. |
I also find the cargo behavior around cycles pretty unhelpful as it makes it very difficult to understand how the cycle is happening. What's the problem with displaying cycles? It seems like if
Where if a package is already present at the top-level we omit display of its tree? |
ah my bad - let me try to fix this today.
i can definitely add some sort footnote for this in the output; was just following what
i'd guess it would be more common default to display the versions but putting it behind a flag seems also fine.
i'll make a separate comment on this with an example, when i was playing around with the version that includes extra, installing a few popular packages would create a dependency cycle. seemed like it would be too limiting as a feature to fail on common set of installed packages.
this is actually easier; if preferred, i can revert the code to print the above output? (and error underneath?) |
Note this is pretty painful. The packse implementation may be a helpful reference.
What does it mean though? :) Regarding cycles in extras: I'm not sure why they need to be an error though? It seems like we should be able to display them. |
Another thing that is missing is the current package as the root of the tree.
Cycles could similarly use |
|
Ah thank you @ibraheemdev. Yeah I'm suggesting something like using |
alright, handled:
what's left now?
i'll look at https://github.com/astral-sh/uv/pull/3859/files#r1647760723 in the meantime. |
The branching looks great now! A footnote seems reasonable for Thoughts on extras? Should we pursue it as a follow-up? |
yah, follow-up sounds good. i think it's confusing both ways. if we do show extras, it would be confusing if the user didn't install it with extras. if we do not show extras, as you pointed out, the user will be surprised by them not being linked in the tree output. i'll add a footnote shortly! |
done 🌵
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your work on this (and your patience!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work! Some of the other things we discussed can be addressed in follow-up PRs.
Summary
resolves #3272
cargo tree
+ cleaner code organization, but can make changes if it's preferred the other way.cargo
thanpipdeptree
(pipdeptree
seems to ignore the packages that are part of the dependency cycle and display the rest).Test Plan
added tests 🌵