mathspp
  • Blog
    • Pydon'ts
    • Problems
    • TIL
    • Twitter threads
  • Books
  • Talks
  • Trainings
    • Advanced iteration
    • Python for scripting and automation
    • Rust for Python developers
  • Courses
  • About
Link blog

#!/usr/bin/env -S uv run

by Simon Willison on 10-01-2025 15:43 (via)

I started using uv recently and I keep getting impressed by everything I can do in such a convenient way with uv. I've been using uv to manage scripts and script dependencies but using the shebang #!/usr/bin/env -S uv run in scripts and then making them executable (with chmod 755) is on a whole new level.

Essentially, you want your scripts' header to look like this:

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

# code here...

If you think about it, what this means is that you get shell scripts written in Python with self-contained dependencies that uv manages for you...

Previous link Next link

If you like this project, please take the time to give me your feedback! Click the @ below to send me an email.

mathspp
  • Blog
    • Pydon'ts
    • Problems
    • TIL
    • Twitter threads
  • Books
  • Talks
  • Trainings
    • Advanced iteration
    • Python for scripting and automation
    • Rust for Python developers
  • Courses
  • About