uv¶
A Dagger module for uv-managed
Python projects and workspaces.
API reference
This site is a tutorial. The exact functions, arguments, and types are published as generated reference documentation on the Daggerverse.
The module's main job is building selected packages from a uv workspace.
A workspace package usually depends on sibling packages by path, and those have to be
present and installed in the right order before the package itself can be installed.
The module reads your uv.lock, works out which local members the target needs, and
stages them, so one call turns a monorepo package into a minimal container.
It can also:
- Package a project as a relocatable virtual environment that runs in a fresh container with no Python of its own.
- Audit the locked dependencies of every workspace in a source tree.
Each workspace knows its own uv version
Each workspace reads its required-version (from uv.toml, or the [tool.uv] table
of pyproject.toml) and resolves it to a concrete image tag. The audit image and the
default build base both use that version, so the tooling matches what the project
declares. You can override the version or pass your own image.
Installation¶
Install it into your workspace, which makes its checks (one audit per uv workspace)
available to dagger check:
Or add it as a client of your own Dagger module:
Quickstart¶
Build a minimal container with a package and its local dependencies installed:
Audit every workspace in the source tree:
from dagger_clients.uv import uv
# Build a minimal container with a package and its local dependencies installed.
ctr = uv(ws).workspace(".").install(package=["my-app"])
ws is the Dagger workspace the module reads. In your own module, take
ws: Workspace as an argument and Dagger fills it in. To read a directory
instead, pass directory.as_workspace().
The mental model
graph LR
Uv["Uv<br/><i>(your source tree)</i>"] -->|workspace / workspaces| WS["UvWorkspaceSource<br/><i>(one per uv.lock)</i>"]
WS -->|build| B["UvWorkspaceBuild<br/><i>(container + sync plan)</i>"]
WS -->|install| C1["Container"]
B -->|with_local_dependencies / copy_venv| C2["Container"]
B -->|venv| V["UvVenv<br/><i>(venv + its Python)</i>"]
Uvholds the source tree it reads from the Dagger workspace (ws). Ask it for one workspace by path (workspace) or for the collection of every workspace it finds (workspaces).UvWorkspaceSourceis oneuvworkspace (the files rooted at auv.lock). From it you can read the requireduvversion,auditit (a check),builda container step by step, orinstalleverything in one call.UvWorkspaceBuildis an in-progress build: a container plus the resolved sync plan. It exposes the individual pipeline steps so you can run your own steps between them, and exports the result as a container or aUvVenv.
The convenience methods (audit, install) cover the common cases. Use the
pipeline when you need control over the individual steps.
Where to go next¶
- Building containers — assemble a monorepo package's build context and install it.
- Virtual environments — export a portable, relocatable venv.
- Auditing dependencies — scan locked dependencies for known vulnerabilities.
- SDK reference