Hasty Briefsbeta

Bilingual

uv Running a Script with Dependencies

9 months ago
  • #Dependency Management
  • #Python
  • #Scripting
  • Python scripts can be executed using `uv run` for dependency management.
  • Scripts without dependencies can be run directly with `uv run`.
  • Dependencies can be declared inline in scripts or via command-line options.
  • `uv` supports managing virtual environments automatically.
  • Inline metadata in scripts can specify Python version requirements and dependencies.
  • Shebangs can make scripts executable without explicitly using `uv run`.
  • Alternative package indexes can be used with the `--index` option.
  • Dependencies can be locked for reproducibility using `uv lock`.
  • `uv` supports GUI scripts on Windows with `.pyw` extension.
  • Different Python versions can be requested per script invocation.