Repository navigation
feat(tree): json representation - #4261
Merged
Merged
Conversation
Closed
abkfenris
force-pushed
the
tree-json
branch
2 times, most recently
from
August 2, 2025 01:35
c391e7f to
40dbb1a
Compare
Adds a JSON output allowing `pixi tree —json` to hopefully be easily consumable by tools like marimo. Closes prefix-dev#4130
abkfenris
marked this pull request as ready for review
August 2, 2025 01:48
Member
|
cc @manzt |
ruben-arts
reviewed
Aug 5, 2025
ruben-arts
left a comment
Contributor
There was a problem hiding this comment.
Thank you, @abkfenris, I really want this feature!
@MantZ would you be able to give this a swirl?
| name: String, | ||
| version: String, | ||
| tags: Vec<String>, | ||
| dependencies: Vec<DependencyTreeNode>, |
Contributor
There was a problem hiding this comment.
I think it would be nice to jam a little more info in here, we've had people ask for the size and I would say it misses the type (conda or pypi)
baszalmstra
reviewed
Aug 5, 2025
Comment on lines
+175
to
+182
| .map_err(|e| { | ||
| if e.kind() == std::io::ErrorKind::BrokenPipe { | ||
| // Exit gracefully | ||
| std::process::exit(0); | ||
| } else { | ||
| e | ||
| } | ||
| }) |
Contributor
There was a problem hiding this comment.
We dont do this anywhere else, can you explain why this is needed?
Collaborator
|
What is the status of this PR? |
Contributor
Author
|
I was waiting for feedback from the Marimo folks before doing another pass. |
Build the tree once and render it as text or JSON, so both share filtering and deduplication. Works for `pixi tree` and `pixi global tree`, including the regex filter and `--invert`. While I was at it: - List every direct dependency as a root, marked with `(*)` if it was already shown - Sort the roots and dependents of the inverted tree, they were in hash map order - Show `<unknown>` for locked packages without version, also for conda Closes prefix-dev#4130
Hofer-Julian
self-requested a review
November 11, 2026 13:18
Hofer-Julian
approved these changes
Nov 11, 2026
Hofer-Julian
left a comment
Member
There was a problem hiding this comment.
Thank you, I pushed a few improvements to your branch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes #4130
Add
pixi tree --jsonandpixi global tree --json, so tools like marimo don't have to parse the box-drawing output anymore.Builds on the initial version by @abkfenris, adapted to the current tree code.
name,version,kind(conda/pypi),is_explicit,via_extras,is_deduplicatedanddependencies--invert, the children are then listed underrequired_by(*)if it was already shown below another one❯ pixi tree --json --manifest-path examples/editable-with-extras [ { "name": "package_with_extras", "version": null, "kind": "pypi", "is_explicit": true, "via_extras": [], "is_deduplicated": false, "dependencies": [ { "name": "boltons", "version": "24.0.0", "kind": "pypi", "is_explicit": false, "via_extras": [], "is_deduplicated": false, "dependencies": [] }, { "name": "rich", "version": "13.7.1", "kind": "pypi", "is_explicit": false, "via_extras": ["color"], "is_deduplicated": false, "dependencies": [ ...For marimo,
via_extrasmaps to theextratags andis_deduplicatedto thededupetag of theirDependencyTreeNode.Filtering on
kind == "pypi"replaces the cross-check withpixi list --json.AI-generated details (Claude Opus 5.5)
crates/pixi_cli/src/shared/tree.rsnow builds aTreeofTreeNodes once,print_treeandprint_tree_jsonrender it. This keeps filtering, deduplication and ordering identical between both outputs.Package::versionis nowOption<String>, so locked packages without a version serialize asnull. Text shows<unknown>for them.(*), the tree no longer ends in a dangling├──when the last direct dependency was already shown, and-ioutput is sorted.examples/editable-with-extras.--environment,--script, PyPI extras andpixi global tree. All passed; it isn't part of this PR.Checklist: