Build backend: Support stubs packages (#13563)

Stubs packages are different in that their name ends with `-stubs`,
their module is `<module name>-stubs` (with a dash, not the generally
legal underscore) and their modules contain a `__init__.pyi` instead of
an `__init__.py`
(https://typing.python.org/en/latest/spec/distributing.html#stub-only-packages).

We add support in the uv build backend by detecting the `-stubs` suffix.

Fixes #13546

---------

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
This commit is contained in:
konsti 2025-05-22 19:02:17 +02:00 committed by GitHub
parent c8479574f2
commit 46bc7d3477
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 240 additions and 22 deletions

View file

@ -54,6 +54,8 @@ module-name = "PIL"
module-root = ""
```
The build backend supports building stubs packages with a `-stubs` package or module name.
## Include and exclude configuration
To select which files to include in the source distribution, uv first adds the included files and

View file

@ -446,6 +446,10 @@ The name of the module directory inside `module-root`.
The default module name is the package name with dots and dashes replaced by underscores.
Package names need to be valid Python identifiers, and the directory needs to contain a
`__init__.py`. An exception are stubs packages, whose name ends with `-stubs`, with the stem
being the module name, and which contain a `__init__.pyi` file.
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.