mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Build backend: Revamp include/exclude (#9525)
When building the source distribution, we always need to include `pyproject.toml` and the module, when building the wheel, we always include the module but nothing else at top level. Since we only allow a single module per wheel, that means that there are no specific wheel includes. This means we have source includes, source excludes, wheel excludes, but no wheel includes: This is defined by the module root, plus the metadata files and data directories separately. Extra source dist includes are currently unused (they can't end up in the wheel currently), but it makes sense to model them here, they will be needed for any sort of procedural build step. This results in the following fields being relevant for inclusions and exclusion: * `pyproject.toml` (always included in the source dist) * project.readme: PEP 621 * project.license-files: PEP 639 * module_root: `Path` * source_include: `Vec<Glob>` * source_exclude: `Vec<Glob>` * wheel_exclude: `Vec<Glob>` * data: `Map<KnownDataName, Path>` An opinionated choice is that that wheel excludes always contain the source excludes: Otherwise you could have a path A in the source tree that gets included when building the wheel directly from the source tree, but not when going through the source dist as intermediary, because A is in source excludes, but not in the wheel excludes. This has been a source of errors previously. In the process, I fixed a bug where we would skip directories and only include the files and were missing license due to absolute globs.
This commit is contained in:
parent
8126a5ed32
commit
dfcceb6a1d
11 changed files with 272 additions and 209 deletions
1
scripts/packages/built-by-uv/data-dir/build-script.py
Normal file
1
scripts/packages/built-by-uv/data-dir/build-script.py
Normal file
|
@ -0,0 +1 @@
|
|||
print("Build script (currently unused)")
|
|
@ -7,7 +7,15 @@ requires-python = ">=3.12"
|
|||
dependencies = ["anyio>=4,<5"]
|
||||
license-files = ["LICENSE*", "third-party-licenses/*"]
|
||||
|
||||
[tool.uv.wheel.data]
|
||||
[tool.uv.build-backend]
|
||||
# A file we need for the source dist -> wheel step, but not in the wheel itself (currently unused)
|
||||
source-include = ["data/build-script.py"]
|
||||
# A temporary or generated file we want to ignore
|
||||
source-exclude = ["/src/built_by_uv/not-packaged.txt", "__pycache__", "*.pyc", "*.pyo"]
|
||||
# Headers are build-only
|
||||
wheel-exclude = ["build-*.h"]
|
||||
|
||||
[tool.uv.build-backend.data]
|
||||
scripts = "scripts"
|
||||
data = "assets"
|
||||
headers = "header"
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
// There is no build step yet, but we're already modelling the basis for it by allowing files only in the source dist,
|
||||
// but not in the wheel.
|
||||
|
||||
#include <pybind11/pybind11.h>
|
|
@ -0,0 +1 @@
|
|||
This file should only exist locally.
|
Loading…
Add table
Add a link
Reference in a new issue