mirror of https://github.com/astral-sh/uv
Update description
This commit is contained in:
parent
ad12ba6907
commit
19756166c1
|
|
@ -310,7 +310,6 @@ impl SourceBuild {
|
|||
&source_tree,
|
||||
install_path,
|
||||
fallback_package_name,
|
||||
fallback_package_version,
|
||||
locations,
|
||||
source_strategy,
|
||||
workspace_cache,
|
||||
|
|
@ -563,7 +562,6 @@ impl SourceBuild {
|
|||
source_tree: &Path,
|
||||
install_path: &Path,
|
||||
package_name: Option<&PackageName>,
|
||||
package_version: Option<&Version>,
|
||||
locations: &IndexLocations,
|
||||
source_strategy: SourceStrategy,
|
||||
workspace_cache: &WorkspaceCache,
|
||||
|
|
@ -593,6 +591,10 @@ impl SourceBuild {
|
|||
Err(err) => return Err(Box::new(err.into())),
|
||||
};
|
||||
|
||||
let build_backend = pyproject_toml
|
||||
.build_system
|
||||
.as_ref()
|
||||
.and_then(|build_backend| build_backend.build_backend.as_deref());
|
||||
if source_strategy == SourceStrategy::Enabled
|
||||
&& pyproject_toml
|
||||
.tool
|
||||
|
|
@ -600,24 +602,24 @@ impl SourceBuild {
|
|||
.and_then(|tool| tool.uv.as_ref())
|
||||
.map(|uv| uv.build_backend.is_some())
|
||||
.unwrap_or(false)
|
||||
&& pyproject_toml
|
||||
.build_system
|
||||
.as_ref()
|
||||
.and_then(|build_backend| build_backend.build_backend.as_deref())
|
||||
!= Some("uv_build")
|
||||
&& build_backend != Some("uv_build")
|
||||
&& let Some(package_name) =
|
||||
package_name.or(pyproject_toml.project.as_ref().map(|project| &project.name))
|
||||
&& let Some(package_version) = package_version.or(pyproject_toml
|
||||
.project
|
||||
.as_ref()
|
||||
.and_then(|project| project.version.as_ref()))
|
||||
{
|
||||
// Show name/version where available to avoid showing a (duplicate) warning with
|
||||
// a temporary path.
|
||||
warn_user_once!(
|
||||
"`pyproject.toml` of {package_name}=={package_version} defines settings for \
|
||||
`uv_build` in `tool.uv.build-backend`, but does not use `uv_build`",
|
||||
);
|
||||
// Show only the name, but not the path to `pyproject.toml`, to avoid showing a
|
||||
// (duplicate) warning that contains the temporary path of an unpacked source
|
||||
// distribution in a source tree -> source dist -> wheel build.
|
||||
if let Some(build_backend) = build_backend {
|
||||
warn_user_once!(
|
||||
"`{package_name}` defines settings for `uv_build` in `tool.uv.build-backend`, \
|
||||
but uses `{build_backend}` as build backend instead",
|
||||
);
|
||||
} else {
|
||||
warn_user_once!(
|
||||
"`{package_name}` defines settings for `uv_build` in `tool.uv.build-backend`, \
|
||||
but the `build-system` table is missing",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
let backend = if let Some(build_system) = pyproject_toml.build_system {
|
||||
|
|
@ -640,7 +642,8 @@ impl SourceBuild {
|
|||
locations,
|
||||
source_strategy,
|
||||
workspace_cache,
|
||||
credentials_cache,)
|
||||
credentials_cache,
|
||||
)
|
||||
.await
|
||||
.map_err(Error::Lowering)?;
|
||||
build_requires.requires_dist
|
||||
|
|
|
|||
|
|
@ -1249,7 +1249,7 @@ fn tool_uv_build_backend_without_build_backend() -> Result<()> {
|
|||
|
||||
----- stderr -----
|
||||
Building source distribution...
|
||||
warning: `pyproject.toml` of project==0.1.0 defines settings for `uv_build` in `tool.uv.build-backend`, but does not use `uv_build`
|
||||
warning: `project` defines settings for `uv_build` in `tool.uv.build-backend`, but the `build-system` table is missing
|
||||
Building wheel from source distribution...
|
||||
Successfully built dist/project-0.1.0.tar.gz
|
||||
Successfully built dist/project-0.1.0-py3-none-any.whl
|
||||
|
|
@ -1262,7 +1262,7 @@ fn tool_uv_build_backend_without_build_backend() -> Result<()> {
|
|||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
warning: `pyproject.toml` of project==0.1.0 defines settings for `uv_build` in `tool.uv.build-backend`, but does not use `uv_build`
|
||||
warning: `project` defines settings for `uv_build` in `tool.uv.build-backend`, but the `build-system` table is missing
|
||||
Prepared 1 package in [TIME]
|
||||
Installed 1 package in [TIME]
|
||||
+ project==0.1.0 (from file://[TEMP_DIR]/)
|
||||
|
|
@ -1270,3 +1270,57 @@ fn tool_uv_build_backend_without_build_backend() -> Result<()> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Warn for cases where `tool.uv.build-backend` is used without the corresponding build backend
|
||||
/// entry.
|
||||
#[test]
|
||||
fn tool_uv_build_backend_wrong_build_backend() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
|
||||
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]
|
||||
package = true
|
||||
|
||||
[tool.uv.build-backend.data]
|
||||
data = "assets"
|
||||
|
||||
[build-system]
|
||||
requires = ["hatchling"]
|
||||
build-backend = "hatchling.build"
|
||||
"#})?;
|
||||
project.child("src/project/__init__.py").touch()?;
|
||||
|
||||
uv_snapshot!(context.filters(), context.build().arg("--no-build-logs").arg(project.path()), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Building source distribution...
|
||||
warning: `project` defines settings for `uv_build` in `tool.uv.build-backend`, but uses `hatchling.build` as build backend instead
|
||||
Building wheel from source distribution...
|
||||
Successfully built project/dist/project-0.1.0.tar.gz
|
||||
Successfully built project/dist/project-0.1.0-py2.py3-none-any.whl
|
||||
");
|
||||
|
||||
uv_snapshot!(context.filters(), context.pip_install().arg(project.path()), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
warning: `project` defines settings for `uv_build` in `tool.uv.build-backend`, but uses `hatchling.build` as build backend instead
|
||||
Prepared 1 package in [TIME]
|
||||
Installed 1 package in [TIME]
|
||||
+ project==0.1.0 (from file://[TEMP_DIR]/project)
|
||||
");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue