From debe67ffdb0cd7835734100e909b2d8f79613743 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 28 Oct 2024 18:08:33 -0400 Subject: [PATCH] Use `dev-dependencies` and `requires-dev` for lockfile compatibility (#8599) ## Summary Unfortunately, it looks like we lost https://github.com/astral-sh/uv/pull/8501 somewhere in a bad rebase. This PR re-adds the change, with compatibility for those lockfiles created in v0.4.27. I'm not certain we should actually merge this. It might be less painful and confusing to just bite the bullet on the change. --------- Co-authored-by: Zanie Blue --- CHANGELOG.md | 1 + crates/uv-resolver/src/lock/mod.rs | 8 +-- crates/uv/tests/it/edit.rs | 6 +-- crates/uv/tests/it/lock.rs | 52 ++++++++++--------- ...system__github-wikidata-bot-lock-file.snap | 4 +- .../it__ecosystem__packse-lock-file.snap | 4 +- .../it__ecosystem__warehouse-lock-file.snap | 4 +- ...se_add_remove_existing_package_noop-2.snap | 4 +- ...flow__packse_add_remove_one_package-2.snap | 4 +- ...te_transitive_to_direct_then_remove-2.snap | 4 +- crates/uv/tests/it/workflow.rs | 8 +-- 11 files changed, 51 insertions(+), 48 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8902524e61f8..d4865a6e4969 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ - Remove duplicate word in error message ([#8589](https://github.com/astral-sh/uv/pull/8589)) - Support cyclic dependencies in `uv tree` ([#8564](https://github.com/astral-sh/uv/pull/8564)) - Update `uv init` to imply `--package` when using `--build-backend` ([#8593](https://github.com/astral-sh/uv/pull/8593)) +- Restore use of `dev-dependencies` and `requires-dev` for lockfile compatibility ([#8599](https://github.com/astral-sh/uv/pull/8599)) ### Documentation diff --git a/crates/uv-resolver/src/lock/mod.rs b/crates/uv-resolver/src/lock/mod.rs index 51b2b199c795..4601556643d2 100644 --- a/crates/uv-resolver/src/lock/mod.rs +++ b/crates/uv-resolver/src/lock/mod.rs @@ -2068,7 +2068,7 @@ impl Package { } } if !dependency_groups.is_empty() { - table.insert("dependency-groups", Item::Table(dependency_groups)); + table.insert("dev-dependencies", Item::Table(dependency_groups)); } } @@ -2131,7 +2131,7 @@ impl Package { dependency_groups.insert(extra.as_ref(), value(deps)); } if !dependency_groups.is_empty() { - metadata_table.insert("dependency-groups", Item::Table(dependency_groups)); + metadata_table.insert("requires-dev", Item::Table(dependency_groups)); } } @@ -2241,7 +2241,7 @@ struct PackageWire { dependencies: Vec, #[serde(default)] optional_dependencies: BTreeMap>, - #[serde(default, alias = "dev-dependencies")] + #[serde(default, rename = "dev-dependencies", alias = "dependency-groups")] dependency_groups: BTreeMap>, } @@ -2250,7 +2250,7 @@ struct PackageWire { struct PackageMetadata { #[serde(default)] requires_dist: BTreeSet, - #[serde(default, alias = "requires-dev")] + #[serde(default, rename = "requires-dev", alias = "dependency-groups")] dependency_groups: BTreeMap>, } diff --git a/crates/uv/tests/it/edit.rs b/crates/uv/tests/it/edit.rs index 847c55bc8961..41165a5fd258 100644 --- a/crates/uv/tests/it/edit.rs +++ b/crates/uv/tests/it/edit.rs @@ -1074,14 +1074,14 @@ fn add_remove_dev() -> Result<()> { version = "0.1.0" source = { editable = "." } - [package.dependency-groups] + [package.dev-dependencies] dev = [ { name = "anyio" }, ] [package.metadata] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] dev = [{ name = "anyio", specifier = "==3.7.0" }] [[package]] @@ -1177,7 +1177,7 @@ fn add_remove_dev() -> Result<()> { [package.metadata] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] dev = [] "### ); diff --git a/crates/uv/tests/it/lock.rs b/crates/uv/tests/it/lock.rs index 4adf1b427573..01fc57d4edcb 100644 --- a/crates/uv/tests/it/lock.rs +++ b/crates/uv/tests/it/lock.rs @@ -4637,7 +4637,7 @@ fn lock_dev() -> Result<()> { { name = "iniconfig" }, ] - [package.dependency-groups] + [package.dev-dependencies] dev = [ { name = "typing-extensions" }, ] @@ -4645,7 +4645,7 @@ fn lock_dev() -> Result<()> { [package.metadata] requires-dist = [{ name = "iniconfig" }] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] dev = [{ name = "typing-extensions", url = "https://files.pythonhosted.org/packages/26/9f/ad63fc0248c5379346306f8668cda6e2e2e9c95e01216d2b8ffd9ff037d0/typing_extensions-4.12.2-py3-none-any.whl" }] [[package]] @@ -6249,14 +6249,14 @@ fn lock_dev_transitive() -> Result<()> { version = "0.1.0" source = { editable = "baz" } - [package.dependency-groups] + [package.dev-dependencies] dev = [ { name = "typing-extensions" }, ] [package.metadata] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] dev = [{ name = "typing-extensions", specifier = ">4" }] [[package]] @@ -6266,7 +6266,7 @@ fn lock_dev_transitive() -> Result<()> { [package.metadata] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] dev = [{ name = "anyio" }] [[package]] @@ -7176,7 +7176,7 @@ fn lock_no_sources() -> Result<()> { { name = "anyio" }, ] - [package.dependency-groups] + [package.dev-dependencies] dev = [ { name = "typing-extensions" }, ] @@ -7184,7 +7184,7 @@ fn lock_no_sources() -> Result<()> { [package.metadata] requires-dist = [{ name = "anyio", directory = "anyio" }] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] dev = [{ name = "typing-extensions", specifier = ">4" }] [[package]] @@ -7266,7 +7266,7 @@ fn lock_no_sources() -> Result<()> { { name = "anyio" }, ] - [package.dependency-groups] + [package.dev-dependencies] dev = [ { name = "typing-extensions" }, ] @@ -7274,7 +7274,7 @@ fn lock_no_sources() -> Result<()> { [package.metadata] requires-dist = [{ name = "anyio" }] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] dev = [{ name = "typing-extensions", specifier = ">4" }] [[package]] @@ -10999,8 +10999,10 @@ fn lock_missing_metadata() -> Result<()> { Ok(()) } -/// Test backwards compatibility for `package.dev-dependencies`, which was renamed to -/// `package.dependency-groups`. +/// Test backwards compatibility for `package.dependency-groups`. `package.dev-dependencies` was +/// accidentally renamed to `package.dependency-groups` in v0.4.27, which is technically out of +/// compliance with our lockfile versioning policy. In v0.4.28, we renamed it back to +/// `package.dev-dependencies`, with backwards compatibility for `package.dependency-groups`. #[test] fn lock_dev_dependencies_alias() -> Result<()> { let context = TestContext::new("3.12"); @@ -11034,12 +11036,12 @@ fn lock_dev_dependencies_alias() -> Result<()> { version = "0.1.0" source = { virtual = "." } - [package.dev-dependencies] + [package.dependency-groups] dev = [{ name = "iniconfig" }] [package.metadata] - [package.metadata.requires-dev] + [package.metadata.dependency-groups] dev = [{ name = "iniconfig" }] [[package]] @@ -11116,7 +11118,7 @@ fn lock_dev_dependencies_alias() -> Result<()> { { name = "typing-extensions" }, ] - [package.dependency-groups] + [package.dev-dependencies] dev = [ { name = "iniconfig" }, ] @@ -11124,7 +11126,7 @@ fn lock_dev_dependencies_alias() -> Result<()> { [package.metadata] requires-dist = [{ name = "typing-extensions" }] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] dev = [{ name = "iniconfig" }] [[package]] @@ -12650,14 +12652,14 @@ fn lock_dropped_dev_extra() -> Result<()> { version = "0.1.0" source = { editable = "." } - [package.dependency-groups] + [package.dev-dependencies] dev = [ { name = "coverage" }, ] [package.metadata] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] dev = [{ name = "coverage", extras = ["toml"] }] "### ); @@ -12765,7 +12767,7 @@ fn lock_empty_dev_dependencies() -> Result<()> { [package.metadata] requires-dist = [{ name = "iniconfig" }] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] dev = [] "### ); @@ -12873,7 +12875,7 @@ fn lock_empty_dependency_group() -> Result<()> { [package.metadata] requires-dist = [{ name = "iniconfig" }] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] empty = [] "### ); @@ -13836,7 +13838,7 @@ fn lock_explicit_virtual_project() -> Result<()> { { name = "black" }, ] - [package.dependency-groups] + [package.dev-dependencies] dev = [ { name = "anyio" }, ] @@ -13844,7 +13846,7 @@ fn lock_explicit_virtual_project() -> Result<()> { [package.metadata] requires-dist = [{ name = "black" }] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] dev = [{ name = "anyio" }] [[package]] @@ -14053,7 +14055,7 @@ fn lock_implicit_virtual_project() -> Result<()> { { name = "black" }, ] - [package.dependency-groups] + [package.dev-dependencies] dev = [ { name = "anyio" }, ] @@ -14061,7 +14063,7 @@ fn lock_implicit_virtual_project() -> Result<()> { [package.metadata] requires-dist = [{ name = "black" }] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] dev = [{ name = "anyio" }] [[package]] @@ -17004,7 +17006,7 @@ fn lock_group_include() -> Result<()> { { name = "typing-extensions" }, ] - [package.dependency-groups] + [package.dev-dependencies] bar = [ { name = "trio" }, ] @@ -17016,7 +17018,7 @@ fn lock_group_include() -> Result<()> { [package.metadata] requires-dist = [{ name = "typing-extensions" }] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] bar = [{ name = "trio" }] foo = [ { name = "anyio" }, diff --git a/crates/uv/tests/it/snapshots/it__ecosystem__github-wikidata-bot-lock-file.snap b/crates/uv/tests/it/snapshots/it__ecosystem__github-wikidata-bot-lock-file.snap index 5f4e82579f2e..5fb225ed60e8 100644 --- a/crates/uv/tests/it/snapshots/it__ecosystem__github-wikidata-bot-lock-file.snap +++ b/crates/uv/tests/it/snapshots/it__ecosystem__github-wikidata-bot-lock-file.snap @@ -116,7 +116,7 @@ dependencies = [ { name = "yarl" }, ] -[package.dependency-groups] +[package.dev-dependencies] dev = [ { name = "httpx" }, { name = "pytest" }, @@ -135,7 +135,7 @@ requires-dist = [ { name = "yarl", specifier = ">=1.9,<2" }, ] -[package.metadata.dependency-groups] +[package.metadata.requires-dev] dev = [ { name = "httpx", specifier = ">=0.27.0,<0.28" }, { name = "pytest", specifier = ">=8.0.0,<9" }, diff --git a/crates/uv/tests/it/snapshots/it__ecosystem__packse-lock-file.snap b/crates/uv/tests/it/snapshots/it__ecosystem__packse-lock-file.snap index 9d083cd0c6f7..70e94d40c7d6 100644 --- a/crates/uv/tests/it/snapshots/it__ecosystem__packse-lock-file.snap +++ b/crates/uv/tests/it/snapshots/it__ecosystem__packse-lock-file.snap @@ -332,7 +332,7 @@ serve = [ { name = "watchfiles" }, ] -[package.dependency-groups] +[package.dev-dependencies] dev = [ { name = "psutil" }, { name = "pytest" }, @@ -352,7 +352,7 @@ requires-dist = [ { name = "watchfiles", marker = "extra == 'serve'", specifier = ">=0.21.0" }, ] -[package.metadata.dependency-groups] +[package.metadata.requires-dev] dev = [ { name = "psutil", specifier = ">=5.9.7" }, { name = "pytest", specifier = ">=7.4.3" }, diff --git a/crates/uv/tests/it/snapshots/it__ecosystem__warehouse-lock-file.snap b/crates/uv/tests/it/snapshots/it__ecosystem__warehouse-lock-file.snap index ef050b15158d..a8dd7118a200 100644 --- a/crates/uv/tests/it/snapshots/it__ecosystem__warehouse-lock-file.snap +++ b/crates/uv/tests/it/snapshots/it__ecosystem__warehouse-lock-file.snap @@ -3889,7 +3889,7 @@ deploy = [ { name = "gunicorn" }, ] -[package.dependency-groups] +[package.dev-dependencies] dev = [ { name = "asyncudp" }, { name = "black" }, @@ -4033,7 +4033,7 @@ requires-dist = [ { name = "zxcvbn" }, ] -[package.metadata.dependency-groups] +[package.metadata.requires-dev] dev = [ { name = "asyncudp", specifier = ">=0.7" }, { name = "black", specifier = "==24.4.2" }, diff --git a/crates/uv/tests/it/snapshots/it__workflow__packse_add_remove_existing_package_noop-2.snap b/crates/uv/tests/it/snapshots/it__workflow__packse_add_remove_existing_package_noop-2.snap index b543a440fe5b..1724c2885e91 100644 --- a/crates/uv/tests/it/snapshots/it__workflow__packse_add_remove_existing_package_noop-2.snap +++ b/crates/uv/tests/it/snapshots/it__workflow__packse_add_remove_existing_package_noop-2.snap @@ -328,7 +328,7 @@ serve = [ { name = "watchfiles" }, ] -[package.dependency-groups] +[package.dev-dependencies] dev = [ { name = "psutil" }, { name = "pytest" }, @@ -348,7 +348,7 @@ requires-dist = [ { name = "watchfiles", marker = "extra == 'serve'", specifier = ">=0.21.0" }, ] -[package.metadata.dependency-groups] +[package.metadata.requires-dev] dev = [ { name = "psutil", specifier = ">=5.9.7" }, { name = "pytest", specifier = ">=7.4.3" }, diff --git a/crates/uv/tests/it/snapshots/it__workflow__packse_add_remove_one_package-2.snap b/crates/uv/tests/it/snapshots/it__workflow__packse_add_remove_one_package-2.snap index b543a440fe5b..1724c2885e91 100644 --- a/crates/uv/tests/it/snapshots/it__workflow__packse_add_remove_one_package-2.snap +++ b/crates/uv/tests/it/snapshots/it__workflow__packse_add_remove_one_package-2.snap @@ -328,7 +328,7 @@ serve = [ { name = "watchfiles" }, ] -[package.dependency-groups] +[package.dev-dependencies] dev = [ { name = "psutil" }, { name = "pytest" }, @@ -348,7 +348,7 @@ requires-dist = [ { name = "watchfiles", marker = "extra == 'serve'", specifier = ">=0.21.0" }, ] -[package.metadata.dependency-groups] +[package.metadata.requires-dev] dev = [ { name = "psutil", specifier = ">=5.9.7" }, { name = "pytest", specifier = ">=7.4.3" }, diff --git a/crates/uv/tests/it/snapshots/it__workflow__packse_promote_transitive_to_direct_then_remove-2.snap b/crates/uv/tests/it/snapshots/it__workflow__packse_promote_transitive_to_direct_then_remove-2.snap index b543a440fe5b..1724c2885e91 100644 --- a/crates/uv/tests/it/snapshots/it__workflow__packse_promote_transitive_to_direct_then_remove-2.snap +++ b/crates/uv/tests/it/snapshots/it__workflow__packse_promote_transitive_to_direct_then_remove-2.snap @@ -328,7 +328,7 @@ serve = [ { name = "watchfiles" }, ] -[package.dependency-groups] +[package.dev-dependencies] dev = [ { name = "psutil" }, { name = "pytest" }, @@ -348,7 +348,7 @@ requires-dist = [ { name = "watchfiles", marker = "extra == 'serve'", specifier = ">=0.21.0" }, ] -[package.metadata.dependency-groups] +[package.metadata.requires-dev] dev = [ { name = "psutil", specifier = ">=5.9.7" }, { name = "pytest", specifier = ">=7.4.3" }, diff --git a/crates/uv/tests/it/workflow.rs b/crates/uv/tests/it/workflow.rs index 7dcf9ad4697e..204a2137ee95 100644 --- a/crates/uv/tests/it/workflow.rs +++ b/crates/uv/tests/it/workflow.rs @@ -72,7 +72,7 @@ fn packse_add_remove_one_package() { { name = "watchfiles", marker = "extra == 'serve'", specifier = ">=0.21.0" }, ] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] dev = [ { name = "psutil", specifier = ">=5.9.7" }, { name = "pytest", specifier = ">=7.4.3" }, @@ -160,7 +160,7 @@ fn packse_add_remove_one_package() { { name = "watchfiles", marker = "extra == 'serve'", specifier = ">=0.21.0" }, ] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] dev = [ { name = "psutil", specifier = ">=5.9.7" }, { name = "pytest", specifier = ">=7.4.3" }, @@ -315,7 +315,7 @@ fn packse_promote_transitive_to_direct_then_remove() { { name = "watchfiles", marker = "extra == 'serve'", specifier = ">=0.21.0" }, ] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] dev = [ { name = "psutil", specifier = ">=5.9.7" }, { name = "pytest", specifier = ">=7.4.3" }, @@ -373,7 +373,7 @@ fn packse_promote_transitive_to_direct_then_remove() { { name = "watchfiles", marker = "extra == 'serve'", specifier = ">=0.21.0" }, ] - [package.metadata.dependency-groups] + [package.metadata.requires-dev] dev = [ { name = "psutil", specifier = ">=5.9.7" }, { name = "pytest", specifier = ">=7.4.3" },