diff --git a/crates/uv-build-frontend/src/lib.rs b/crates/uv-build-frontend/src/lib.rs index 3758dced9e210..a5805124efd40 100644 --- a/crates/uv-build-frontend/src/lib.rs +++ b/crates/uv-build-frontend/src/lib.rs @@ -611,11 +611,12 @@ impl SourceBuild { .as_ref() .and_then(|build_system| build_system.build_backend.as_deref()); - if let Some(backend_path) = pyproject_toml + let backend_path = pyproject_toml .build_system .as_ref() - .and_then(|build_system| build_system.backend_path.as_ref()) - { + .and_then(|build_system| build_system.backend_path.as_ref()); + + if let Some(backend_path) = backend_path { let source_tree = fs_err::canonicalize(source_tree).map_err(Error::Io)?; for path in backend_path.iter() { if Path::new(path).is_absolute() { @@ -639,8 +640,10 @@ impl SourceBuild { } // Only show the warning for first party and URL dependencies, not for registry dependencies - // (which have sources disabled). + // (which have sources disabled). In-tree build backends may wrap `uv_build`, so we don't + // warn for them either. if !no_sources.all() + && backend_path.is_none() && pyproject_toml .tool .as_ref() diff --git a/crates/uv/tests/build/build_backend.rs b/crates/uv/tests/build/build_backend.rs index 6cb1b6059b6fd..202a0243c0894 100644 --- a/crates/uv/tests/build/build_backend.rs +++ b/crates/uv/tests/build/build_backend.rs @@ -1764,6 +1764,51 @@ fn tool_uv_build_backend_wrong_build_backend() -> Result<()> { Ok(()) } +/// Don't warn about uv build backend setting when an in-tree build backend, it might be wrapping +/// `uv_build`. +/// +/// See . +#[test] +#[cfg(feature = "test-pypi")] +fn tool_uv_build_backend_in_tree_backend() -> Result<()> { + // We need to use a real `uv_build` package. + let context = uv_test::test_context!("3.12").with_exclude_newer("2025-05-27T00:00:00Z"); + + let project = context.temp_dir.child("project"); + let pyproject_toml = project.child("pyproject.toml"); + pyproject_toml.write_str(indoc! {r#" + [project] + name = "project" + version = "0.1.0" + + [tool.uv.build-backend] + source-include = ["backend/**"] + + [build-system] + requires = ["uv_build>=0.7,<10000"] + build-backend = "backend" + backend-path = ["."] + "#})?; + project.child("src/project/__init__.py").touch()?; + project + .child("backend/__init__.py") + .write_str("from uv_build import *\n")?; + + uv_snapshot!(context.filters(), context.build().arg("--no-build-logs").arg(project.path()), @" + success: true + exit_code: 0 + ----- stdout ----- + + ----- stderr ----- + Building source distribution... + Building wheel from source distribution... + Successfully built project/dist/project-0.1.0.tar.gz + Successfully built project/dist/project-0.1.0-py3-none-any.whl + "); + + Ok(()) +} + /// Show a warning when the project uses deprecated `License ::` classifiers. #[test] fn warn_on_license_classifier() -> Result<()> {