mirror of
https://github.com/astral-sh/uv.git
synced 2025-08-04 19:08:04 +00:00
Build backend: Support data files (#9197)
Allow including data files in wheels, configured through `pyproject.toml`. This configuration is currently only read in the build backend. We'd only start using it in the frontend when we're adding a fast path. Each data entry is a directory, whose contents are copied to the matching directory in the wheel in `<name>-<version>.data/(purelib|platlib|headers|scripts|data)`. Upon installation, this data is moved to its target location, as defined by <https://docs.python.org/3.12/library/sysconfig.html#installation-paths>: - `data`: Installed over the virtualenv environment root. Warning: This may override existing files! - `scripts`: Installed to the directory for executables, `<venv>/bin` on Unix or `<venv>\Scripts` on Windows. This directory is added to PATH when the virtual environment is activated or when using `uv run`, so this data type can be used to install additional binaries. Consider using `project.scripts` instead for starting Python code. - `headers`: Installed to the include directory, where compilers building Python packages with this package as built requirement will search for header files. - `purelib` and `platlib`: Installed to the `site-packages` directory. It is not recommended to uses these two options. For simplicity, for now we're just defining a directory to be copied for each data directory, while using the glob based include mechanism in the background. We thereby introduce a third mechanism next to the main includes and the PEP 639 mechanism, which is not what we should finalize on.
This commit is contained in:
parent
4f6db1d8f9
commit
9460398371
10 changed files with 294 additions and 125 deletions
10
scripts/packages/built-by-uv/assets/data.csv
Normal file
10
scripts/packages/built-by-uv/assets/data.csv
Normal file
|
@ -0,0 +1,10 @@
|
|||
sepal_length,sepal_width,petal_length,petal_width,species
|
||||
5.1,3.5,1.4,0.2,setosa
|
||||
4.9,3.0,1.4,0.2,setosa
|
||||
4.7,3.2,1.3,0.2,setosa
|
||||
4.6,3.1,1.5,0.2,setosa
|
||||
5.0,3.6,1.4,0.2,setosa
|
||||
5.4,3.9,1.7,0.4,setosa
|
||||
4.6,3.4,1.4,0.3,setosa
|
||||
5.0,3.4,1.5,0.2,setosa
|
||||
4.4,2.9,1.4,0.2,setosa
|
|
8
scripts/packages/built-by-uv/header/built_by_uv.h
Normal file
8
scripts/packages/built-by-uv/header/built_by_uv.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef BUILT_BY_UV_H
|
||||
#define BUILT_BY_UV_H
|
||||
|
||||
static inline const char* hello_world() {
|
||||
return "Hello World!";
|
||||
}
|
||||
|
||||
#endif /* HELLO_WORLD_H */
|
|
@ -7,6 +7,11 @@ requires-python = ">=3.12"
|
|||
dependencies = ["anyio>=4,<5"]
|
||||
license-files = ["LICENSE*", "third-party-licenses/*"]
|
||||
|
||||
[tool.uv.wheel.data]
|
||||
scripts = "scripts"
|
||||
data = "assets"
|
||||
headers = "header"
|
||||
|
||||
[build-system]
|
||||
requires = ["uv>=0.4.15,<5"]
|
||||
build-backend = "uv"
|
||||
|
|
3
scripts/packages/built-by-uv/scripts/whoami.sh
Executable file
3
scripts/packages/built-by-uv/scripts/whoami.sh
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
|
||||
whoami
|
Loading…
Add table
Add a link
Reference in a new issue