Revert "Fix settings rendering for extra-build-dependencies" (#15228)

Reverts astral-sh/uv#15161
This commit is contained in:
Charlie Marsh 2025-08-12 01:37:12 +01:00 committed by GitHub
parent 9ba1ef1155
commit dacc86ff03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 118 additions and 27 deletions

View file

@ -639,8 +639,9 @@ pub struct ResolverInstallerOptions {
default = "[]", default = "[]",
value_type = "dict", value_type = "dict",
example = r#" example = r#"
extra-build-dependencies = { pytest = ["setuptools"] } [extra-build-dependencies]
"# pytest = ["setuptools"]
"#
)] )]
pub extra_build_dependencies: Option<ExtraBuildDependencies>, pub extra_build_dependencies: Option<ExtraBuildDependencies>,
/// Extra environment variables to set when building certain packages. /// Extra environment variables to set when building certain packages.
@ -651,7 +652,8 @@ pub struct ResolverInstallerOptions {
default = r#"{}"#, default = r#"{}"#,
value_type = r#"dict[str, dict[str, str]]"#, value_type = r#"dict[str, dict[str, str]]"#,
example = r#" example = r#"
extra-build-variables = { flash-attn = { FLASH_ATTENTION_SKIP_CUDA_BUILD = "TRUE" } } [tool.uv.extra-build-variables]
flash-attn = { FLASH_ATTENTION_SKIP_CUDA_BUILD = "TRUE" }
"# "#
)] )]
pub extra_build_variables: Option<ExtraBuildVariables>, pub extra_build_variables: Option<ExtraBuildVariables>,
@ -1176,7 +1178,8 @@ pub struct PipOptions {
default = "[]", default = "[]",
value_type = "dict", value_type = "dict",
example = r#" example = r#"
extra-build-dependencies = { pytest = ["setuptools"] } [extra-build-dependencies]
pytest = ["setuptools"]
"# "#
)] )]
pub extra_build_dependencies: Option<ExtraBuildDependencies>, pub extra_build_dependencies: Option<ExtraBuildDependencies>,
@ -1188,7 +1191,8 @@ pub struct PipOptions {
default = r#"{}"#, default = r#"{}"#,
value_type = r#"dict[str, dict[str, str]]"#, value_type = r#"dict[str, dict[str, str]]"#,
example = r#" example = r#"
extra-build-variables = { flash-attn = { FLASH_ATTENTION_SKIP_CUDA_BUILD = "TRUE" } } [extra-build-variables]
flash-attn = { FLASH_ATTENTION_SKIP_CUDA_BUILD = "TRUE" }
"# "#
)] )]
pub extra_build_variables: Option<ExtraBuildVariables>, pub extra_build_variables: Option<ExtraBuildVariables>,

View file

@ -22,7 +22,7 @@ use serde::{Deserialize, Deserializer, Serialize};
use thiserror::Error; use thiserror::Error;
use uv_build_backend::BuildBackendSettings; use uv_build_backend::BuildBackendSettings;
use uv_distribution_types::{Index, IndexName, RequirementSource}; use uv_distribution_types::{ExtraBuildVariables, Index, IndexName, RequirementSource};
use uv_fs::{PortablePathBuf, relative_to}; use uv_fs::{PortablePathBuf, relative_to};
use uv_git_types::GitReference; use uv_git_types::GitReference;
use uv_macros::OptionsMetadata; use uv_macros::OptionsMetadata;
@ -428,6 +428,35 @@ pub struct ToolUv {
)] )]
pub dependency_groups: Option<ToolUvDependencyGroups>, pub dependency_groups: Option<ToolUvDependencyGroups>,
/// Additional build dependencies for packages.
///
/// This allows extending the PEP 517 build environment for the project's dependencies with
/// additional packages. This is useful for packages that assume the presence of packages, like,
/// `pip`, and do not declare them as build dependencies.
#[option(
default = "[]",
value_type = "dict",
example = r#"
[tool.uv.extra-build-dependencies]
pytest = ["pip"]
"#
)]
pub extra_build_dependencies: Option<ExtraBuildDependencies>,
/// Extra environment variables to set when building certain packages.
///
/// Environment variables will be added to the environment when building the
/// specified packages.
#[option(
default = r#"{}"#,
value_type = r#"dict[str, dict[str, str]]"#,
example = r#"
[tool.uv.extra-build-variables]
flash-attn = { FLASH_ATTENTION_SKIP_CUDA_BUILD = "TRUE" }
"#
)]
pub extra_build_variables: Option<ExtraBuildVariables>,
/// The project's development dependencies. /// The project's development dependencies.
/// ///
/// Development dependencies will be installed by default in `uv run` and `uv sync`, but will /// Development dependencies will be installed by default in `uv run` and `uv sync`, but will

