πŸ’­ Lazy self-installing Python scripts with uv

Here's my thought on πŸ’­ Lazy self-installing Python scripts with uv


I really like Trey's steps to making an executable python script with uv

his old process seems to be the same with a new shebang

  1. Add an appropriate shebang line above the first line in the file (e.g. #!/usr/bin/env python3)
  2. Aet an executable bit on the file (chmod a+x my_script.py)
  3. Place the script in a directory that’s in my shell’s PATH variable (e.g. cp my_script.py ~/bin/my_script)

And here is the new format the the shebang followed by the metadata comment block defined in PEP 723.


#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.12"
# dependencies = [
#     "ffmpeg-normalize",
# ]
# ///

Note

This post is a thought. It's a short note that I make about someone else's content online. Learn more about the process thoughts

This post was a thought by Waylon Walker see all my thoughts at https://waylonwalker.com/thoughts