Fix implied `platform_machine` marker for `win_amd64` platform tag (#14041)

## Summary

Fixes #14040

## Test Plan

Added a test using required-environments
This commit is contained in:
Frazer McLean 2025-06-16 04:37:40 +02:00 committed by GitHub
parent 67c0f93e37
commit 87827b6d82
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 77 additions and 2 deletions

View File

@ -831,7 +831,7 @@ pub fn implied_markers(filename: &WheelFilename) -> MarkerTree {
tag_marker.and(MarkerTree::expression(MarkerExpression::String {
key: MarkerValueString::PlatformMachine,
operator: MarkerOperator::Equal,
value: arcstr::literal!("x86_64"),
value: arcstr::literal!("AMD64"),
}));
marker.or(tag_marker);
}
@ -925,7 +925,7 @@ mod tests {
);
assert_markers(
"numpy-2.2.1-cp313-cp313t-win_amd64.whl",
"sys_platform == 'win32' and platform_machine == 'x86_64'",
"sys_platform == 'win32' and platform_machine == 'AMD64'",
);
assert_markers(
"numpy-2.2.1-cp313-cp313t-win_arm64.whl",

View File

@ -27495,6 +27495,81 @@ fn windows_arm() -> Result<()> {
Ok(())
}
#[test]
fn windows_amd64_required() -> Result<()> {
let context = TestContext::new("3.12").with_exclude_newer("2025-01-30T00:00:00Z");
let pyproject_toml = context.temp_dir.child("pyproject.toml");
pyproject_toml.write_str(
r#"
[project]
name = "pywin32-prj"
version = "0.1.0"
requires-python = "~=3.12.0"
dependencies = ["pywin32; sys_platform == 'win32'"]
[tool.uv]
required-environments = [
"sys_platform == 'win32' and platform_machine == 'x86'",
"sys_platform == 'win32' and platform_machine == 'AMD64'",
]
"#,
)?;
uv_snapshot!(context.filters(), context.lock(), @r###"
success: true
exit_code: 0
----- stdout -----
----- stderr -----
Resolved 2 packages in [TIME]
"###);
let lock = context.read("uv.lock");
insta::with_settings!({
filters => context.filters(),
}, {
assert_snapshot!(
lock, @r#"
version = 1
revision = 2
requires-python = ">=3.12.[X], <3.13"
required-markers = [
"platform_machine == 'x86' and sys_platform == 'win32'",
"platform_machine == 'AMD64' and sys_platform == 'win32'",
]
[options]
exclude-newer = "2025-01-30T00:00:00Z"
[[package]]
name = "pywin32"
version = "308"
source = { registry = "https://pypi.org/simple" }
wheels = [
{ url = "https://files.pythonhosted.org/packages/00/7c/d00d6bdd96de4344e06c4afbf218bc86b54436a94c01c71a8701f613aa56/pywin32-308-cp312-cp312-win32.whl", hash = "sha256:587f3e19696f4bf96fde9d8a57cec74a57021ad5f204c9e627e15c33ff568897", size = 5939729, upload-time = "2024-10-12T20:42:12.001Z" },
{ url = "https://files.pythonhosted.org/packages/21/27/0c8811fbc3ca188f93b5354e7c286eb91f80a53afa4e11007ef661afa746/pywin32-308-cp312-cp312-win_amd64.whl", hash = "sha256:00b3e11ef09ede56c6a43c71f2d31857cf7c54b0ab6e78ac659497abd2834f47", size = 6543015, upload-time = "2024-10-12T20:42:14.044Z" },
{ url = "https://files.pythonhosted.org/packages/9d/0f/d40f8373608caed2255781a3ad9a51d03a594a1248cd632d6a298daca693/pywin32-308-cp312-cp312-win_arm64.whl", hash = "sha256:9b4de86c8d909aed15b7011182c8cab38c8850de36e6afb1f0db22b8959e3091", size = 7976033, upload-time = "2024-10-12T20:42:16.215Z" },
]
[[package]]
name = "pywin32-prj"
version = "0.1.0"
source = { virtual = "." }
dependencies = [
{ name = "pywin32", marker = "sys_platform == 'win32'" },
]
[package.metadata]
requires-dist = [{ name = "pywin32", marker = "sys_platform == 'win32'" }]
"#
);
});
Ok(())
}
#[test]
fn lock_empty_extra() -> Result<()> {
let context = TestContext::new("3.12");