Skip to content

Commit

Permalink
Omit empty resolution markers in lockfile
Browse files Browse the repository at this point in the history
  • Loading branch information
konstin committed Dec 9, 2024
1 parent cded50f commit 13ecc64
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 45 deletions.
10 changes: 7 additions & 3 deletions crates/uv-resolver/src/lock/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,9 @@ impl Lock {
})
.filter_map(super::requires_python::SimplifiedMarkerTree::try_to_string),
);
doc.insert("resolution-markers", value(fork_markers));
if !fork_markers.is_empty() {
doc.insert("resolution-markers", value(fork_markers));
}
}

if !self.supported_environments.is_empty() {
Expand Down Expand Up @@ -1973,7 +1975,7 @@ impl Package {
self.id.to_toml(None, &mut table);

if !self.fork_markers.is_empty() {
let wheels = each_element_on_its_line_array(
let fork_markers = each_element_on_its_line_array(
self.fork_markers
.iter()
// TODO(ag): Consider whether `resolution-markers` should actually
Expand All @@ -1983,7 +1985,9 @@ impl Package {
.map(|marker| SimplifiedMarkerTree::new(requires_python, marker.pep508()))
.filter_map(super::requires_python::SimplifiedMarkerTree::try_to_string),
);
table.insert("resolution-markers", value(wheels));
if !fork_markers.is_empty() {
table.insert("resolution-markers", value(fork_markers));
}
}

if !self.dependencies.is_empty() {
Expand Down
42 changes: 0 additions & 42 deletions crates/uv/tests/it/lock_conflict.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,6 @@ fn extra_basic() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", extra = "extra1" },
{ package = "project", extra = "extra2" },
Expand Down Expand Up @@ -309,8 +307,6 @@ fn extra_basic_three_extras() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", extra = "extra1" },
{ package = "project", extra = "extra2" },
Expand Down Expand Up @@ -824,8 +820,6 @@ fn extra_multiple_independent() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", extra = "extra1" },
{ package = "project", extra = "extra2" },
Expand Down Expand Up @@ -986,8 +980,6 @@ fn extra_config_change_ignore_lockfile() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", extra = "extra1" },
{ package = "project", extra = "extra2" },
Expand Down Expand Up @@ -1499,8 +1491,6 @@ fn group_basic() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", group = "group1" },
{ package = "project", group = "group2" },
Expand Down Expand Up @@ -1665,8 +1655,6 @@ fn group_default() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", group = "group1" },
{ package = "project", group = "group2" },
Expand Down Expand Up @@ -1891,8 +1879,6 @@ fn mixed() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", group = "group1" },
{ package = "project", extra = "extra1" },
Expand Down Expand Up @@ -2067,8 +2053,6 @@ fn multiple_sources_index_disjoint_extras() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", extra = "cu118" },
{ package = "project", extra = "cu124" },
Expand Down Expand Up @@ -2218,8 +2202,6 @@ fn multiple_sources_index_disjoint_groups() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", group = "cu118" },
{ package = "project", group = "cu124" },
Expand Down Expand Up @@ -2369,8 +2351,6 @@ fn multiple_sources_index_disjoint_extras_with_extra() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", extra = "cu118" },
{ package = "project", extra = "cu124" },
Expand Down Expand Up @@ -2860,8 +2840,6 @@ fn shared_optional_dependency_extra1() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", extra = "foo" },
{ package = "project", extra = "bar" },
Expand Down Expand Up @@ -3004,8 +2982,6 @@ fn shared_optional_dependency_group1() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", group = "foo" },
{ package = "project", group = "bar" },
Expand Down Expand Up @@ -3150,8 +3126,6 @@ fn shared_optional_dependency_mixed1() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", extra = "foo" },
{ package = "project", group = "bar" },
Expand Down Expand Up @@ -3302,8 +3276,6 @@ fn shared_optional_dependency_extra2() -> Result<()> {
lock, @r###"
version = 1
requires-python = "==3.11.*"
resolution-markers = [
]
conflicts = [[
{ package = "project", extra = "foo" },
{ package = "project", extra = "bar" },
Expand Down Expand Up @@ -3450,8 +3422,6 @@ fn shared_optional_dependency_group2() -> Result<()> {
lock, @r###"
version = 1
requires-python = "==3.11.*"
resolution-markers = [
]
conflicts = [[
{ package = "project", group = "foo" },
{ package = "project", group = "bar" },
Expand Down Expand Up @@ -3604,8 +3574,6 @@ fn shared_optional_dependency_mixed2() -> Result<()> {
lock, @r###"
version = 1
requires-python = "==3.11.*"
resolution-markers = [
]
conflicts = [[
{ package = "project", extra = "foo" },
{ package = "project", group = "bar" },
Expand Down Expand Up @@ -3752,8 +3720,6 @@ fn shared_dependency_extra() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", extra = "foo" },
{ package = "project", extra = "bar" },
Expand Down Expand Up @@ -3931,8 +3897,6 @@ fn shared_dependency_group() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", group = "foo" },
{ package = "project", group = "bar" },
Expand Down Expand Up @@ -4112,8 +4076,6 @@ fn shared_dependency_mixed() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", extra = "foo" },
{ package = "project", group = "bar" },
Expand Down Expand Up @@ -4329,8 +4291,6 @@ conflicts = [
lock, @r###"
version = 1
requires-python = "==3.11.*"
resolution-markers = [
]
conflicts = [[
{ package = "project", extra = "x1" },
{ package = "proxy1", extra = "x2" },
Expand Down Expand Up @@ -4524,8 +4484,6 @@ fn jinja_no_conflict_markers1() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
]
conflicts = [[
{ package = "project", extra = "cu118" },
{ package = "project", extra = "cu124" },
Expand Down

0 comments on commit 13ecc64

Please sign in to comment.