Multiple modules in namespace packages (#14460)

Support multiple root modules in namespace packages by enumerating them:

```toml
[tool.uv.build-backend]
module-name = ["foo", "bar"]
```

This allows applications with multiple root packages without migrating
to workspaces. Since those are regular module names (we iterate over
them an process each one like a single module names), it allows
combining dotted (namespace) names and regular names. It also
technically allows combining regular and stub modules, even though this
is even less recommends.

We don't recommend this structure (please use a workspace instead, or
structure everything in one root module), but it reduces the number of
cases that need `namespace = true`.

Fixes #14435
Fixes #14438

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
This commit is contained in:
konsti
2025-07-09 19:45:44 +02:00
committed by GitHub
parent 812a3e7c34
commit e798b09aa4
9 changed files with 310 additions and 86 deletions
+5 -1
View File
@@ -474,13 +474,17 @@ being the module name, and which contain a `__init__.pyi` file.
For namespace packages with a single module, the path can be dotted, e.g., `foo.bar` or
`foo-stubs.bar`.
For namespace packages with multiple modules, the path can be a list, e.g.,
`["foo", "bar"]`. We recommend using a single module per package, splitting multiple
packages into a workspace.
Note that using this option runs the risk of creating two packages with different names but
the same module names. Installing such packages together leads to unspecified behavior,
often with corrupted files or directory trees.
**Default value**: `None`
**Type**: `str`
**Type**: `str | list[str]`
**Example usage**: