uv
uv copied to clipboard
`uv pip tree` improvement
Some additional features that did not land as part of https://github.com/astral-sh/uv/pull/3859:
- [ ] Proper handling of extras
- [x]
--no-dedupe(https://github.com/astral-sh/uv/pull/4449) - [x]
--pruneand--depth(https://github.com/astral-sh/uv/pull/4440) - [ ]
--packages - [ ]
--reverse - [ ] Machine readable output (e.g. JSON with
-j)
Can you create specific issues for each of these so we can track contributions easier?
how would --no-dedupe and the current behavior for printing out dependency cycles would interact? wouldn't it end up with an infinite loop?
We would need to deduplicate cycles still, but we can show anything that's not a cycle.
should we also print (**) instead of (*) for cyclic dependencies? it may be nice to disambiguate between the regular de-duplication and cyclic dependencies.
If you use --no-dedupe we can just use (*) still and change the footnote to say it's a cycle. idk if we need to highlight cycles further in the default output, sounds hard to read.
May I propose to add a machine-readable output like JSON/CSV/Toml/whatever to the list of improvements?
So I can hack uv pip tree output to produce a mermaid graph of dependencies (and emulates pipdeptree --mermaid > dependencies.mmd)?
+1 on adding JSON -j to pipdeptree and other machine readable outputs. Example output:
[
....
{
"package": {
"key": "werkzeug",
"package_name": "Werkzeug",
"installed_version": "3.0.3"
},
"dependencies": [
{
"key": "markupsafe",
"package_name": "MarkupSafe",
"installed_version": "2.1.5",
"required_version": ">=2.1.1"
}
]
}
]
@zanieb I think this accidentally got closed in #4449; #4440 hasn't been merged yet and contains some of the additional features being asked for (--depth and --prune). There was also the bullet on proper handling of extras.
You might also want to ask about creating follow-up issues for the output flags that were mentioned in comments (--mermaid, -j, etc.).
I mostly use pipdeptree with its -p / --packages and -r / --reverse flags; I'd love to see uv pip tree have equivalent functionality!
(let me know if I should open a new issue for that :-) )
We're on the loose with this issue right now — seems to be working fine since @ChannyClaus is just doing them all :)
Please chime in if you're interested in doing any of these improvements though!
oh okay yah i can add those (--packages and --reverse that is) 🌵
was going to make a PR for the extras (since this would be a "breaking" change unless it's behind a flag?) once https://github.com/astral-sh/uv/pull/4440 merged but maybe i'll just stack them on top of each other or something...
I don't think you need to worry about breaking changes in the text output since it's meant for users to "view".
Thanks @ChannyClaus for all your work on this! Splitting the remaining two issues into https://github.com/astral-sh/uv/issues/4711 and https://github.com/astral-sh/uv/issues/4710.