View file

@ -1970,6 +1970,8 @@ mod tests {
"package": null, "package": null,
"default-groups": null, "default-groups": null,
"dependency-groups": null, "dependency-groups": null,
"extra-build-dependencies": null,
"extra-build-variables": null,
"dev-dependencies": null, "dev-dependencies": null,
"override-dependencies": null, "override-dependencies": null,
"constraint-dependencies": null, "constraint-dependencies": null,
@ -2070,6 +2072,8 @@ mod tests {
"package": null, "package": null,
"default-groups": null, "default-groups": null,
"dependency-groups": null, "dependency-groups": null,
"extra-build-dependencies": null,
"extra-build-variables": null,
"dev-dependencies": null, "dev-dependencies": null,
"override-dependencies": null, "override-dependencies": null,
"constraint-dependencies": null, "constraint-dependencies": null,
@ -2283,6 +2287,8 @@ mod tests {
"package": null, "package": null,
"default-groups": null, "default-groups": null,
"dependency-groups": null, "dependency-groups": null,
"extra-build-dependencies": null,
"extra-build-variables": null,
"dev-dependencies": null, "dev-dependencies": null,
"override-dependencies": null, "override-dependencies": null,
"constraint-dependencies": null, "constraint-dependencies": null,
@ -2392,6 +2398,8 @@ mod tests {
"package": null, "package": null,
"default-groups": null, "default-groups": null,
"dependency-groups": null, "dependency-groups": null,
"extra-build-dependencies": null,
"extra-build-variables": null,
"dev-dependencies": null, "dev-dependencies": null,
"override-dependencies": null, "override-dependencies": null,
"constraint-dependencies": null, "constraint-dependencies": null,
@ -2514,6 +2522,8 @@ mod tests {
"package": null, "package": null,
"default-groups": null, "default-groups": null,
"dependency-groups": null, "dependency-groups": null,
"extra-build-dependencies": null,
"extra-build-variables": null,
"dev-dependencies": null, "dev-dependencies": null,
"override-dependencies": null, "override-dependencies": null,
"constraint-dependencies": null, "constraint-dependencies": null,
@ -2610,6 +2620,8 @@ mod tests {
"package": null, "package": null,
"default-groups": null, "default-groups": null,
"dependency-groups": null, "dependency-groups": null,
"extra-build-dependencies": null,
"extra-build-variables": null,
"dev-dependencies": null, "dev-dependencies": null,
"override-dependencies": null, "override-dependencies": null,
"constraint-dependencies": null, "constraint-dependencies": null,

View file

@ -12745,7 +12745,7 @@ fn sync_build_dependencies_respect_locked_versions() -> Result<()> {
uv_snapshot!(context.filters(), context.sync(), @r#" uv_snapshot!(context.filters(), context.sync(), @r#"
success: false success: false
exit_code: 1 exit_code: 2
----- stdout ----- ----- stdout -----
----- stderr ----- ----- stderr -----
@ -12756,16 +12756,12 @@ fn sync_build_dependencies_respect_locked_versions() -> Result<()> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dependencies marked with `match-runtime = true` cannot include version specifiers Dependencies marked with `match-runtime = true` cannot include version specifiers
Resolved [N] packages in [TIME] error: Failed to parse: `pyproject.toml`
× Failed to build `child @ file://[TEMP_DIR]/child` Caused by: TOML parse error at line 11, column 9
The build backend returned an error |
Call to `build_backend.build_wheel` failed (exit status: 1) 11 | child = [{ requirement = "anyio>4", match-runtime = true }]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[stderr] Dependencies marked with `match-runtime = true` cannot include version specifiers
`EXPECTED_ANYIO_VERSION` not set
hint: This usually indicates a problem with the package or the build environment.
help: `child` was included because `parent` (v0.1.0) depends on `child`
"#); "#);
Ok(()) Ok(())

View file

@ -202,6 +202,49 @@ environments = ["sys_platform == 'darwin'"]
--- ---
### [`extra-build-dependencies`](#extra-build-dependencies) {: #extra-build-dependencies }
Additional build dependencies for packages.
This allows extending the PEP 517 build environment for the project's dependencies with
additional packages. This is useful for packages that assume the presence of packages, like,
`pip`, and do not declare them as build dependencies.
**Default value**: `[]`
**Type**: `dict`
**Example usage**:
```toml title="pyproject.toml"
[tool.uv.extra-build-dependencies]
pytest = ["pip"]
```
---
### [`extra-build-variables`](#extra-build-variables) {: #extra-build-variables }
Extra environment variables to set when building certain packages.
Environment variables will be added to the environment when building the
specified packages.
**Default value**: `{}`
**Type**: `dict[str, dict[str, str]]`
**Example usage**:
```toml title="pyproject.toml"
[tool.uv.extra-build-variables]
flash-attn = { FLASH_ATTENTION_SKIP_CUDA_BUILD = "TRUE" }
```
---
### [`index`](#index) {: #index } ### [`index`](#index) {: #index }
The indexes to use when resolving dependencies. The indexes to use when resolving dependencies.
@ -1145,12 +1188,14 @@ additional packages. This is useful for packages that assume the presence of pac
```toml ```toml
[tool.uv] [tool.uv]
extra-build-dependencies = { pytest = ["setuptools"] } [extra-build-dependencies]
pytest = ["setuptools"]
``` ```
=== "uv.toml" === "uv.toml"
```toml ```toml
extra-build-dependencies = { pytest = ["setuptools"] } [extra-build-dependencies]
pytest = ["setuptools"]
``` ```
--- ---
@ -1171,13 +1216,14 @@ specified packages.
=== "pyproject.toml" === "pyproject.toml"
```toml ```toml
[tool.uv] [tool.uv.extra-build-variables]
extra-build-variables = { flash-attn = { FLASH_ATTENTION_SKIP_CUDA_BUILD = "TRUE" } } flash-attn = { FLASH_ATTENTION_SKIP_CUDA_BUILD = "TRUE" }
``` ```
=== "uv.toml" === "uv.toml"
```toml ```toml
extra-build-variables = { flash-attn = { FLASH_ATTENTION_SKIP_CUDA_BUILD = "TRUE" } } [tool.uv.extra-build-variables]
flash-attn = { FLASH_ATTENTION_SKIP_CUDA_BUILD = "TRUE" }
``` ```
--- ---
@ -2695,13 +2741,15 @@ additional packages. This is useful for packages that assume the presence of pac
```toml ```toml
[tool.uv.pip] [tool.uv.pip]
extra-build-dependencies = { pytest = ["setuptools"] } [extra-build-dependencies]
pytest = ["setuptools"]
``` ```
=== "uv.toml" === "uv.toml"
```toml ```toml
[pip] [pip]
extra-build-dependencies = { pytest = ["setuptools"] } [extra-build-dependencies]
pytest = ["setuptools"]
``` ```
--- ---
@ -2724,13 +2772,15 @@ specified packages.
```toml ```toml
[tool.uv.pip] [tool.uv.pip]
extra-build-variables = { flash-attn = { FLASH_ATTENTION_SKIP_CUDA_BUILD = "TRUE" } } [extra-build-variables]
flash-attn = { FLASH_ATTENTION_SKIP_CUDA_BUILD = "TRUE" }
``` ```
=== "uv.toml" === "uv.toml"
```toml ```toml
[pip] [pip]
extra-build-variables = { flash-attn = { FLASH_ATTENTION_SKIP_CUDA_BUILD = "TRUE" } } [extra-build-variables]
flash-attn = { FLASH_ATTENTION_SKIP_CUDA_BUILD = "TRUE" }
``` ```
--- ---

2
uv.schema.json generated
View file

@ -226,7 +226,7 @@
] ]
}, },
"extra-build-dependencies": { "extra-build-dependencies": {
"description": "Additional build dependencies for packages.\n\nThis allows extending the PEP 517 build environment for the project's dependencies with\nadditional packages. This is useful for packages that assume the presence of packages like\n`pip`, and do not declare them as build dependencies.", "description": "Additional build dependencies for packages.\n\nThis allows extending the PEP 517 build environment for the project's dependencies with\nadditional packages. This is useful for packages that assume the presence of packages, like,\n`pip`, and do not declare them as build dependencies.",
"anyOf": [ "anyOf": [
{ {
"$ref": "#/definitions/ExtraBuildDependencies" "$ref": "#/definitions/ExtraBuildDependencies"