Skip to content

Commit

Permalink
Use uv-build consistently
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Feb 12, 2025
1 parent d856945 commit 6123fe0
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 26 deletions.
8 changes: 4 additions & 4 deletions crates/uv-build-backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ mod tests {
license = { file = "license.txt" }
[build-system]
requires = ["uv>=0.5.15,<0.6"]
build-backend = "uv"
requires = ["uv-build>=0.5.15,<0.6"]
build-backend = "uv_build"
"#
},
)
Expand Down Expand Up @@ -471,8 +471,8 @@ mod tests {
version = "1.0.0"
[build-system]
requires = ["uv>=0.5.15,<0.6"]
build-backend = "uv"
requires = ["uv-build>=0.5.15,<0.6"]
build-backend = "uv_build"
"#
},
)
Expand Down
37 changes: 20 additions & 17 deletions crates/uv-build-backend/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,14 +161,17 @@ impl PyProjectToml {
///
/// ```toml
/// [build-system]
/// requires = ["uv>=0.4.15,<5"]
/// build-backend = "uv"
/// requires = ["uv-build>=0.4.15,<5"]
/// build-backend = "uv_build"
/// ```
pub fn check_build_system(&self, uv_version: &str) -> Vec<String> {
let mut warnings = Vec::new();
if self.build_system.build_backend.as_deref() != Some("uv") {
if !matches!(
self.build_system.build_backend.as_deref(),
Some("uv" | "uv_build")
) {
warnings.push(format!(
r#"The value for `build_system.build-backend` should be `"uv"`, not `"{}"`"#,
r#"The value for `build_system.build-backend` should be `"uv_build"` or `"uv"`, not `"{}"`"#,
self.build_system.build_backend.clone().unwrap_or_default()
));
}
Expand All @@ -189,7 +192,7 @@ impl PyProjectToml {
warnings.push(expected());
return warnings;
};
if uv_requirement.name.as_str() != "uv" {
if uv_requirement.name.as_str() != "uv" && uv_requirement.name.as_str() != "uv-build" {
warnings.push(expected());
return warnings;
}
Expand Down Expand Up @@ -940,8 +943,8 @@ mod tests {
{payload}
[build-system]
requires = ["uv>=0.4.15,<5"]
build-backend = "uv"
requires = ["uv-build>=0.4.15,<5"]
build-backend = "uv_build"
"#
}
}
Expand Down Expand Up @@ -1023,8 +1026,8 @@ mod tests {
foo-bar = "foo:bar"
[build-system]
requires = ["uv>=0.4.15,<5"]
build-backend = "uv"
requires = ["uv-build>=0.4.15,<5"]
build-backend = "uv_build"
"#
};

Expand Down Expand Up @@ -1150,8 +1153,8 @@ mod tests {
foo-bar = "foo:bar"
[build-system]
requires = ["uv>=0.4.15,<5"]
build-backend = "uv"
requires = ["uv-build>=0.4.15,<5"]
build-backend = "uv_build"
"#
};

Expand Down Expand Up @@ -1232,7 +1235,7 @@ mod tests {
[build-system]
requires = ["uv"]
build-backend = "uv"
build-backend = "uv_build"
"#};
let pyproject_toml = PyProjectToml::parse(contents).unwrap();
assert_snapshot!(
Expand All @@ -1249,8 +1252,8 @@ mod tests {
version = "0.1.0"
[build-system]
requires = ["uv>=0.4.15,<5", "wheel"]
build-backend = "uv"
requires = ["uv-build>=0.4.15,<5", "wheel"]
build-backend = "uv_build"
"#};
let pyproject_toml = PyProjectToml::parse(contents).unwrap();
assert_snapshot!(
Expand All @@ -1268,7 +1271,7 @@ mod tests {
[build-system]
requires = ["setuptools"]
build-backend = "uv"
build-backend = "uv_build"
"#};
let pyproject_toml = PyProjectToml::parse(contents).unwrap();
assert_snapshot!(
Expand All @@ -1285,13 +1288,13 @@ mod tests {
version = "0.1.0"
[build-system]
requires = ["uv>=0.4.15,<5"]
requires = ["uv-build>=0.4.15,<5"]
build-backend = "setuptools"
"#};
let pyproject_toml = PyProjectToml::parse(contents).unwrap();
assert_snapshot!(
pyproject_toml.check_build_system("0.4.15+test").join("\n"),
@r###"The value for `build_system.build-backend` should be `"uv"`, not `"setuptools"`"###
@r###"The value for `build_system.build-backend` should be `"uv_build"` or `"uv"`, not `"setuptools"`"###
);
}

Expand Down
4 changes: 2 additions & 2 deletions crates/uv/src/commands/project/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,8 +942,8 @@ fn pyproject_build_system(package: &PackageName, build_backend: ProjectBuildBack
let max_version = Version::new([0, min_version.release()[1] + 1]);
indoc::formatdoc! {r#"
[build-system]
requires = ["uv>={min_version},<{max_version}"]
build-backend = "uv"
requires = ["uv-build>={min_version},<{max_version}"]
build-backend = "uv_build"
"#}
}
.to_string(),
Expand Down
6 changes: 3 additions & 3 deletions crates/uv/tests/it/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3465,7 +3465,7 @@ fn init_application_package_uv() -> Result<()> {

let pyproject = fs_err::read_to_string(&pyproject_toml)?;
let mut filters = context.filters();
filters.push((r#"\["uv>=.*,<.*"\]"#, r#"["uv[SPECIFIERS]"]"#));
filters.push((r#"\["uv-build>=.*,<.*"\]"#, r#"["uv-build[SPECIFIERS]"]"#));
insta::with_settings!({
filters => filters,
}, {
Expand All @@ -3483,8 +3483,8 @@ fn init_application_package_uv() -> Result<()> {
foo = "foo:main"
[build-system]
requires = ["uv[SPECIFIERS]"]
build-backend = "uv"
requires = ["uv-build[SPECIFIERS]"]
build-backend = "uv_build"
"###
);
});
Expand Down

0 comments on commit 6123fe0

Please sign in to comment.