Skip to content

Commit

Permalink
Fork on...
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Dec 16, 2024
1 parent 0bed449 commit f3e0a90
Show file tree
Hide file tree
Showing 16 changed files with 1,785 additions and 1,736 deletions.
52 changes: 52 additions & 0 deletions crates/uv-pep508/src/marker/algebra.rs
Original file line number Diff line number Diff line change
Expand Up @@ -984,6 +984,58 @@ impl InternerGuard<'_> {
let a_and_b = conjunction(self, a, b);
tree = disjunction(self, tree, a_and_b);
}

// These are markers that must have the same value (i.e., they must both be true or both be
// false).
for (a, b) in [
// sys_platform == 'win32' and platform_system == 'Windows'
(
MarkerExpression::String {
key: MarkerValueString::SysPlatform,
operator: MarkerOperator::Equal,
value: "win32".to_string(),
},
MarkerExpression::String {
key: MarkerValueString::PlatformSystem,
operator: MarkerOperator::Equal,
value: "Windows".to_string(),
},
),
// sys_platform == 'darwin' and platform_system == 'Darwin'
(
MarkerExpression::String {
key: MarkerValueString::SysPlatform,
operator: MarkerOperator::Equal,
value: "darwin".to_string(),
},
MarkerExpression::String {
key: MarkerValueString::PlatformSystem,
operator: MarkerOperator::Equal,
value: "Darwin".to_string(),
},
),
// sys_platform == 'linux' and platform_system == 'Linux'
(
MarkerExpression::String {
key: MarkerValueString::SysPlatform,
operator: MarkerOperator::Equal,
value: "linux".to_string(),
},
MarkerExpression::String {
key: MarkerValueString::PlatformSystem,
operator: MarkerOperator::Equal,
value: "Linux".to_string(),
},
),
] {
let a = self.expression(a);
let b = self.expression(b);
let a_and_not_b = conjunction(self, a, b.not());
let not_a_and_b = conjunction(self, a.not(), b);
tree = disjunction(self, tree, a_and_not_b);
tree = disjunction(self, tree, not_a_and_b);
}

self.state.exclusions = Some(tree);
tree
}
Expand Down
19 changes: 19 additions & 0 deletions crates/uv-pep508/src/marker/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1165,6 +1165,25 @@ impl MarkerTree {
_ => None,
}))
}

pub fn references_platform(self) -> bool {
match self.kind() {
MarkerTreeKind::True => false,
MarkerTreeKind::False => false,
MarkerTreeKind::Version(marker) => {
false
}
MarkerTreeKind::String(marker) => {
matches!(marker.key, CanonicalMarkerValueString::SysPlatform) ||
marker
.children()
.any(|(_, tree)| tree.references_platform())
}
MarkerTreeKind::In(marker) => false,
MarkerTreeKind::Contains(marker) => false,
MarkerTreeKind::Extra(marker) => false,
}
}
}

impl fmt::Debug for MarkerTree {
Expand Down
1 change: 1 addition & 0 deletions crates/uv-resolver/src/resolver/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3129,6 +3129,7 @@ impl Forks {
.marker()
.and_then(marker::requires_python)
.is_some_and(|bound| python_requirement.raises(&bound))
&& !dep.package.marker().is_some_and(|marker| marker.references_platform())
{
let dep = deps.pop().unwrap();
let markers = dep.package.marker().unwrap_or(MarkerTree::TRUE);
Expand Down
46 changes: 36 additions & 10 deletions crates/uv/tests/it/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13405,6 +13405,10 @@ fn lock_non_project_conditional() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
"sys_platform == 'linux'",
"sys_platform != 'linux'",
]

[options]
exclude-newer = "2024-03-25T00:00:00Z"
Expand All @@ -13417,8 +13421,8 @@ fn lock_non_project_conditional() -> Result<()> {
version = "4.3.0"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "idna" },
{ name = "sniffio" },
{ name = "idna", marker = "sys_platform == 'linux'" },
{ name = "sniffio", marker = "sys_platform == 'linux'" },
]
sdist = { url = "https://files.pythonhosted.org/packages/db/4d/3970183622f0330d3c23d9b8a5f52e365e50381fd484d08e3285104333d3/anyio-4.3.0.tar.gz", hash = "sha256:f75253795a87df48568485fd18cdd2a3fa5c4f7c5be8e5e36637733fce06fed6", size = 159642 }
wheels = [
Expand Down Expand Up @@ -15818,9 +15822,12 @@ fn lock_python_upper_bound() -> Result<()> {
version = 1
requires-python = ">=3.8"
resolution-markers = [
"python_full_version >= '3.13'",
"python_full_version < '3.9'",
"python_full_version >= '3.9' and python_full_version < '3.13'",
"python_full_version >= '3.13' and sys_platform == 'win32'",
"python_full_version >= '3.13' and sys_platform != 'win32'",
"python_full_version < '3.9' and sys_platform == 'win32'",
"python_full_version < '3.9' and sys_platform != 'win32'",
"python_full_version >= '3.9' and python_full_version < '3.13' and sys_platform == 'win32'",
"python_full_version >= '3.9' and python_full_version < '3.13' and sys_platform != 'win32'",
]

[options]
Expand All @@ -15831,7 +15838,7 @@ fn lock_python_upper_bound() -> Result<()> {
version = "8.1.7"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "colorama", marker = "platform_system == 'Windows'" },
{ name = "colorama", marker = "platform_system == 'Windows' and sys_platform == 'win32'" },
]
sdist = { url = "https://files.pythonhosted.org/packages/96/d3/f04c7bfcf5c1862a2a5b845c6b2b360488cf47af55dfa79c98f6a6bf98b5/click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de", size = 336121 }
wheels = [
Expand Down Expand Up @@ -15912,7 +15919,8 @@ fn lock_python_upper_bound() -> Result<()> {
version = "1.24.4"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
"python_full_version < '3.9'",
"python_full_version < '3.9' and sys_platform == 'win32'",
"python_full_version < '3.9' and sys_platform != 'win32'",
]
sdist = { url = "https://files.pythonhosted.org/packages/a4/9b/027bec52c633f6556dba6b722d9a0befb40498b9ceddd29cbe67a45a127c/numpy-1.24.4.tar.gz", hash = "sha256:80f5e3a4e498641401868df4208b74581206afbee7cf7b8329daae82676d9463", size = 10911229 }
wheels = [
Expand Down Expand Up @@ -15950,7 +15958,8 @@ fn lock_python_upper_bound() -> Result<()> {
version = "1.26.4"
source = { registry = "https://pypi.org/simple" }
resolution-markers = [
"python_full_version >= '3.9' and python_full_version < '3.13'",
"python_full_version >= '3.9' and python_full_version < '3.13' and sys_platform == 'win32'",
"python_full_version >= '3.9' and python_full_version < '3.13' and sys_platform != 'win32'",
]
sdist = { url = "https://files.pythonhosted.org/packages/65/6e/09db70a523a96d25e115e71cc56a6f9031e7b8cd166c1ac8438307c14058/numpy-1.26.4.tar.gz", hash = "sha256:2a02aba9ed12e4ac4eb3ea9421c420301a0c6460d9830d74a9df87efa4912010", size = 15786129 }
wheels = [
Expand Down Expand Up @@ -16114,7 +16123,7 @@ fn lock_python_upper_bound() -> Result<()> {
version = "4.66.2"
source = { registry = "https://pypi.org/simple" }
dependencies = [
{ name = "colorama", marker = "platform_system == 'Windows'" },
{ name = "colorama", marker = "platform_system == 'Windows' and sys_platform == 'win32'" },
]
sdist = { url = "https://files.pythonhosted.org/packages/ea/85/3ce0f9f7d3f596e7ea57f4e5ce8c18cb44e4a9daa58ddb46ee0d13d6bff8/tqdm-4.66.2.tar.gz", hash = "sha256:6cd52cdf0fef0e0f543299cfc96fec90d7b8a7e88745f411ec33eb44d5ed3531", size = 169462 }
wheels = [
Expand Down Expand Up @@ -18078,6 +18087,10 @@ fn lock_multiple_sources_respect_marker() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
"platform_system == 'Windows' and sys_platform != 'darwin'",
"platform_system != 'Windows' or sys_platform == 'darwin'",
]

[options]
exclude-newer = "2024-03-25T00:00:00Z"
Expand Down Expand Up @@ -19117,6 +19130,10 @@ fn lock_group_workspace() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
"sys_platform == 'win32'",
"sys_platform != 'win32'",
]

[options]
exclude-newer = "2024-03-25T00:00:00Z"
Expand Down Expand Up @@ -19956,6 +19973,11 @@ fn lock_recursive_extra() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
"python_full_version >= '3.13' and sys_platform == 'darwin'",
"sys_platform != 'darwin'",
"python_full_version < '3.13' and sys_platform == 'darwin'",
]

[options]
exclude-newer = "2024-03-25T00:00:00Z"
Expand Down Expand Up @@ -20747,6 +20769,10 @@ fn lock_self_marker_compatible() -> Result<()> {
lock, @r###"
version = 1
requires-python = ">=3.12"
resolution-markers = [
"sys_platform == 'win32'",
"sys_platform != 'win32'",
]

[options]
exclude-newer = "2024-03-25T00:00:00Z"
Expand Down Expand Up @@ -20834,7 +20860,7 @@ fn lock_self_marker_incompatible() -> Result<()> {
----- stdout -----

----- stderr -----
× No solution found when resolving dependencies:
× No solution found when resolving dependencies for split (sys_platform == 'win32'):
╰─▶ Because only project{sys_platform == 'win32'}<=0.1 is available and your project depends on itself at an incompatible version (project{sys_platform == 'win32'}>0.1), we can conclude that your project's requirements are unsatisfiable.

hint: The project `project` depends on itself at an incompatible version. This is likely a mistake. If you intended to depend on a third-party package named `project`, consider renaming the project `project` to avoid creating a conflict.
Expand Down
Loading

0 comments on commit f3e0a90

Please sign in to comment.