Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Output format json #411

Open
konstin opened this issue Nov 13, 2023 · 6 comments
Open

Output format json #411

konstin opened this issue Nov 13, 2023 · 6 comments
Labels
cli Related to the command line interface enhancement New feature or improvement to existing functionality help wanted Contribution especially encouraged
Milestone

Comments

@konstin
Copy link
Member

konstin commented Nov 13, 2023

Our main commands, especially pip-compile, should have a json output format that can be in downstream applications such as auditing, dependabot-like application and our own testing.

@konstin konstin added the enhancement New feature or improvement to existing functionality label Nov 13, 2023
@konstin konstin changed the title output format json Output format json Nov 13, 2023
@charliermarsh charliermarsh added this to the Future milestone Nov 13, 2023
@charliermarsh charliermarsh added the internal A refactor or improvement that is not user-facing label Nov 13, 2023
@bigluck
Copy link

bigluck commented Feb 15, 2024

I'd love it, too :)

@zanieb
Copy link
Member

zanieb commented Jul 1, 2024

#3199 has relevant context for implementing this in the uv pip interfaces

@zanieb zanieb added help wanted Contribution especially encouraged cli Related to the command line interface and removed internal A refactor or improvement that is not user-facing labels Jul 1, 2024
Gankra added a commit that referenced this issue Jan 14, 2025
<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

I use `uv` for automation on remote hosts and it would be useful to have
it be able to tell me the supported versions of python (for the remote
machine) in a machine readable manner so I do not need to parse `uv
python list`.

This change adds `--format (json|text)` to `uv python list` to make it's
output machine readable

Loosely related:

- #411

## Test Plan

Manually tested via

```
# quick inspection without pretty print
cargo run -- python list --format json
```

### Short example of output (trimmed down)

Cmd: `cargo run -- python list --format json | jq '.[:2]'`

```json
[
  {
    "key": "cpython-3.13.1+freethreaded-linux-x86_64-gnu",
    "version": "3.13.1",
    "version_parts": {
      "major": 3,
      "minor": 13,
      "patch": 1
    },
    "path": null,
    "symlink": null,
    "url": "https://github.com/astral-sh/python-build-standalone/releases/download/20241219/cpython-3.13.1%2B20241219-x86_64-unknown-linux-gnu-freethreaded%2Bpgo%2Blto-full.tar.zst",
    "os": "linux",
    "variant": "freethreaded",
    "implementation": "cpython",
    "arch": "x86_64",
    "libc": "gnu"
  },
  {
    "key": "cpython-3.13.1-linux-x86_64-gnu",
    "version": "3.13.1",
    "version_parts": {
      "major": 3,
      "minor": 13,
      "patch": 1
    },
    "path": "/usr/bin/python3.13",
    "symlink": null,
    "url": null,
    "os": "linux",
    "variant": "default",
    "implementation": "cpython",
    "arch": "x86_64",
    "libc": "gnu"
  }
]
```

---------

Co-authored-by: John Zlotek <jzlotek@gmail.com>
@robinjhuang
Copy link

Would love to have this for non-interactive terminals! Any idea when this will be implemented? @Gankra

@Gankra
Copy link
Contributor

Gankra commented Feb 21, 2025

This is gonna take a while and will have to be done piecemeal interface-by-interface.

Some commands like uv python list will probably want to just dump a single json object.

Other commands that compile/install packages will probably benefit from a json-lines streaming output, like the one you can see in cargo/rustc's interface.

It would be helpful to know what commands people specifically need/want this output from to prioritize.

@edgarrmondragon
Copy link
Contributor

It would be helpful to know what commands people specifically need/want this output from to prioritize.

#1442 would be at the top of my list 🙂

@robinjhuang
Copy link

uv pip install is at the top of my list! When installing large downloads like pytorch, it's really helpful to have some form of machine readable progress.

#11121

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Related to the command line interface enhancement New feature or improvement to existing functionality help wanted Contribution especially encouraged
Projects
None yet
Development

No branches or pull requests

7 participants