You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
e.g. JSON with -j. This is useful for interacting with graph tools such as mermaid.
Reacted by Sorin Sbarnea, John Paton, Alex Ball, Sandy Fraser, Sebastian Schuberth, MarkusSintonen, Marcel Bochtler, Myles Scolnick, Chamal Gomes, Kapil Thangavelu and 3 more
should this be part of uv pip tree or uv pip list? uv pip list --format json seems to already print something very similar to what pipdeptree --json prints:
additionally the output of pipdeptree --json doesn't seem to necessarily relate to the concept of tree, since when there's a nested dependency, it doesn't actually nest it in the json output.
I'm interested in this in an SBOM context. A JSON representation of the tree would be a fantastic precursor format that can be easily post-processed into one of the many SBOM formats out there. In particular, being able to distinguish between direct and transitive dependencies is key.
(not sure if doing this in uv pip list would work for this usage? If it does, great!)
interested in any ongoing work here. I recognize that people want to at least distinguish between transitive and direct dependencies, and this is ofc doable at a glance, though there seems to be no specification on how people want it to look like. Personally I don't mind a flattened list approach for our needs where we would just have packages listed with the dependency type as a field in the object. Just gonna throw a suggestion:
for the dependencies, we would only need the package identifier and the constraint. We can collect the actual package info in the flat list and you would be able to build from this a graph including the constraints each dependency had, vs the actual resolved version. Also trivial to format this way since we have the tree, it's just leaf-first traversal at that point to turn them into this I assume?
If people are okay with that or don't care within a day or so I'll start finalizing this including some flag logic (for example --invert makes no sense with json formats)
Triage: #16523 added JSON formatted SBOM support to uv export, which we encourage over the pip compatibility layer for users who are already using uv lockfiles 🙂
Hi, I am interested in implementing this. Before I send a PR I want to confirm the right form-factor, since I see #10886 was closed and the discussion in the thread has shifted.
My read of the current state is that:
uv export --format cyclonedx/spdx (PR Add SBOM export support #16523) is now the canonical SBOM path for lockfile-aware users.
pip tree --format json would still serve users who are not on uv lockfiles and want a tree-shaped graph (e.g., the Mermaid use case in the original issue).
The design tension @zanieb raised (pip list vs pip tree overlap, future uv list) applies to the format flag too.
And the two questions I have are:
Is pip tree --format json still a wanted addition, or has uv export superseded the use case enough that this should be closed
If wanted, should the JSON shape be nested (preserving the tree, matching pipdeptree --json) or flat with requires/required-by edges (matching what tjni proposed in Print dependencies in uv pip list. #10886)?
Happy to implement once the form-factor is settled. Thanks!
I don't really think we should spend time on this, given the existence of uv export (for lockfile users), and the relative lack of interest (upvotes) on the issue in the past two years.
Reacted by Suryansh Sijwali, William Woodruff and Ibraheem Ahmed
Activity
zanieb commentedon Jul 1, 2024
I think we should probably use
--format jsonfor consistency with other interfaces?zanieb commentedon Jul 1, 2024
See also #411
ChannyClaus commentedon Jul 3, 2024
should this be part of
uv pip treeoruv pip list?uv pip list --format jsonseems to already print something very similar to whatpipdeptree --jsonprints:additionally the output of
pipdeptree --jsondoesn't seem to necessarily relate to the concept of tree, since when there's a nested dependency, it doesn't actually nest it in the json output.thoughts @dsully @kdeldycke?
kdeldycke commentedon Jul 3, 2024
Oh I'm not really picky about the shape of the JSON output, as long as it is machine readable.
That's because I'm only interested in creating a Mermaid diagram to visualize dependencies like so: https://kdeldycke.github.io/meta-package-manager/install.html#python-dependencies
So whatever the JSON looks like, I'll have to write a script to generate the
.mmdfile out ofuv pip treeoutput.paveldikov commentedon Jul 24, 2024
I'm interested in this in an SBOM context. A JSON representation of the tree would be a fantastic precursor format that can be easily post-processed into one of the many SBOM formats out there. In particular, being able to distinguish between direct and transitive dependencies is key.
(not sure if doing this in
uv pip listwould work for this usage? If it does, great!)kdeldycke commentedon Aug 2, 2024
Lol. I just realized I solved this problem myself, as my Meta Package Manager CLI allows you to:
Export a JSON list of installed packages from a uv environment:
{ "uv": { "errors": [], "id": "uv", "name": "UV", "packages": [ { "id": "alabaster", "installed_version": "0.7.16", "name": null }, { "id": "arrow", "installed_version": "1.3.0", "name": null }, { "id": "attrs", "installed_version": "23.2.0", "name": null }, ...Export an SBOM of a uv environment:
{ "SPDXID": "SPDXRef-DOCUMENT", "creationInfo": { "created": "2024-08-02T23:29:10Z", "creators": [ "Tool: meta-package-manager-5.18.1" ] }, "dataLicense": "CC0-1.0", "name": "macOS-Darwin-23.6.0-arm64", "spdxVersion": "SPDX-2.3", "documentNamespace": "https://github.com/kdeldycke/meta-package-manager/releases/tag/v5.18.1/fdcf50b29504cc4c0df620af2283ed3", "packages": [ { "SPDXID": "SPDXRef-pkg-uv-alabaster-0.7.16", "downloadLocation": "https://www.example.com", "externalRefs": [ { "referenceCategory": "PACKAGE_MANAGER", "referenceLocator": "pkg:uv/[email protected]", "referenceType": "purl" } ], "filesAnalyzed": false, "name": "alabaster", "primaryPackagePurpose": "INSTALL", "supplier": "Organization: UV", "versionInfo": "0.7.16" }, { "SPDXID": "SPDXRef-pkg-uv-arrow-1.3.0", "downloadLocation": "https://www.example.com", "externalRefs": [ { "referenceCategory": "PACKAGE_MANAGER", "referenceLocator": "pkg:uv/[email protected]", "referenceType": "purl" } ], "filesAnalyzed": false, "name": "arrow", "primaryPackagePurpose": "INSTALL", "supplier": "Organization: UV", "versionInfo": "1.3.0" }, ...dsully commentedon Oct 12, 2024
I'm not picky about the output of the JSON either, and it doesn't need to take a tree shape.
Just represent the consumers and producers in the environment / lock file.
Alternatively if there was a consumable crate that I could depend on to walk the tree/lock file that would almost be better.
kapilt commentedon Jun 25, 2025
I'd prefer a tree shape to be able to understand the top level depend, ie which package in a workspace pulled in this dependency.
cr-klarna commentedon Aug 29, 2025
interested in any ongoing work here. I recognize that people want to at least distinguish between transitive and direct dependencies, and this is ofc doable at a glance, though there seems to be no specification on how people want it to look like. Personally I don't mind a flattened list approach for our needs where we would just have packages listed with the dependency type as a field in the object. Just gonna throw a suggestion:
e.g.
for the dependencies, we would only need the package identifier and the constraint. We can collect the actual package info in the flat list and you would be able to build from this a graph including the constraints each dependency had, vs the actual resolved version. Also trivial to format this way since we have the tree, it's just leaf-first traversal at that point to turn them into this I assume?
cr-klarna commentedon Sep 4, 2025
https://github.com/cr-klarna/uv/tree/add-tree-json-format
Ended up needing to sacrifice some initial info, but as an example what I have now would generate for example if given the project:
you would get the following (heavily truncated):
If people are okay with that or don't care within a day or so I'll start finalizing this including some flag logic (for example --invert makes no sense with json formats)
woodruffw commentedon Nov 20, 2025
Triage: #16523 added JSON formatted SBOM support to
uv export, which we encourage over the pip compatibility layer for users who are already using uv lockfiles 🙂SuryanshSS1011 commentedon Jun 4, 2026
Hi, I am interested in implementing this. Before I send a PR I want to confirm the right form-factor, since I see #10886 was closed and the discussion in the thread has shifted.
My read of the current state is that:
And the two questions I have are:
Happy to implement once the form-factor is settled. Thanks!
zsol commentedon Jun 4, 2026
I don't really think we should spend time on this, given the existence of
uv export(for lockfile users), and the relative lack of interest (upvotes) on the issue in the past two years.