Add tool.uv.build-constraint-dependencies to pyproject.toml (#11585)
## Summary Resolves #6913. Add `tool.uv.build-constraint-dependencies` to pyproject.toml. The changes are analogous to the constraint-dependencies feature implemented in #5248. Add documentation for `build-constraint-dependencies` ## Test Plan Add tests for `uv lock`, `uv add`, `uv pip install` and `uv pip compile`. --------- Co-authored-by: Charlie Marsh <charlie.r.marsh@gmail.com>
This commit is contained in:
@@ -1,4 +1,35 @@
|
||||
## Project metadata
|
||||
### [`build-constraint-dependencies`](#build-constraint-dependencies) {: #build-constraint-dependencies }
|
||||
|
||||
Constraints to apply when solving build dependencies.
|
||||
|
||||
Build constraints are used to restrict the versions of build dependencies that are selected
|
||||
when building a package during resolution or installation.
|
||||
|
||||
Including a package as a constraint will _not_ trigger installation of the package during
|
||||
a build; instead, the package must be requested elsewhere in the project's build dependency
|
||||
graph.
|
||||
|
||||
!!! note
|
||||
In `uv lock`, `uv sync`, and `uv run`, uv will only read `build-constraint-dependencies` from
|
||||
the `pyproject.toml` at the workspace root, and will ignore any declarations in other
|
||||
workspace members or `uv.toml` files.
|
||||
|
||||
**Default value**: `[]`
|
||||
|
||||
**Type**: `list[str]`
|
||||
|
||||
**Example usage**:
|
||||
|
||||
```toml title="pyproject.toml"
|
||||
[tool.uv]
|
||||
# Ensure that the setuptools v60.0.0 is used whenever a package has a build dependency
|
||||
# on setuptools.
|
||||
build-constraint-dependencies = ["setuptools==60.0.0"]
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
### [`conflicts`](#conflicts) {: #conflicts }
|
||||
|
||||
Declare collections of extras or dependency groups that are conflicting
|
||||
|
||||
@@ -288,6 +288,28 @@ uv will avoid using an old version of `apache-beam`.
|
||||
Constraints can also be defined for indirect dependencies using `constraints.txt` files or the
|
||||
[`constraint-dependencies`](../settings.md#constraint-dependencies) setting.
|
||||
|
||||
### Old Version of a build dependency is used
|
||||
|
||||
If a package fails to build because `uv` selects an incompatible or outdated version of a build-time
|
||||
dependency, you can enforce constraints specifically for build dependencies. The
|
||||
[`build-constraint-dependencies`](../settings.md#build-constraint-dependencies) setting (or an
|
||||
analogous `build-constraints.txt` file) can be used to ensure that `uv` selects an appropriate
|
||||
version of a given build requirements.
|
||||
|
||||
For example, the issue described in
|
||||
[#5551](https://github.com/astral-sh/uv/issues/5551#issuecomment-2256055975) could be addressed by
|
||||
specifying a build constraint that excludes `setuptools` version `72.0.0`:
|
||||
|
||||
```toml title="pyproject.toml"
|
||||
[tool.uv]
|
||||
# Prevent setuptools version 72.0.0 from being used as a build dependency.
|
||||
build-constraint-dependencies = ["setuptools!=72.0.0"]
|
||||
```
|
||||
|
||||
The build constraint will thus ensure that any package requiring `setuptools` during the build
|
||||
process will avoid using the problematic version, preventing build failures caused by incompatible
|
||||
build dependencies.
|
||||
|
||||
### Package is only needed for an unused platform
|
||||
|
||||
If locking fails due to building a package from a platform you do not need to support, consider
|
||||
|
||||
Reference in New Issue
Block a user