uv icon indicating copy to clipboard operation
uv copied to clipboard

`uv pip list -e -q` outputs nothing.

Open charlesnicholson opened this issue 1 year ago • 7 comments

This one is more entertaining than serious- we deploy Python artifacts as a set of wheels, a constraints file, and a bunch of shell/batch scripts that possibly create the venv and install the wheels etc before launching the corresponding entry point script in the venv.

These shell / batch scripts run from a non-deployed development repository as well, so they have to decide whether to uv pip install anything or just lean on the existing editable-installs of our first-party packages.

To do this, we run uv pip list -e and search the process's stdout: if there are no editable installations matching the requested package name, we install from the wheel file.

Amusingly, our scripts are also quiet by default, so we pass -q to everything.

So, we run uv -q pip list -e, which always prints nothing and quietly messes up our strategy because the output with the "quiet" flag is indistinguishable from the lack of output when uv pip list finds nothing.

Removing the -q flag of course fixes it trivially. I'm totally happy with this being "user error", but I thought it was an interesting / funny way to hold uv wrong.

3caedb8a-1692-4c89-945e-791386768c3d_text

charlesnicholson avatar Apr 02 '24 14:04 charlesnicholson

We agree it probably shouldn't be that quiet :)

Open to suggestions on what should change if anything when --quiet is used in uv pip list

zanieb avatar Apr 02 '24 14:04 zanieb

If it's interesting, my opinion is that if a tool only exists to dump info to stdout/stderr, a quiet flag doesn't make sense and I'd probably not offer it as an option. I'd prefer to be forced to simply not call it, instead of having an option that can confound the meaning of "there was no output".

But it's easy to see the other side too: users are grown-ups, and the tool is giving them what they've explicitly asked for :)

charlesnicholson avatar Apr 02 '24 14:04 charlesnicholson

--quiet is just a global CLI flag that adjusts the verbosity of our logging, I'm not sure if it makes sense to turn off for a single command although I agree it doesn't really make sense in a "show me things" command.

zanieb avatar Apr 02 '24 14:04 zanieb

We should emit this to stdout instead of stderr

zanieb avatar Apr 02 '24 19:04 zanieb

It looks like pip list --quiet also doesn't print :D

charliermarsh avatar Apr 03 '24 01:04 charliermarsh

Any appetite for something like a --json flag that emits the repository installed package manifest to stdout in json format? That way it's easily machine-parseable (unlike the current output), and there's a difference between "no output whatsoever" (-q) and "no output because of requested filters or the venv is just empty"- the latter would emit {\n}\n.

That might be a nice way to disambiguate the cases and make uv pip list easier to tool against, all at the same time, without breaking compatibility with pip list.

charlesnicholson avatar Apr 05 '24 13:04 charlesnicholson

If we emit to stdout instead of stderr it will not be silenced by -q.

There's appetite for machine readable / JSON output throughout the CLI though, yeah.

zanieb avatar Apr 05 '24 14:04 zanieb

I think probably the -q/--quiet flag should be respected here and uv shouldn't emit any output. I think this matches the behavior of other CLI tools like grep. Typically, the utility in a -q/--quiet flag though is that you want to run the command just to determine whether it was successful or not by querying its exit status. I'm not sure that's a meaningful thing to ask of uv pip list, though it conceivably could be I suppose.

BurntSushi avatar Apr 19 '24 14:04 BurntSushi

Yeah, that makes sense to me.

charliermarsh avatar Apr 19 '24 14:04 charliermarsh

Thanks!

zanieb avatar Apr 19 '24 14:04 zanieb