by TheIronYuppie · 1y ago · 0 comments
E.g.:
#!/usr/bin/env python3
# /// script
# requires-python = ">=3.11"
# dependencies = [
# "psycopg2-binary",
# "pyyaml",
# ]
# ///
Then - uv run -s file.py import os
print(os.environ['VIRTUAL_ENV'] + '/bin/python')
Then, e.g. in VS Code, you bring up the command palette, run Python: Select Interpreter, and enter the result. #!/usr/bin/env uv run --script> Using uv as your shebang line
— https://news.ycombinator.com/item?id=42855258
Since `env` doesn’t pass multiple arguments by default, the suggested line uses `-S`:
#!/usr/bin/env -S uv run --script #!/home/tetha/Tools/uv run #!/usr/bin/env uv run