uv icon indicating copy to clipboard operation
uv copied to clipboard

Possibility for no output when running a script with `uv run main.py` (that has filled requirements)

Open justcallmelarry opened this issue 1 year ago • 1 comments

Perhaps this is possible already, but I tried both looking in the documentation and in the code but was not able to figure out a way, if it is already possible, sorry for the extra work…

In the section of the docs regarding script dependencies (which is a GREAT feature!), it shows example output which does not have the "Reading inline script metadata from: example.py" line at the top.

I can't seem to replicate the behaviour though, and it looked to my inexperienced Rust eyes that it is in fact always printed to stderr if it is a script being run.

Would love to have a config setting possibility to not print this line, and only the output (if any) from the script.

justcallmelarry avatar Aug 23 '24 07:08 justcallmelarry

Did you try uv run -q main.py?

zanieb avatar Aug 23 '24 13:08 zanieb

@zanieb nope! thanks! i should have found that one, i was mainly looking in the scripts part (as the run command doesn't give output generally while running in projects), but I should have checked the --help as well (or the corresponding page).

Thanks!

I did put it in my alias now, so for my workflow it works out nicely :) Sorry for the extra ticket and thanks for all your great work!

justcallmelarry avatar Aug 23 '24 14:08 justcallmelarry

Is this output necessary to have by default? I've just tried out uv run for the first time with a script that has the inline metadata specified. My expectation was that it does not print that, only if I call it with --verbose.

mschoettle avatar Sep 16 '24 21:09 mschoettle

It seems generally helpful to understand that your invocation is going to run in an entirely different environment than other uv run requests. What's the problem with the output?

zanieb avatar Sep 16 '24 21:09 zanieb

Apologies, that was my bad. I realized after using it more that there is more output that can be shown besides the one line that I saw "Reading inline script metadata from: ...".

mschoettle avatar Sep 17 '24 16:09 mschoettle

@zanieb

What's the problem with the output?

why should the output of "uv run hello.py" be different than python hello.py?

uv run -q hello.py

Hello world!

This still prints a newline, which can be annoying/breaking if you need to pipe the output for further processing.

woutervh avatar Nov 06 '24 08:11 woutervh