←back to thread

Fun with uv and PEP 723

(www.cottongeeks.com)
619 points deepakjois | 1 comments | | HN request time: 0.445s | source
Show context
js2 ◴[] No.44371129[source]
So far I've only run into one minor ergonomic issue when using `uv run --script` with embedded metadata which is that sometimes I want to test changes to the script via the Python REPL, but that's a bit harder to do since you have to run something like:

  $ uv run --python=3.13 --with-requirements <(uv export --script script.py) -- python
  >>> from script import X
I'd love if there were something more ergonomic like:

  $ uv run --with-script script.py python
Edit: this is better:

  $ "$(uv python find --script script.py)"
  >>> from script import X
That fires up the correct python and venv for the script. You probably have to run the script once to create it.
replies(2): >>44371484 #>>44371734 #
mayli ◴[] No.44371484[source]
you are welcome

    cat ~/.local/bin/uve
    #!/bin/bash
    temp=$(mktemp)
    uv export --script $1 --no-hashes > $temp
    uv run --with-requirements $temp vim $1
    unlink $temp
replies(2): >>44371562 #>>44380025 #
1. nomel ◴[] No.44371562[source]
This is rather silly.