fix: filter Windows-specific wheels from PEX lock for Linux/Mac targets

- Add platform filtering to exclude Windows wheels (Win32, WinAmd64, WinArm64, WinIa64)
- Import uv_platform_tags::PlatformTag for platform detection
- Only include platform-compatible artifacts in PEX lock file
- Fixes "Failed to resolve compatible artifacts" error for Linux targets

This prevents Windows-only packages like pywin32 from being included
in PEX lock files targeting Linux/Mac systems.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Alessandro De Maria 2025-07-06 00:05:26 +00:00
parent d8cdb7c199
commit 67e3aaa6db

View file

@ -12,6 +12,7 @@
use std::fmt; use std::fmt;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use uv_platform_tags::PlatformTag;
use crate::lock::{Lock, LockError, WheelWireSource}; use crate::lock::{Lock, LockError, WheelWireSource};
@ -153,8 +154,23 @@ impl PexLock {
// Create locked requirement // Create locked requirement
let mut artifacts = Vec::new(); let mut artifacts = Vec::new();
// Add wheels // Add wheels (excluding Windows-specific wheels for Linux/Mac targets)
for wheel in &package.wheels { for wheel in &package.wheels {
// Filter out Windows-specific wheels when targeting linux/mac
let is_windows_wheel = wheel.filename.platform_tags().iter().any(|tag| {
matches!(
tag,
PlatformTag::Win32
| PlatformTag::WinAmd64
| PlatformTag::WinArm64
| PlatformTag::WinIa64
)
});
if is_windows_wheel {
continue;
}
let wheel_url = match &wheel.url { let wheel_url = match &wheel.url {
WheelWireSource::Url { url } => url.to_string(), WheelWireSource::Url { url } => url.to_string(),
WheelWireSource::Path { path } => format!("file://{}", path.to_string_lossy()), WheelWireSource::Path { path } => format!("file://{}", path.to_string_lossy()),
@ -212,7 +228,8 @@ impl PexLock {
.find(|pkg| pkg.id.name == dep.package_id.name) .find(|pkg| pkg.id.name == dep.package_id.name)
.and_then(|pkg| pkg.id.version.as_ref()) .and_then(|pkg| pkg.id.version.as_ref())
{ {
requires_dists.push(format!("{}=={}", dep.package_id.name, dep_version)); requires_dists
.push(format!("{}=={}", dep.package_id.name, dep_version));
} }
} }