Closed sequoiayoav closed 4 weeks ago
Does uv run python ./example
work as expected?
Possible workaround:
#!/usr/bin/env uv run -q --no-project --python 3.12 --with requests
It would be nice if uv run
had option --script
that did not need to have an explicit path to the script.
I am using an alias as a workaround in .zshrc
:
alias fahctl='uv run -q --no-project --python 3.12 --with websocket-client fahctl'
Does
uv run python ./example
work as expected?
Does not work for me
% uv run python /usr/local/bin/fahctl
Missing python3-websocket library
The best thing would probably be for python3 itself to understand PEP 723.
We may want an explicit --script
option to treat a path as PEP 723 script without sniffing the extension.
Seems reasonable to me.
Sounds like the perfect solution
First off, thanks for uv.
Came across this issue too and on Ubuntu it not only "does not work", it calls itself recursively. 😨
Example:
#!/usr/bin/env -S uv run
import sys
print(f'sys.executable={sys.executable}')
When I name this file test-uv.py
, make it chmod +x
, then ./test-uv.py
works normally.
However, when I name this file test-uv
, make it chmod +x
, then ./test-uv
never finishes as it spawns itself recursively -- you can see it from this while true; do ps -e ...|grep uv -w; sleep .1; done
:
1110162 1110156 uv run ./test-uv
1110168 1110162 uv run ./test-uv
1110174 1110168 uv run ./test-uv
1110180 1110174 uv run ./test-uv
1110186 1110180 uv run ./test-uv
1110192 1110186 uv run ./test-uv
1110198 1110192 uv run ./test-uv
1110204 1110198 uv run ./test-uv
1110210 1110204 uv run ./test-uv
I used uv
version 0.4.15
.
--script
now exists to power this use-case.
if I make this file and name it
example.py
running
example.py
in my shell just works, But if I rename the file to justexample
and try to run it, uv doesn't recognize it as a python file. this isn't a bug, just want some help on this. (or recommendations) thanks!