Create and run uv scripts with POSIX standardized shebang line
Project description
uvrs
This program is meant to be used in a shebang line, like this:
#!/usr/bin/env uvrs
Unlike the shebang line recommended by uv's documentation, the above shebang does not rely on the non-standard -S option (see uv issue 11876).
Installation
This should be installed as a globally available tool (so the above shebang line works):
uv tool install uvrs
Primary Usage
The primary purpose of the uvrs command is to accept a filename to be run as a uv script.
The uvrs command is not designed to run a script on its own.
If you need to run a script, use uv run for that.
The uvrs command can also be used to:
- Create new uv scripts with a
uvrsshebang line - Update existing uv scripts to use a
uvrsshebang line
Creating new uv scripts
To initialize a new uv script with a uvrs shebang line use the init command:
uvrs init ~/bin/my-script --python 3.12
This will create the file ~/bin/my-script using uv init --script ~/bin/my-script --python 3.12 and then add an appropriate shebang line to the beginning of the script:
#!/usr/bin/env uvrs
# /// script
# requires-python = ">=3.12"
# dependencies = []
# ///
def main() -> None:
print("Hello from my-script!")
if __name__ == "__main__":
main()
Updating existing uv scripts
To update an existing uv script to use the uvrs shebang, use the fix command:
uvrs fix ~/bin/my-script
If the file does not yet have a shebang line, this shebang line will be added:
#!/usr/bin/env uvrs
If the file being fixed already has a shebang line which uses uv run, the shebang will be updated to use uvrs instead.
Managing dependencies
To update the dependencies within inline script metadata, use uvrs add and uvrs remove.
To add a new dependency:
uvrs add ~/bin/my-script 'rich'
This is simply a shortcut for running uv add --script ~/bin/my-script 'rich'`.
To remove a new dependency:
uvrs remove ~/bin/my-script 'rich'
This is simply a shortcut for running uv remove --script ~/bin/my-script 'rich'`.
The goal
Eventually, I would like to see a similar tool integrated into uv.
Until that time, I plan to maintain this uvrs tool.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file uvrs-0.3.0.tar.gz.
File metadata
- Download URL: uvrs-0.3.0.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69a82d1abaa2098933ac41ed5b54f90e9d276166f066fea49615e33990c55edf
|
|
| MD5 |
c8808dc17a14493aed7a4e20a5de5a2e
|
|
| BLAKE2b-256 |
b1c59ce159c063c5193218befb462440fd87fbd23c030554a553743051c2b0df
|
File details
Details for the file uvrs-0.3.0-py3-none-any.whl.
File metadata
- Download URL: uvrs-0.3.0-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b4d50d889de1ac7b2ddc9e33598b0b1e40baef37a15963d2a0f06137f4f04600
|
|
| MD5 |
9ede01a57bd8eec924f4368ca1962e06
|
|
| BLAKE2b-256 |
8259ce1a824b660c769fda421d89ec2ef23b7db89bccf1536973ab483e184e41
|