Skip to content

Commit 780655a

Browse files
authored
fix: deprecate [build-dependencies] and [host-dependencies] (#4767)
1 parent d71d19c commit 780655a

File tree

2 files changed

+170
-4
lines changed

2 files changed

+170
-4
lines changed

crates/pixi_manifest/src/toml/feature.rs

Lines changed: 88 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use crate::{
1515
task::TomlTask,
1616
},
1717
utils::{PixiSpanned, package_map::UniquePackageMap},
18+
warning::Deprecation,
1819
workspace::ChannelPriority,
1920
};
2021
use pixi_pypi_spec::{PixiPypiSpec, PypiPackageName};
@@ -137,8 +138,33 @@ impl<'de> toml_span::Deserialize<'de> for TomlFeature {
137138
.map(TomlIndexMap::into_inner)
138139
.unwrap_or_default();
139140
let dependencies = th.optional("dependencies");
140-
let host_dependencies = th.optional("host-dependencies");
141-
let build_dependencies = th.optional("build-dependencies");
141+
let host_dependencies: Option<Spanned<UniquePackageMap>> = th.optional("host-dependencies");
142+
if let Some(host_dependencies) = &host_dependencies {
143+
warnings.push(
144+
Deprecation::renamed_field(
145+
"host-dependencies",
146+
"dependencies",
147+
host_dependencies.span,
148+
)
149+
.into(),
150+
);
151+
}
152+
let host_dependencies = host_dependencies.map(From::from);
153+
154+
let build_dependencies: Option<Spanned<UniquePackageMap>> =
155+
th.optional("build-dependencies");
156+
if let Some(build_dependencies) = &build_dependencies {
157+
warnings.push(
158+
Deprecation::renamed_field(
159+
"build-dependencies",
160+
"dependencies",
161+
build_dependencies.span,
162+
)
163+
.into(),
164+
);
165+
}
166+
let build_dependencies = build_dependencies.map(From::from);
167+
142168
let pypi_dependencies = th
143169
.optional::<TomlIndexMap<_, _>>("pypi-dependencies")
144170
.map(TomlIndexMap::into_inner);
@@ -216,4 +242,64 @@ mod test {
216242
"#,
217243
));
218244
}
245+
246+
#[test]
247+
fn test_host_dependencies_deprecation_warning() {
248+
assert_snapshot!(
249+
expect_parse_warnings(
250+
r#"
251+
[workspace]
252+
name = "test"
253+
channels = []
254+
platforms = ['linux-64']
255+
256+
[feature.foo.host-dependencies]
257+
foo = "*"
258+
259+
[environments]
260+
dev = ["foo"]
261+
"#,
262+
),
263+
@r#"
264+
⚠ The `host-dependencies` field is deprecated. Use `dependencies` instead.
265+
╭─[pixi.toml:7:9]
266+
6 │
267+
7 │ ╭─▶ [feature.foo.host-dependencies]
268+
8 │ ├─▶ foo = "*"
269+
· ╰──── replace this with 'dependencies'
270+
9 │
271+
╰────
272+
"#
273+
);
274+
}
275+
276+
#[test]
277+
fn test_build_dependencies_deprecation_warning() {
278+
assert_snapshot!(
279+
expect_parse_warnings(
280+
r#"
281+
[workspace]
282+
name = "test"
283+
channels = []
284+
platforms = ['linux-64']
285+
286+
[feature.foo.build-dependencies]
287+
bar = "*"
288+
289+
[environments]
290+
dev = ["foo"]
291+
"#,
292+
),
293+
@r#"
294+
⚠ The `build-dependencies` field is deprecated. Use `dependencies` instead.
295+
╭─[pixi.toml:7:9]
296+
6 │
297+
7 │ ╭─▶ [feature.foo.build-dependencies]
298+
8 │ ├─▶ bar = "*"
299+
· ╰──── replace this with 'dependencies'
300+
9 │
301+
╰────
302+
"#
303+
);
304+
}
219305
}

crates/pixi_manifest/src/toml/manifest.rs

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -486,8 +486,34 @@ impl<'de> toml_span::Deserialize<'de> for TomlManifest {
486486
.map(TomlWith::into_inner);
487487

488488
let dependencies = th.optional("dependencies");
489-
let host_dependencies = th.optional("host-dependencies");
490-
let build_dependencies = th.optional("build-dependencies");
489+
490+
let host_dependencies: Option<Spanned<UniquePackageMap>> = th.optional("host-dependencies");
491+
if let Some(host_dependencies) = &host_dependencies {
492+
warnings.push(
493+
Deprecation::renamed_field(
494+
"host-dependencies",
495+
"dependencies",
496+
host_dependencies.span,
497+
)
498+
.into(),
499+
);
500+
}
501+
let host_dependencies = host_dependencies.map(From::from);
502+
503+
let build_dependencies: Option<Spanned<UniquePackageMap>> =
504+
th.optional("build-dependencies");
505+
if let Some(build_dependencies) = &build_dependencies {
506+
warnings.push(
507+
Deprecation::renamed_field(
508+
"build-dependencies",
509+
"dependencies",
510+
build_dependencies.span,
511+
)
512+
.into(),
513+
);
514+
}
515+
let build_dependencies = build_dependencies.map(From::from);
516+
491517
let pypi_dependencies = th
492518
.optional::<TomlWith<_, PixiSpanned<TomlIndexMap<_, Same>>>>("pypi-dependencies")
493519
.map(TomlWith::into_inner);
@@ -788,6 +814,60 @@ mod test {
788814
));
789815
}
790816

817+
#[test]
818+
fn test_host_dependencies_deprecation_warning() {
819+
assert_snapshot!(
820+
expect_parse_warnings(
821+
r#"
822+
[workspace]
823+
name = "test"
824+
channels = []
825+
platforms = ['linux-64']
826+
827+
[host-dependencies]
828+
foo = "*"
829+
"#,
830+
),
831+
@r#"
832+
⚠ The `host-dependencies` field is deprecated. Use `dependencies` instead.
833+
╭─[pixi.toml:7:9]
834+
6 │
835+
7 │ ╭─▶ [host-dependencies]
836+
8 │ ├─▶ foo = "*"
837+
· ╰──── replace this with 'dependencies'
838+
9 │
839+
╰────
840+
"#
841+
);
842+
}
843+
844+
#[test]
845+
fn test_build_dependencies_deprecation_warning() {
846+
assert_snapshot!(
847+
expect_parse_warnings(
848+
r#"
849+
[workspace]
850+
name = "test"
851+
channels = []
852+
platforms = ['linux-64']
853+
854+
[build-dependencies]
855+
bar = "*"
856+
"#,
857+
),
858+
@r#"
859+
⚠ The `build-dependencies` field is deprecated. Use `dependencies` instead.
860+
╭─[pixi.toml:7:9]
861+
6 │
862+
7 │ ╭─▶ [build-dependencies]
863+
8 │ ├─▶ bar = "*"
864+
· ╰──── replace this with 'dependencies'
865+
9 │
866+
╰────
867+
"#
868+
);
869+
}
870+
791871
#[test]
792872
fn test_unused_features() {
793873
assert_snapshot!(expect_parse_warnings(

0 commit comments

Comments
 (0)