Streamlined Script Execution with uvr
uv is a Python package manager and script runner. uvr selects an interpreter for Python scripts and resolves commands from a project's .venv or PATH. It delegates to uv when a script requests uv-managed execution, such as with PEP 723 inline metadata or a uv shebang.
Call uvr with a script or command:
uvr [options] [--] script.py [script arguments]
uvr [options] [--] command [arguments]
Decision Rules
Rules are applied in this order:
uvr -handuvr --helpprint help.uvr --versionoruvr -Vprints the package version and the resolved executable, module, and Python interpreter paths.- With no target,
uvrstarts Python. It uses a usable activeVIRTUAL_ENV, then a project.venv. If the current directory is inside a project but that project has no usable.venv, it reports an error. Outside a project it starts system Python 3. uvr --scriptoruvr --gui-scriptexplicitly requests uv-managed script execution.- Otherwise, a script with a non-Python manager in its shebang is handed to that manager. Examples include
uv run --script,poetry run python, andconda run -n my-env python. A shebang naminguvritself is not recursively invoked. - A script containing PEP 723 inline script metadata is run by
uv, so its declared dependencies and Python requirement are honored. This takes precedence over a discovered project.venv. - Other Python scripts use the active
VIRTUAL_ENV, then the nearest project.venv. Project roots are detected bypyproject.toml,uv.lock, orpoetry.lock. If a project root has no usable.venv,uvrreports an error rather than silently selecting a different Python. - A Python script outside a project and without an active venv uses system Python 3. Set
UVR_SYSTEM_PYTHONto select its executable explicitly. The default is/usr/bin/python3on Unix-like systems andpy -3on Windows. - For commands,
uvrchecks the selected venv'sbinorScriptsdirectory first, then searchesPATH. It does not useuv runas a command fallback.
The active VIRTUAL_ENV takes precedence over a project .venv. uvr does not install or synchronize dependencies in either environment.
Python Packages
UVR_SYSTEM_PYTHON selects an interpreter; it does not install packages. Install packages into an isolated project .venv when possible. Packages can also be installed into a separately managed Python installation, but mixing dependencies into an OS-managed Python may conflict with the operating system's package manager.
Installation
Prerequisite: uv must be installed and available on your PATH.
To install uvr, use the following command:
uv tool install uvr
To upgrade uvr, use the following command:
uv tool upgrade uvr
Windows Console Modes
Two entry points are installed:
uvr— console application. Use from a terminal or for scripts that need a command-line window.uvr-gui— GUI application. Use for scripts started by double-click or for GUI-only programs that must not open a console window.
When uvr-gui is started by another process that redirects its standard
streams — an editor, Inkscape, or a build tool — the child still writes to
those pipes; only the console window is suppressed.
On Linux and macOS both commands behave the same.
Usage
Examples of running scripts and commands with uvr:
-
Using
uv run --project <project_path> <script_path>:-
This command explicitly tells
uvto run the specified Python script within the context of the project located at<project_path>. -
This is useful when your script relies on dependencies defined within a specific project directory but is executed from elsewhere.
-
Example:
uv run --project /path/to/project [options] /path/to/project/script.py [script_options]
-
-
Using
uvr script.py:-
uvrselects the interpreter based on the decision rules above. -
Example:
uvr [options] [--] script.py [script_options]
-
For ambiguity and edge cases, use
--(see the section General Rule for Using the--Separator).
-
-
Shebang Usage:
-
Example:
#!/usr/bin/env -S uvr [options] [--] # Your Python code here...
-
Note on
-Sflag: The-Sflag allows passing multiple arguments to the interpreter. It is optional if yourenvimplementation supports it (most modern systems do). However:- Without
-S: You can only use#!/usr/bin/env uvrwithout additional options or parameters - With
-S: You can pass options like#!/usr/bin/env -S uvr --with dep1 -- - Some older or minimal Unix-like systems may not support the
-Sflag inenv
- Without
-
If you pass script arguments, use
--to separateuvr/uvoptions from script arguments.
-
-
Scripts without
.pyor.pywextension:-
For extensionless script files,
uvruses--scriptwhen needed to preserve script execution. A shebang naming another manager is handed to that manager. -
Example: For a
fooscript:#!/usr/bin/env -S uvr [options] [--] # Your Python code here...
This is treated as a Python script. Use an explicit manager shebang, such as
#!/usr/bin/env -S uv run --script, when the script must use that manager. -
Or, to be more explicit, you can include the
--scriptflag directly in the shebang:#!/usr/bin/env -S uvr --script -
Commands such as
uvr black .oruvr pytestare resolved from the selected venv and thenPATH; they are not treated as Python scripts.
-
-
Debug usage:
- Example:
uvr -v [options] [--] script.py [script_options] uvr -vv [options] [--] script.py [script_options]
- Example:
-
Offline mode: - When
UV_OFFLINE=1is set or--offlineis passed among theuvrpre-options,uvrdoes not invoke uv for script dependency resolution. - Python scripts run directly from the selected venv. A script that needs uv-managed metadata but has no usable venv fails rather than resolving or downloading dependencies. - Commands are still resolved from the selected venv and thenPATH.- Examples:
UV_OFFLINE=1 uvr script.py uvr --offline script.py uvr --offline -- script.py --some-script-arg uvr --offline pytest -q
- Examples:
General Rule for Using the -- Separator
The -- argument functions as a standard command-line delimiter. It separates options intended for uvr (and, for uv-managed scripts, uv) from arguments intended for the target script or command.
Arguments appearing before -- are processed by uvr. Arguments appearing after -- are passed directly to the invoked script or command.
This explicit separation is crucial for:
-
Preventing Ambiguity:
uvremploys a basic heuristic to identify the script path (the first non-hyphenated argument). This can lead to misinterpretation if the script itself accepts options that resembleuvr/uvarguments. -
Ensuring Precise Argument Passing: By using
--, users guarantee that all subsequent arguments are correctly delivered to their script, bypassinguvr'sargument parsing logic.
Recommendation: Utilize the -- separator whenever precise control over argument distribution between uvr/uv and the target script is required.
Ctrl+C (SIGINT) Handling
uvr exits with status code 130 when interrupted with Ctrl+C.
- It suppresses Python traceback noise (unwanted junk output) on user interruption.
- When running the no-argument interactive Python REPL,
uvrterminates and waits for the Python child so it cannot remain attached to the terminal afteruvrexits. - Python may print a
KeyboardInterrupttraceback before the child is terminated. - Status
130follows the common Unix convention:128 + 2(SIGINTis signal number2).
Platform note:
- On Linux and macOS,
130matches the common signal-derived convention (128 + SIGINT 2). - On Windows,
130is used intentionally as a consistent, cross-platform interruption code foruvr.
Security Notes
uvr is a command runner, not a sandbox. It executes the script or command you pass to it, directly or through the manager selected by the script's shebang.
Main risks:
- Running untrusted scripts can execute arbitrary code.
- Untrusted dependency sources can introduce supply-chain risk.
- Running as root/Administrator increases impact if something goes wrong.
- A compromised
PATHcould resolve a maliciousuvbinary.
Recommended protections:
- Run only trusted scripts and trusted dependency sources.
- Do not run
uvras root/Administrator unless strictly required. - In CI, pin dependencies and use a lockfile where possible.
- Prefer explicit script paths for automation (
script.py) over ambiguous invocations. - Keep build/runtime environments isolated (virtual environments, containers, CI runners).
- Ensure your
PATHresolves to the expecteduvexecutable.
Scope note:
uvris not a sandbox. It is a command runner helper and should be used with standard secure development practices.
Metadata
Release files for uvr 0.2.7
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| uvr-0.2.7.tar.gz | 10.8 kB | Without provenance | Details for uvr-0.2.7.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| uvr-0.2.7-py3-none-any.whl | Python 3 | none | any | Details for uvr-0.2.7-py3-none-any.whl |
Total release size: 22.1 kB
Release files / uvr-0.2.7.tar.gz
| Download URL | uvr-0.2.7.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1a76d74fa325123ca9174cd8cd295183c56f522898b6efc82e22392c66a4bfd5
|
|
BLAKE2b-256 checksum How to use checksums |
5acb44eac75a33236f23a43919497656c579f72849fe73eb74a8c36fb7381675
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.24
|
Release files / uvr-0.2.7-py3-none-any.whl
| Download URL | uvr-0.2.7-py3-none-any.whl |
|---|---|
| Size | 11.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
29bb9fa7c1928ba9abb14b7cab34ebc042be625706a49dd7e117e2d77199b5dc
|
|
BLAKE2b-256 checksum How to use checksums |
27354426a62037624ebfaa7633e31236c40875f436dd9085718cc14177f64322
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.24
|
Security for uvr 0.2.7
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.