Skip to content

Conversation

abkfenris
Copy link
Contributor

@abkfenris abkfenris commented Aug 2, 2025

Adds a JSON output allowing pixi tree —json to hopefully be easily
consumable by tools like marimo.

❯ pixi tree --json --manifest-path tests/data/mock-projects/test-project-export/pixi.toml
[
  {
    "name": "ca-certificates",
    "version": "2024.8.30",
    "tags": [],
    "dependencies": []
  },
  {
    "name": "python",
    "version": "3.12.6",
    "tags": [],
    "dependencies": [
      {
        "name": "bzip2",
        "version": "1.0.8",
        "tags": [],
        "dependencies": []
      },
      {
        "name": "libexpat",
        "version": "2.6.3",
        "tags": [],
        "dependencies": []
      },
      {
        "name": "libffi",
        "version": "3.4.2",
        "tags": [],
        "dependencies": []
      },
      {
        "name": "libsqlite",
        "version": "3.46.1",
        "tags": [],
        "dependencies": [
          {
            "name": "libzlib",
            "version": "1.3.1",
            "tags": [],
            "dependencies": []
          }
        ]
      },
      {
        "name": "libzlib",
        "version": "1.3.1",
        "tags": [],
        "dependencies": []
      },
      {
        "name": "ncurses",
        "version": "6.5",
        "tags": [],
        "dependencies": []
      },
      {
        "name": "openssl",
        "version": "3.3.2",
        "tags": [],
        "dependencies": [
          {
            "name": "ca-certificates",
            "version": "2024.8.30",
            "tags": [],
            "dependencies": []
          }
        ]
      },
      {
        "name": "readline",
        "version": "8.2",
        "tags": [],
        "dependencies": [
          {
            "name": "ncurses",
            "version": "6.5",
            "tags": [],
            "dependencies": []
          }
        ]
      },
      {
        "name": "tk",
        "version": "8.6.13",
        "tags": [],
        "dependencies": [
          {
            "name": "libzlib",
            "version": "1.3.1",
            "tags": [],
            "dependencies": []
          }
        ]
      },
      {
        "name": "tzdata",
        "version": "2024a",
        "tags": [],
        "dependencies": []
      },
      {
        "name": "xz",
        "version": "5.2.6",
        "tags": [],
        "dependencies": []
      }
    ]
  },
  {
    "name": "rich",
    "version": "13.8.1",
    "tags": [],
    "dependencies": [
      {
        "name": "markdown_it_py",
        "version": "3.0.0",
        "tags": [],
        "dependencies": [
          {
            "name": "mdurl",
            "version": "0.1.2",
            "tags": [],
            "dependencies": []
          }
        ]
      },
      {
        "name": "pygments",
        "version": "2.18.0",
        "tags": [],
        "dependencies": []
      }
    ]
  }
]

Closes #4130

@abkfenris abkfenris force-pushed the tree-json branch 2 times, most recently from c391e7f to 40dbb1a Compare August 2, 2025 01:35
Adds a JSON output allowing `pixi tree —json` to hopefully be easily 
consumable by tools like marimo.

Closes prefix-dev#4130
@abkfenris abkfenris marked this pull request as ready for review August 2, 2025 01:48
@lucascolley
Copy link
Collaborator

cc @manzt

@lucascolley lucascolley added area:tree Related to pixi tree enhancement New features labels Aug 5, 2025
Copy link
Contributor

@ruben-arts ruben-arts left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Comment on lines +175 to +182
.map_err(|e| {
if e.kind() == std::io::ErrorKind::BrokenPipe {
// Exit gracefully
std::process::exit(0);
} else {
e
}
})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We dont do this anywhere else, can you explain why this is needed?

@lucascolley lucascolley changed the title feat: Tree json representation feat(tree): json representation Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:tree Related to pixi tree enhancement New features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add pixi tree --json
4 participants