uv icon indicating copy to clipboard operation
uv copied to clipboard

`uv pip tree` improvement

Open ibraheemdev opened this issue 1 year ago • 12 comments
trafficstars

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] --prune and --depth (https://github.com/astral-sh/uv/pull/4440)
  • [ ] --packages
  • [ ] --reverse
  • [ ] Machine readable output (e.g. JSON with -j)

ibraheemdev avatar Jun 21 '24 19:06 ibraheemdev

Can you create specific issues for each of these so we can track contributions easier?

zanieb avatar Jun 21 '24 20:06 zanieb

how would --no-dedupe and the current behavior for printing out dependency cycles would interact? wouldn't it end up with an infinite loop?

ChannyClaus avatar Jun 21 '24 21:06 ChannyClaus

We would need to deduplicate cycles still, but we can show anything that's not a cycle.

zanieb avatar Jun 21 '24 21:06 zanieb

should we also print (**) instead of (*) for cyclic dependencies? it may be nice to disambiguate between the regular de-duplication and cyclic dependencies.

ChannyClaus avatar Jun 21 '24 22:06 ChannyClaus

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.

zanieb avatar Jun 21 '24 22:06 zanieb

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)?

kdeldycke avatar Jun 22 '24 08:06 kdeldycke

+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"
            }
        ]
    }
]

dsully avatar Jun 22 '24 17:06 dsully

@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.).

Peiffap avatar Jun 25 '24 12:06 Peiffap

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 :-) )

hauntsaninja avatar Jun 26 '24 22:06 hauntsaninja

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!

zanieb avatar Jun 26 '24 23:06 zanieb

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...

ChannyClaus avatar Jun 27 '24 00:06 ChannyClaus

I don't think you need to worry about breaking changes in the text output since it's meant for users to "view".

zanieb avatar Jun 27 '24 00:06 zanieb

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.

ibraheemdev avatar Jul 01 '24 21:07 ibraheemdev