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
- Add an appropriate shebang line above the first line in the file (e.g. #!/usr/bin/env python3)
- Aet an executable bit on the file (chmod a+x my_script.py)
- 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", # ] # ///