-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Build backend: Make preview default and add configuration docs #12804
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
a7300ab
Make uv the preview default
konstin d5e42d3
uv build backend docs
konstin 7192d30
Update docs/configuration/build_backend.md
konstin c07664d
Update docs/configuration/build_backend.md
konstin 2a0ab67
Update docs/configuration/build_backend.md
konstin f5cacf5
Update docs/configuration/build_backend.md
konstin 51b538a
Update docs/configuration/build_backend.md
konstin fc9f2f3
Update docs/configuration/build_backend.md
konstin 96d013f
Update docs/configuration/build_backend.md
konstin 103f623
Update docs/configuration/build_backend.md
konstin 11e8fee
Editing
konstin 8246119
Add admonition about upper bounds
konstin 025cb59
Editing
konstin 9517cb9
Test `--package`
konstin bdc8288
Link build system docs
konstin 2a75f4d
Update pyproject.toml
konstin e4c0f6d
Use relative links
konstin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| # The uv build backend | ||
|
|
||
| !!! note | ||
|
|
||
| The uv build backend is currently in preview and may change without warning. | ||
|
|
||
| When preview mode is not enabled, uv uses [hatchling](https://pypi.org/project/hatchling/) as the default build backend. | ||
|
|
||
| A build backend transforms a source tree (i.e., a directory) into a source distribution or a wheel. | ||
| While uv supports all build backends (as specified by PEP 517), it includes a `uv_build` backend | ||
| that integrates tightly with uv to improve performance and user experience. | ||
|
|
||
| The uv build backend currently only supports Python code. An alternative backend is required if you | ||
| want to create a | ||
| [library with extension modules](../concepts/projects/init.md#projects-with-extension-modules). | ||
|
|
||
| To use the uv build backend as [build system](../concepts/projects/config.md#build-systems) in an | ||
| existing project, add it to the `[build-system]` section in your `pyproject.toml`: | ||
|
|
||
| ```toml | ||
| [build-system] | ||
| requires = ["uv_build>=0.6.13,<0.7"] | ||
| build-backend = "uv_build" | ||
| ``` | ||
|
|
||
| !!! important | ||
|
|
||
| The uv build backend follows the same [versioning policy](../reference/policies/versioning.md), | ||
| setting an upper bound on the `uv_build` version ensures that the package continues to build in | ||
| the future. | ||
|
|
||
| You can also create a new project that uses the uv build backend with `uv init`: | ||
|
|
||
| ```shell | ||
| uv init --build-backend uv | ||
| ``` | ||
|
|
||
| `uv_build` is a separate package from uv, optimized for portability and small binary size. The `uv` | ||
| command includes a copy of the build backend, so when running `uv build`, the same version will be | ||
| used for the build backend as for the uv process. Other build frontends, such as `python -m build`, | ||
| will choose the latest compatible `uv_build` version. | ||
|
|
||
| ## Include and exclude configuration | ||
|
|
||
| To select which files to include in the source distribution, uv first adds the included files and | ||
| directories, then removes the excluded files and directories. This means that exclusions always take | ||
| precedence over inclusions. | ||
|
|
||
| When building the source distribution, the following files and directories are included: | ||
|
|
||
| - `pyproject.toml` | ||
| - The module under `tool.uv.build-backend.module-root`, by default | ||
| `src/<module-name or project_name_with_underscores>/**`. | ||
| - `project.license-files` and `project.readme`. | ||
| - All directories under `tool.uv.build-backend.data`. | ||
| - All patterns from `tool.uv.build-backend.source-include`. | ||
|
|
||
| From these, `tool.uv.build-backend.source-exclude` and the default excludes are removed. | ||
|
|
||
| When building the wheel, the following files and directories are included: | ||
|
|
||
| - The module under `tool.uv.build-backend.module-root`, by default | ||
| `src/<module-name or project_name_with_underscores>/**`. | ||
| - `project.license-files` and `project.readme`, as part of the project metadata. | ||
| - Each directory under `tool.uv.build-backend.data`, as data directories. | ||
|
|
||
| From these, `tool.uv.build-backend.source-exclude`, `tool.uv.build-backend.wheel-exclude` and the | ||
| default excludes are removed. The source dist excludes are applied to avoid source tree to wheel | ||
| source builds including more files than source tree to source distribution to wheel build. | ||
|
|
||
| There are no specific wheel includes. There must only be one top level module, and all data files | ||
| must either be under the module root or in the appropriate | ||
| [data directory](../reference/settings.md#build-backend_data). Most packages store small data in the | ||
| module root alongside the source code. | ||
|
|
||
| ## Include and exclude syntax | ||
|
|
||
| Includes are anchored, which means that `pyproject.toml` includes only | ||
| `<project root>/pyproject.toml`. For example, `assets/**/sample.csv` includes all `sample.csv` files | ||
| in `<project root>/assets` or any child directory. To recursively include all files under a | ||
| directory, use a `/**` suffix, e.g. `src/**`. | ||
|
|
||
| !!! note | ||
|
|
||
| For performance and reproducibility, avoid patterns without an anchor such as `**/sample.csv`. | ||
|
|
||
| Excludes are not anchored, which means that `__pycache__` excludes all directories named | ||
| `__pycache__` and its children anywhere. To anchor a directory, use a `/` prefix, e.g., `/dist` will | ||
| exclude only `<project root>/dist`. | ||
|
|
||
| All fields accepting patterns use the reduced portable glob syntax from | ||
| [PEP 639](https://peps.python.org/pep-0639/#add-license-FILES-key). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.