Skip to content

Commit

Permalink
Use dev-dependencies and requires-dev for lockfile compatibility (#…
Browse files Browse the repository at this point in the history
…8599)

## Summary

Unfortunately, it looks like we lost
#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 <[email protected]>
  • Loading branch information
charliermarsh and zanieb authored Oct 28, 2024
1 parent 4c82561 commit debe67f
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 48 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 4 additions & 4 deletions crates/uv-resolver/src/lock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -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));
}
}

Expand Down Expand Up @@ -2241,7 +2241,7 @@ struct PackageWire {
dependencies: Vec<DependencyWire>,
#[serde(default)]
optional_dependencies: BTreeMap<ExtraName, Vec<DependencyWire>>,
#[serde(default, alias = "dev-dependencies")]
#[serde(default, rename = "dev-dependencies", alias = "dependency-groups")]
dependency_groups: BTreeMap<GroupName, Vec<DependencyWire>>,
}

Expand All @@ -2250,7 +2250,7 @@ struct PackageWire {
struct PackageMetadata {
#[serde(default)]
requires_dist: BTreeSet<Requirement>,
#[serde(default, alias = "requires-dev")]
#[serde(default, rename = "requires-dev", alias = "dependency-groups")]
dependency_groups: BTreeMap<GroupName, BTreeSet<Requirement>>,
}

Expand Down
6 changes: 3 additions & 3 deletions crates/uv/tests/it/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down Expand Up @@ -1177,7 +1177,7 @@ fn add_remove_dev() -> Result<()> {
[package.metadata]
[package.metadata.dependency-groups]
[package.metadata.requires-dev]
dev = []
"###
);
Expand Down
52 changes: 27 additions & 25 deletions crates/uv/tests/it/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4637,15 +4637,15 @@ fn lock_dev() -> Result<()> {
{ name = "iniconfig" },
]

[package.dependency-groups]
[package.dev-dependencies]
dev = [
{ name = "typing-extensions" },
]

[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]]
Expand Down Expand Up @@ -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]]
Expand All @@ -6266,7 +6266,7 @@ fn lock_dev_transitive() -> Result<()> {

[package.metadata]

[package.metadata.dependency-groups]
[package.metadata.requires-dev]
dev = [{ name = "anyio" }]

[[package]]
Expand Down Expand Up @@ -7176,15 +7176,15 @@ fn lock_no_sources() -> Result<()> {
{ name = "anyio" },
]

[package.dependency-groups]
[package.dev-dependencies]
dev = [
{ name = "typing-extensions" },
]

[package.metadata]
requires-dist = [{ name = "anyio", directory = "anyio" }]

[package.metadata.dependency-groups]
[package.metadata.requires-dev]
dev = [{ name = "typing-extensions", specifier = ">4" }]

[[package]]
Expand Down Expand Up @@ -7266,15 +7266,15 @@ fn lock_no_sources() -> Result<()> {
{ name = "anyio" },
]

[package.dependency-groups]
[package.dev-dependencies]
dev = [
{ name = "typing-extensions" },
]

[package.metadata]
requires-dist = [{ name = "anyio" }]

[package.metadata.dependency-groups]
[package.metadata.requires-dev]
dev = [{ name = "typing-extensions", specifier = ">4" }]

[[package]]
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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]]
Expand Down Expand Up @@ -11116,15 +11118,15 @@ fn lock_dev_dependencies_alias() -> Result<()> {
{ name = "typing-extensions" },
]

[package.dependency-groups]
[package.dev-dependencies]
dev = [
{ name = "iniconfig" },
]

[package.metadata]
requires-dist = [{ name = "typing-extensions" }]

[package.metadata.dependency-groups]
[package.metadata.requires-dev]
dev = [{ name = "iniconfig" }]

[[package]]
Expand Down Expand Up @@ -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"] }]
"###
);
Expand Down Expand Up @@ -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 = []
"###
);
Expand Down Expand Up @@ -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 = []
"###
);
Expand Down Expand Up @@ -13836,15 +13838,15 @@ fn lock_explicit_virtual_project() -> Result<()> {
{ name = "black" },
]

[package.dependency-groups]
[package.dev-dependencies]
dev = [
{ name = "anyio" },
]

[package.metadata]
requires-dist = [{ name = "black" }]

[package.metadata.dependency-groups]
[package.metadata.requires-dev]
dev = [{ name = "anyio" }]

[[package]]
Expand Down Expand Up @@ -14053,15 +14055,15 @@ fn lock_implicit_virtual_project() -> Result<()> {
{ name = "black" },
]

[package.dependency-groups]
[package.dev-dependencies]
dev = [
{ name = "anyio" },
]

[package.metadata]
requires-dist = [{ name = "black" }]

[package.metadata.dependency-groups]
[package.metadata.requires-dev]
dev = [{ name = "anyio" }]

[[package]]
Expand Down Expand Up @@ -17004,7 +17006,7 @@ fn lock_group_include() -> Result<()> {
{ name = "typing-extensions" },
]

[package.dependency-groups]
[package.dev-dependencies]
bar = [
{ name = "trio" },
]
Expand All @@ -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" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ dependencies = [
{ name = "yarl" },
]

[package.dependency-groups]
[package.dev-dependencies]
dev = [
{ name = "httpx" },
{ name = "pytest" },
Expand All @@ -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" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ serve = [
{ name = "watchfiles" },
]

[package.dependency-groups]
[package.dev-dependencies]
dev = [
{ name = "psutil" },
{ name = "pytest" },
Expand All @@ -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" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3889,7 +3889,7 @@ deploy = [
{ name = "gunicorn" },
]

[package.dependency-groups]
[package.dev-dependencies]
dev = [
{ name = "asyncudp" },
{ name = "black" },
Expand Down Expand Up @@ -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" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ serve = [
{ name = "watchfiles" },
]

[package.dependency-groups]
[package.dev-dependencies]
dev = [
{ name = "psutil" },
{ name = "pytest" },
Expand All @@ -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" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ serve = [
{ name = "watchfiles" },
]

[package.dependency-groups]
[package.dev-dependencies]
dev = [
{ name = "psutil" },
{ name = "pytest" },
Expand All @@ -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" },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ serve = [
{ name = "watchfiles" },
]

[package.dependency-groups]
[package.dev-dependencies]
dev = [
{ name = "psutil" },
{ name = "pytest" },
Expand All @@ -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" },
Expand Down
Loading

0 comments on commit debe67f

Please sign in to comment.