Skip to content

Latest commit

 

History

History
27 lines (21 loc) · 773 Bytes

File metadata and controls

27 lines (21 loc) · 773 Bytes

uv run in the Shebang Line

Beginning a script with #!/usr/bin/env -S uv run and then chmod 755 the script.

#!/usr/bin/env -S uv run
# /// script
# requires-python = ">=3.12"
# dependencies = [
#     "flask==3.*",
# ]
# ///
import flask
# ...

This allows you to run the script on any machine with the uv binary installed via ./script.py.

And, it will automatically:

  1. Create its own isolated, sandboxed environment
  2. Install all required dependencies in the environment
  3. Run itself in that environment (even using the correctly installed version of Python)

via alsuren ➡️ diff