|
| 1 | +**Warning: this documentation applies to a future version of uv. Please refer to |
| 2 | +[README.md](../README.md) for documentation for the latest release.** |
| 3 | + |
| 4 | +Workspaces help you organize large codebases by splitting them into multiple packages with |
| 5 | +independent dependencies. |
| 6 | + |
| 7 | +When using the `uv pip` interface, workspace dependencies behave like automatic editable path |
| 8 | +dependencies. Using the `uv` interface, all your workspace packages are locked together. `uv run` |
| 9 | +installs only the current package (unless overridden with `--package`) and its workspace and |
| 10 | +non-workspace dependencies. |
| 11 | + |
| 12 | +## Configuration |
| 13 | + |
| 14 | +You can create a workspace by adding a `tool.uv.workspace` to a pyproject.toml that is the workspace |
| 15 | +root. This table contains `members` (mandatory) and `exclude` (optional), with lists of globs of |
| 16 | +directories: |
| 17 | + |
| 18 | +```toml |
| 19 | +[tool.uv.workspace] |
| 20 | +members = ["packages/*", "examples/*"] |
| 21 | +exclude = ["example/excluded_example"] |
| 22 | +``` |
| 23 | + |
| 24 | +If you define `tool.uv.sources` in your workspace root, it applies to all packages, unless |
| 25 | +overridden in the `tool.uv.sources` of a specific project. |
| 26 | + |
| 27 | +## Common usage |
| 28 | + |
| 29 | +There a two main usage patterns: A root package and helpers, and the flat workspace. The root |
| 30 | +workspace layout defines one main package in the root of the repository, with helper packages in |
| 31 | +`packages`. In the flat layout, all packages are in the `packages` directory, and the root |
| 32 | +`pyproject.toml` defines a so-called virtual workspace. |
| 33 | + |
| 34 | +Root package and helpers: In this layout `albatross/pyproject.toml` has both a `project` section and |
| 35 | +a `tool.uv.workspace` section. |
| 36 | + |
| 37 | +``` |
| 38 | +albatross |
| 39 | +├── packages |
| 40 | +│ ├── provider_a |
| 41 | +│ │ ├── pyproject.toml |
| 42 | +│ │ └── src |
| 43 | +│ │ └── provider_a |
| 44 | +│ │ ├── __init__.py |
| 45 | +│ │ └── foo.py |
| 46 | +│ └── provider_b |
| 47 | +│ ├── pyproject.toml |
| 48 | +│ └── src |
| 49 | +│ └── provider_b |
| 50 | +│ ├── __init__.py |
| 51 | +│ └── bar.py |
| 52 | +├── pyproject.toml |
| 53 | +├── README.md |
| 54 | +├── uv.lock |
| 55 | +└── src |
| 56 | + └── albatross |
| 57 | + └── main.py |
| 58 | +``` |
| 59 | + |
| 60 | +Flat workspace: In this layout `albatross/pyproject.toml` has only a `tool.uv.workspace` section, |
| 61 | +but no `project`. |
| 62 | + |
| 63 | +``` |
| 64 | +albatross |
| 65 | +├── packages |
| 66 | +│ ├── albatross |
| 67 | +│ │ ├── pyproject.toml |
| 68 | +│ │ └── src |
| 69 | +│ │ └── albatross |
| 70 | +│ │ ├── __init__.py |
| 71 | +│ │ └── foo.py |
| 72 | +│ ├── provider_a |
| 73 | +│ │ ├── pyproject.toml |
| 74 | +│ │ └── src |
| 75 | +│ │ └── provider_a |
| 76 | +│ │ ├── __init__.py |
| 77 | +│ │ └── foo.py |
| 78 | +│ └── provider_b |
| 79 | +│ ├── pyproject.toml |
| 80 | +│ └── src |
| 81 | +│ └── provider_b |
| 82 | +│ ├── __init__.py |
| 83 | +│ └── bar.py |
| 84 | +├── pyproject.toml |
| 85 | +├── README.md |
| 86 | +└── uv.lock |
| 87 | +``` |
0 commit comments