Skip to content

Include a method to create machine readable output #3199

Closed as duplicate
@pfmoore

Description

@pfmoore

When automating uv, having to parse the command output (which is intended for human readability) is not ideal. It would be useful to have an option to produce machine readable (probably JSON) output from the various uv commands.

  • For uv pip install something along the lines of the pip installation report would probably be a reasonable format.
  • For uv pip list, the pip list --format=json command is probably a good model.
  • uv pip show and uv pip freeze are machine readable, although having a --format=json equivalent for consistency might be worthwhile.
  • uv pip check probably doesn't need an output option, assuming the exit code is success or failure as appropriate.
  • uv pip compile and uv pip sync can probably have an installation report similar to uv pip install. I've not used these myself, though, so I don't know how useful they would be in practice.
  • uv venv could produce JSON output showing details of the created environment - path to the environment, Python executable path, scripts and site-package directories. Basically, the values that the stdlib venv module captures in the "context" object documented here.

To make automation easier, it's probably worth having some additional command line capabilities:

  • An isolated mode, to prevent user config affecting results (uv doesn't have as many possibilities for problems here as pip does, but that may change, I guess...)
  • A "guaranteed quiet" mode that ensures that just the JSON data will be printed to stdout, with any user messages either going to stderr or being suppressed. (Writing the data to a file is another possibility, but IMO it tends to be clumsy to manage).
  • I assume uv always writes its output as UTF-8, but if it doesn't (for example it follows the system defined encoding) then a "guaranteed UTF-8 output" mode would be important to avoid encoding problems.

Metadata

Metadata

Assignees

No one assigned

    Labels

    cliRelated to the command line interface

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions