💭 Lazy self-installing Python scripts with uv ============================================= !https://treyhunner.com/2024/12/lazy-self-installing-python-scripts-with-uv/ Date: December 24, 2024 Lazy self-installing Python scripts with uv I frequently find myself writing my own short command-line scripts in Python that help me with day-to-day tasks. It’s so easy to throw together … treyhunner.com [1] 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. ``` bash #!/usr/bin/env -S uv run --script # /// script # requires-python = ">=3.12" # dependencies = [ # "ffmpeg-normalize", # ] # /// ``` !!! note This post is a thought [2]. It's a short note that I make about someone else's content online #thoughts [3] References: [1]: https://treyhunner.com/2024/12/lazy-self-installing-python-scripts-with-uv/ [2]: /thoughts/ [3]: /tags/thoughts/