mirror of
https://github.com/astral-sh/uv.git
synced 2025-07-07 13:25:00 +00:00
Ignore invalid build backend settings when not building (#14372)
Fixes #14323
This commit is contained in:
parent
ae500c95d2
commit
0372a5b05d
2 changed files with 80 additions and 1 deletions
|
@ -24,6 +24,7 @@ use uv_fs::{PortablePathBuf, relative_to};
|
|||
use uv_git_types::GitReference;
|
||||
use uv_macros::OptionsMetadata;
|
||||
use uv_normalize::{DefaultGroups, ExtraName, GroupName, PackageName};
|
||||
use uv_options_metadata::{OptionSet, OptionsMetadata, Visit};
|
||||
use uv_pep440::{Version, VersionSpecifiers};
|
||||
use uv_pep508::MarkerTree;
|
||||
use uv_pypi_types::{
|
||||
|
@ -610,7 +611,7 @@ pub struct ToolUv {
|
|||
/// Note that those settings only apply when using the `uv_build` backend, other build backends
|
||||
/// (such as hatchling) have their own configuration.
|
||||
#[option_group]
|
||||
pub build_backend: Option<BuildBackendSettings>,
|
||||
pub build_backend: Option<BuildBackendSettingsSchema>,
|
||||
}
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Eq)]
|
||||
|
@ -1684,3 +1685,44 @@ pub enum DependencyType {
|
|||
/// A dependency in `dependency-groups.{0}`.
|
||||
Group(GroupName),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(test, derive(Serialize))]
|
||||
pub struct BuildBackendSettingsSchema;
|
||||
|
||||
impl<'de> Deserialize<'de> for BuildBackendSettingsSchema {
|
||||
fn deserialize<D>(_deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
Ok(BuildBackendSettingsSchema)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "schemars")]
|
||||
impl schemars::JsonSchema for BuildBackendSettingsSchema {
|
||||
fn schema_name() -> Cow<'static, str> {
|
||||
BuildBackendSettings::schema_name()
|
||||
}
|
||||
|
||||
fn json_schema(generator: &mut schemars::SchemaGenerator) -> schemars::Schema {
|
||||
BuildBackendSettings::json_schema(generator)
|
||||
}
|
||||
}
|
||||
|
||||
impl OptionsMetadata for BuildBackendSettingsSchema {
|
||||
fn record(visit: &mut dyn Visit) {
|
||||
BuildBackendSettings::record(visit);
|
||||
}
|
||||
|
||||
fn documentation() -> Option<&'static str> {
|
||||
BuildBackendSettings::documentation()
|
||||
}
|
||||
|
||||
fn metadata() -> OptionSet
|
||||
where
|
||||
Self: Sized + 'static,
|
||||
{
|
||||
BuildBackendSettings::metadata()
|
||||
}
|
||||
}
|
||||
|
|
|
@ -858,3 +858,40 @@ fn symlinked_file() -> Result<()> {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Ignore invalid build backend settings when not building.
|
||||
///
|
||||
/// They may be from another `uv_build` version that has a different schema.
|
||||
#[test]
|
||||
fn invalid_build_backend_settings_are_ignored() -> Result<()> {
|
||||
let context = TestContext::new("3.12");
|
||||
|
||||
let pyproject_toml = context.temp_dir.child("pyproject.toml");
|
||||
pyproject_toml.write_str(indoc! {r#"
|
||||
[project]
|
||||
name = "built-by-uv"
|
||||
version = "0.1.0"
|
||||
requires-python = ">=3.12"
|
||||
|
||||
[tool.uv.build-backend]
|
||||
# Error: `source-include` must be a list
|
||||
source-include = "data/build-script.py"
|
||||
|
||||
[build-system]
|
||||
requires = ["uv_build>=10000,<10001"]
|
||||
build-backend = "uv_build"
|
||||
"#})?;
|
||||
|
||||
// Since we are not building, this must pass without complaining about the error in
|
||||
// `tool.uv.build-backend`.
|
||||
uv_snapshot!(context.filters(), context.lock(), @r"
|
||||
success: true
|
||||
exit_code: 0
|
||||
----- stdout -----
|
||||
|
||||
----- stderr -----
|
||||
Resolved 1 package in [TIME]
|
||||
");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue