Skip to content

Commit d3a6fec

Browse files
committed
Normalize platform_system to sys_platform
1 parent 4091cce commit d3a6fec

16 files changed

+184
-236
lines changed

crates/uv-pep508/src/marker/algebra.rs

+39-82
Original file line numberDiff line numberDiff line change
@@ -271,10 +271,44 @@ impl InternerGuard<'_> {
271271
key,
272272
operator,
273273
value,
274-
} => (
275-
Variable::String(key.into()),
276-
Edges::from_string(operator, value),
277-
),
274+
} => {
275+
// Normalize `platform_system` markers to `sys_platform` nodes.
276+
let (key, value) = match (key, value.as_str()) {
277+
(MarkerValueString::PlatformSystem, "Windows") => {
278+
(CanonicalMarkerValueString::SysPlatform, "win32".to_string())
279+
}
280+
(MarkerValueString::PlatformSystem, "Darwin") => (
281+
CanonicalMarkerValueString::SysPlatform,
282+
"darwin".to_string(),
283+
),
284+
(MarkerValueString::PlatformSystem, "Linux") => {
285+
(CanonicalMarkerValueString::SysPlatform, "linux".to_string())
286+
}
287+
(MarkerValueString::PlatformSystem, "Java") => {
288+
(CanonicalMarkerValueString::SysPlatform, "java".to_string())
289+
}
290+
(MarkerValueString::PlatformSystem, "AIX") => {
291+
(CanonicalMarkerValueString::SysPlatform, "aix".to_string())
292+
}
293+
(MarkerValueString::PlatformSystem, "FreeBSD") => (
294+
CanonicalMarkerValueString::SysPlatform,
295+
"freebsd".to_string(),
296+
),
297+
(MarkerValueString::PlatformSystem, "NetBSD") => (
298+
CanonicalMarkerValueString::SysPlatform,
299+
"netbsd".to_string(),
300+
),
301+
(MarkerValueString::PlatformSystem, "OpenBSD") => (
302+
CanonicalMarkerValueString::SysPlatform,
303+
"openbsd".to_string(),
304+
),
305+
(MarkerValueString::PlatformSystem, "SunOS") => {
306+
(CanonicalMarkerValueString::SysPlatform, "sunos".to_string())
307+
}
308+
_ => (key.into(), value),
309+
};
310+
(Variable::String(key), Edges::from_string(operator, value))
311+
}
278312
// A variable representing the existence or absence of a particular extra.
279313
MarkerExpression::Extra {
280314
name: MarkerValueExtra::Extra(extra),
@@ -822,84 +856,6 @@ impl InternerGuard<'_> {
822856
}
823857
let mut tree = NodeId::FALSE;
824858
for (a, b) in [
825-
// sys_platform == 'darwin' and platform_system == 'Windows'
826-
(
827-
MarkerExpression::String {
828-
key: MarkerValueString::SysPlatform,
829-
operator: MarkerOperator::Equal,
830-
value: "darwin".to_string(),
831-
},
832-
MarkerExpression::String {
833-
key: MarkerValueString::PlatformSystem,
834-
operator: MarkerOperator::Equal,
835-
value: "Windows".to_string(),
836-
},
837-
),
838-
// sys_platform == 'darwin' and platform_system == 'Linux'
839-
(
840-
MarkerExpression::String {
841-
key: MarkerValueString::SysPlatform,
842-
operator: MarkerOperator::Equal,
843-
value: "darwin".to_string(),
844-
},
845-
MarkerExpression::String {
846-
key: MarkerValueString::PlatformSystem,
847-
operator: MarkerOperator::Equal,
848-
value: "Linux".to_string(),
849-
},
850-
),
851-
// sys_platform == 'win32' and platform_system == 'Darwin'
852-
(
853-
MarkerExpression::String {
854-
key: MarkerValueString::SysPlatform,
855-
operator: MarkerOperator::Equal,
856-
value: "win32".to_string(),
857-
},
858-
MarkerExpression::String {
859-
key: MarkerValueString::PlatformSystem,
860-
operator: MarkerOperator::Equal,
861-
value: "Darwin".to_string(),
862-
},
863-
),
864-
// sys_platform == 'win32' and platform_system == 'Linux'
865-
(
866-
MarkerExpression::String {
867-
key: MarkerValueString::SysPlatform,
868-
operator: MarkerOperator::Equal,
869-
value: "win32".to_string(),
870-
},
871-
MarkerExpression::String {
872-
key: MarkerValueString::PlatformSystem,
873-
operator: MarkerOperator::Equal,
874-
value: "Linux".to_string(),
875-
},
876-
),
877-
// sys_platform == 'linux' and platform_system == 'Darwin'
878-
(
879-
MarkerExpression::String {
880-
key: MarkerValueString::SysPlatform,
881-
operator: MarkerOperator::Equal,
882-
value: "linux".to_string(),
883-
},
884-
MarkerExpression::String {
885-
key: MarkerValueString::PlatformSystem,
886-
operator: MarkerOperator::Equal,
887-
value: "Darwin".to_string(),
888-
},
889-
),
890-
// sys_platform == 'linux' and platform_system == 'Windows'
891-
(
892-
MarkerExpression::String {
893-
key: MarkerValueString::SysPlatform,
894-
operator: MarkerOperator::Equal,
895-
value: "linux".to_string(),
896-
},
897-
MarkerExpression::String {
898-
key: MarkerValueString::PlatformSystem,
899-
operator: MarkerOperator::Equal,
900-
value: "Windows".to_string(),
901-
},
902-
),
903859
// os_name == 'nt' and sys_platform == 'darwin'
904860
(
905861
MarkerExpression::String {
@@ -984,6 +940,7 @@ impl InternerGuard<'_> {
984940
let a_and_b = conjunction(self, a, b);
985941
tree = disjunction(self, tree, a_and_b);
986942
}
943+
987944
self.state.exclusions = Some(tree);
988945
tree
989946
}

crates/uv-requirements-txt/src/snapshots/uv_requirements_txt__test__line-endings-poetry-with-hashes.txt.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ RequirementsTxt {
8585
),
8686
),
8787
),
88-
marker: python_full_version >= '3.8' and python_full_version < '4.0' and platform_system == 'Windows',
88+
marker: python_full_version >= '3.8' and python_full_version < '4.0' and sys_platform == 'win32',
8989
origin: Some(
9090
File(
9191
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",

crates/uv-requirements-txt/src/snapshots/uv_requirements_txt__test__parse-poetry-with-hashes.txt.snap

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ RequirementsTxt {
8585
),
8686
),
8787
),
88-
marker: python_full_version >= '3.8' and python_full_version < '4.0' and platform_system == 'Windows',
88+
marker: python_full_version >= '3.8' and python_full_version < '4.0' and sys_platform == 'win32',
8989
origin: Some(
9090
File(
9191
"<REQUIREMENTS_DIR>/poetry-with-hashes.txt",

crates/uv-resolver/src/lock/mod.rs

+3-12
Original file line numberDiff line numberDiff line change
@@ -60,24 +60,15 @@ mod tree;
6060
pub const VERSION: u32 = 1;
6161

6262
static LINUX_MARKERS: LazyLock<UniversalMarker> = LazyLock::new(|| {
63-
let pep508 = MarkerTree::from_str(
64-
"platform_system == 'Linux' and os_name == 'posix' and sys_platform == 'linux'",
65-
)
66-
.unwrap();
63+
let pep508 = MarkerTree::from_str("os_name == 'posix' and sys_platform == 'linux'").unwrap();
6764
UniversalMarker::new(pep508, ConflictMarker::TRUE)
6865
});
6966
static WINDOWS_MARKERS: LazyLock<UniversalMarker> = LazyLock::new(|| {
70-
let pep508 = MarkerTree::from_str(
71-
"platform_system == 'Windows' and os_name == 'nt' and sys_platform == 'win32'",
72-
)
73-
.unwrap();
67+
let pep508 = MarkerTree::from_str("os_name == 'nt' and sys_platform == 'win32'").unwrap();
7468
UniversalMarker::new(pep508, ConflictMarker::TRUE)
7569
});
7670
static MAC_MARKERS: LazyLock<UniversalMarker> = LazyLock::new(|| {
77-
let pep508 = MarkerTree::from_str(
78-
"platform_system == 'Darwin' and os_name == 'posix' and sys_platform == 'darwin'",
79-
)
80-
.unwrap();
71+
let pep508 = MarkerTree::from_str("os_name == 'posix' and sys_platform == 'darwin'").unwrap();
8172
UniversalMarker::new(pep508, ConflictMarker::TRUE)
8273
});
8374

crates/uv/tests/it/export.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ fn dependency_extra() -> Result<()> {
128128
click==8.1.7 \
129129
--hash=sha256:ae74fb96c20a0277a1d615f1e4d73c8414f5a98db8b799a7931d1582f3390c28 \
130130
--hash=sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de
131-
colorama==0.4.6 ; platform_system == 'Windows' \
131+
colorama==0.4.6 ; sys_platform == 'win32' \
132132
--hash=sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44 \
133133
--hash=sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6
134134
flask==3.0.2 \

crates/uv/tests/it/lock.rs

+30-30
Original file line numberDiff line numberDiff line change
@@ -1014,7 +1014,7 @@ fn lock_wheel_url() -> Result<()> {
10141014
{ name = "trio", marker = "extra == 'trio'", specifier = ">=0.23" },
10151015
{ name = "trustme", marker = "extra == 'test'" },
10161016
{ name = "typing-extensions", marker = "python_full_version < '3.11'", specifier = ">=4.1" },
1017-
{ name = "uvloop", marker = "platform_python_implementation == 'CPython' and platform_system != 'Windows' and extra == 'test'", specifier = ">=0.17" },
1017+
{ name = "uvloop", marker = "platform_python_implementation == 'CPython' and sys_platform != 'win32' and extra == 'test'", specifier = ">=0.17" },
10181018
]
10191019

10201020
[[package]]
@@ -1159,7 +1159,7 @@ fn lock_sdist_url() -> Result<()> {
11591159
{ name = "trio", marker = "extra == 'trio'", specifier = ">=0.23" },
11601160
{ name = "trustme", marker = "extra == 'test'" },
11611161
{ name = "typing-extensions", marker = "python_full_version < '3.11'", specifier = ">=4.1" },
1162-
{ name = "uvloop", marker = "platform_python_implementation == 'CPython' and platform_system != 'Windows' and extra == 'test'", specifier = ">=0.17" },
1162+
{ name = "uvloop", marker = "platform_python_implementation == 'CPython' and sys_platform != 'win32' and extra == 'test'", specifier = ">=0.17" },
11631163
]
11641164

11651165
[[package]]
@@ -1675,7 +1675,7 @@ fn lock_dependency_extra() -> Result<()> {
16751675
version = "8.1.7"
16761676
source = { registry = "https://pypi.org/simple" }
16771677
dependencies = [
1678-
{ name = "colorama", marker = "platform_system == 'Windows'" },
1678+
{ name = "colorama", marker = "sys_platform == 'win32'" },
16791679
]
16801680
sdist = { url = "https://files.pythonhosted.org/packages/96/d3/f04c7bfcf5c1862a2a5b845c6b2b360488cf47af55dfa79c98f6a6bf98b5/click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de", size = 336121 }
16811681
wheels = [
@@ -2180,7 +2180,7 @@ fn lock_dependency_non_existent_extra() -> Result<()> {
21802180
version = "8.1.7"
21812181
source = { registry = "https://pypi.org/simple" }
21822182
dependencies = [
2183-
{ name = "colorama", marker = "platform_system == 'Windows'" },
2183+
{ name = "colorama", marker = "sys_platform == 'win32'" },
21842184
]
21852185
sdist = { url = "https://files.pythonhosted.org/packages/96/d3/f04c7bfcf5c1862a2a5b845c6b2b360488cf47af55dfa79c98f6a6bf98b5/click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de", size = 336121 }
21862186
wheels = [
@@ -12694,10 +12694,10 @@ fn lock_constrained_environment() -> Result<()> {
1269412694
version = 1
1269512695
requires-python = ">=3.12"
1269612696
resolution-markers = [
12697-
"platform_system != 'Windows'",
12697+
"sys_platform != 'win32'",
1269812698
]
1269912699
supported-markers = [
12700-
"platform_system != 'Windows'",
12700+
"sys_platform != 'win32'",
1270112701
]
1270212702

1270312703
[options]
@@ -12708,11 +12708,11 @@ fn lock_constrained_environment() -> Result<()> {
1270812708
version = "24.3.0"
1270912709
source = { registry = "https://pypi.org/simple" }
1271012710
dependencies = [
12711-
{ name = "click", marker = "platform_system != 'Windows'" },
12712-
{ name = "mypy-extensions", marker = "platform_system != 'Windows'" },
12713-
{ name = "packaging", marker = "platform_system != 'Windows'" },
12714-
{ name = "pathspec", marker = "platform_system != 'Windows'" },
12715-
{ name = "platformdirs", marker = "platform_system != 'Windows'" },
12711+
{ name = "click", marker = "sys_platform != 'win32'" },
12712+
{ name = "mypy-extensions", marker = "sys_platform != 'win32'" },
12713+
{ name = "packaging", marker = "sys_platform != 'win32'" },
12714+
{ name = "pathspec", marker = "sys_platform != 'win32'" },
12715+
{ name = "platformdirs", marker = "sys_platform != 'win32'" },
1271612716
]
1271712717
sdist = { url = "https://files.pythonhosted.org/packages/8f/5f/bac24a952668c7482cfdb4ebf91ba57a796c9da8829363a772040c1a3312/black-24.3.0.tar.gz", hash = "sha256:a0c9c4a0771afc6919578cec71ce82a3e31e054904e7197deacbc9382671c41f", size = 634292 }
1271812718
wheels = [
@@ -12772,7 +12772,7 @@ fn lock_constrained_environment() -> Result<()> {
1277212772
version = "0.1.0"
1277312773
source = { editable = "." }
1277412774
dependencies = [
12775-
{ name = "black", marker = "platform_system != 'Windows'" },
12775+
{ name = "black", marker = "sys_platform != 'win32'" },
1277612776
]
1277712777

1277812778
[package.metadata]
@@ -12907,7 +12907,7 @@ fn lock_constrained_environment() -> Result<()> {
1290712907
version = "8.1.7"
1290812908
source = { registry = "https://pypi.org/simple" }
1290912909
dependencies = [
12910-
{ name = "colorama", marker = "platform_system == 'Windows'" },
12910+
{ name = "colorama", marker = "sys_platform == 'win32'" },
1291112911
]
1291212912
sdist = { url = "https://files.pythonhosted.org/packages/96/d3/f04c7bfcf5c1862a2a5b845c6b2b360488cf47af55dfa79c98f6a6bf98b5/click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de", size = 336121 }
1291312913
wheels = [
@@ -13024,10 +13024,10 @@ fn lock_constrained_environment_legacy() -> Result<()> {
1302413024
version = 1
1302513025
requires-python = ">=3.12"
1302613026
resolution-markers = [
13027-
"platform_system != 'Windows'",
13027+
"sys_platform != 'win32'",
1302813028
]
1302913029
supported-markers = [
13030-
"platform_system != 'Windows'",
13030+
"sys_platform != 'win32'",
1303113031
]
1303213032

1303313033
[options]
@@ -13043,11 +13043,11 @@ fn lock_constrained_environment_legacy() -> Result<()> {
1304313043
version = "24.3.0"
1304413044
source = { registry = "https://pypi.org/simple" }
1304513045
dependencies = [
13046-
{ name = "click", marker = "platform_system != 'Windows'" },
13047-
{ name = "mypy-extensions", marker = "platform_system != 'Windows'" },
13048-
{ name = "packaging", marker = "platform_system != 'Windows'" },
13049-
{ name = "pathspec", marker = "platform_system != 'Windows'" },
13050-
{ name = "platformdirs", marker = "platform_system != 'Windows'" },
13046+
{ name = "click", marker = "sys_platform != 'win32'" },
13047+
{ name = "mypy-extensions", marker = "sys_platform != 'win32'" },
13048+
{ name = "packaging", marker = "sys_platform != 'win32'" },
13049+
{ name = "pathspec", marker = "sys_platform != 'win32'" },
13050+
{ name = "platformdirs", marker = "sys_platform != 'win32'" },
1305113051
]
1305213052
sdist = { url = "https://files.pythonhosted.org/packages/8f/5f/bac24a952668c7482cfdb4ebf91ba57a796c9da8829363a772040c1a3312/black-24.3.0.tar.gz", hash = "sha256:a0c9c4a0771afc6919578cec71ce82a3e31e054904e7197deacbc9382671c41f", size = 634292 }
1305313053
wheels = [
@@ -13062,7 +13062,7 @@ fn lock_constrained_environment_legacy() -> Result<()> {
1306213062
version = "0.1.0"
1306313063
source = { virtual = "child" }
1306413064
dependencies = [
13065-
{ name = "black", marker = "platform_system != 'Windows'" },
13065+
{ name = "black", marker = "sys_platform != 'win32'" },
1306613066
]
1306713067

1306813068
[package.metadata]
@@ -13169,9 +13169,9 @@ fn lock_overlapping_environment() -> Result<()> {
1316913169
----- stdout -----
1317013170

1317113171
----- stderr -----
13172-
error: Supported environments must be disjoint, but the following markers overlap: `platform_system != 'Windows'` and `python_full_version >= '3.11'`.
13172+
error: Supported environments must be disjoint, but the following markers overlap: `sys_platform != 'win32'` and `python_full_version >= '3.11'`.
1317313173

13174-
hint: replace `python_full_version >= '3.11'` with `python_full_version >= '3.11' and platform_system == 'Windows'`.
13174+
hint: replace `python_full_version >= '3.11'` with `python_full_version >= '3.11' and sys_platform == 'win32'`.
1317513175
"###);
1317613176

1317713177
Ok(())
@@ -15049,7 +15049,7 @@ fn lock_explicit_virtual_project() -> Result<()> {
1504915049
version = "8.1.7"
1505015050
source = { registry = "https://pypi.org/simple" }
1505115051
dependencies = [
15052-
{ name = "colorama", marker = "platform_system == 'Windows'" },
15052+
{ name = "colorama", marker = "sys_platform == 'win32'" },
1505315053
]
1505415054
sdist = { url = "https://files.pythonhosted.org/packages/96/d3/f04c7bfcf5c1862a2a5b845c6b2b360488cf47af55dfa79c98f6a6bf98b5/click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de", size = 336121 }
1505515055
wheels = [
@@ -15266,7 +15266,7 @@ fn lock_implicit_virtual_project() -> Result<()> {
1526615266
version = "8.1.7"
1526715267
source = { registry = "https://pypi.org/simple" }
1526815268
dependencies = [
15269-
{ name = "colorama", marker = "platform_system == 'Windows'" },
15269+
{ name = "colorama", marker = "sys_platform == 'win32'" },
1527015270
]
1527115271
sdist = { url = "https://files.pythonhosted.org/packages/96/d3/f04c7bfcf5c1862a2a5b845c6b2b360488cf47af55dfa79c98f6a6bf98b5/click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de", size = 336121 }
1527215272
wheels = [
@@ -15765,7 +15765,7 @@ fn lock_python_upper_bound() -> Result<()> {
1576515765
version = "8.1.7"
1576615766
source = { registry = "https://pypi.org/simple" }
1576715767
dependencies = [
15768-
{ name = "colorama", marker = "platform_system == 'Windows'" },
15768+
{ name = "colorama", marker = "sys_platform == 'win32'" },
1576915769
]
1577015770
sdist = { url = "https://files.pythonhosted.org/packages/96/d3/f04c7bfcf5c1862a2a5b845c6b2b360488cf47af55dfa79c98f6a6bf98b5/click-8.1.7.tar.gz", hash = "sha256:ca9853ad459e787e2192211578cc907e7594e294c7ccc834310722b41b9ca6de", size = 336121 }
1577115771
wheels = [
@@ -16048,7 +16048,7 @@ fn lock_python_upper_bound() -> Result<()> {
1604816048
version = "4.66.2"
1604916049
source = { registry = "https://pypi.org/simple" }
1605016050
dependencies = [
16051-
{ name = "colorama", marker = "platform_system == 'Windows'" },
16051+
{ name = "colorama", marker = "sys_platform == 'win32'" },
1605216052
]
1605316053
sdist = { url = "https://files.pythonhosted.org/packages/ea/85/3ce0f9f7d3f596e7ea57f4e5ce8c18cb44e4a9daa58ddb46ee0d13d6bff8/tqdm-4.66.2.tar.gz", hash = "sha256:6cd52cdf0fef0e0f543299cfc96fec90d7b8a7e88745f411ec33eb44d5ed3531", size = 169462 }
1605416054
wheels = [
@@ -17985,7 +17985,7 @@ fn lock_multiple_sources_respect_marker() -> Result<()> {
1798517985
name = "project"
1798617986
version = "0.1.0"
1798717987
requires-python = ">=3.12"
17988-
dependencies = ["iniconfig ; platform_system == 'Windows'"]
17988+
dependencies = ["iniconfig ; sys_platform == 'win32'"]
1798917989

1799017990
[tool.uv.sources]
1799117991
iniconfig = [
@@ -18030,11 +18030,11 @@ fn lock_multiple_sources_respect_marker() -> Result<()> {
1803018030
version = "0.1.0"
1803118031
source = { virtual = "." }
1803218032
dependencies = [
18033-
{ name = "iniconfig", marker = "platform_system == 'Windows' and sys_platform != 'darwin'" },
18033+
{ name = "iniconfig", marker = "sys_platform == 'win32'" },
1803418034
]
1803518035

1803618036
[package.metadata]
18037-
requires-dist = [{ name = "iniconfig", marker = "platform_system == 'Windows' and sys_platform != 'darwin'" }]
18037+
requires-dist = [{ name = "iniconfig", marker = "sys_platform == 'win32'" }]
1803818038
"###
1803918039
);
1804018040
});

0 commit comments

Comments
 (0)