From 67e3aaa6dbc3a59765c0da18e731ff8bbce54b06 Mon Sep 17 00:00:00 2001 From: Alessandro De Maria Date: Sun, 6 Jul 2025 00:05:26 +0000 Subject: [PATCH] fix: filter Windows-specific wheels from PEX lock for Linux/Mac targets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- .../uv-resolver/src/lock/export/pex_lock.rs | 21 +++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/crates/uv-resolver/src/lock/export/pex_lock.rs b/crates/uv-resolver/src/lock/export/pex_lock.rs index 867286958..92073320a 100644 --- a/crates/uv-resolver/src/lock/export/pex_lock.rs +++ b/crates/uv-resolver/src/lock/export/pex_lock.rs @@ -12,6 +12,7 @@ use std::fmt; use serde::{Deserialize, Serialize}; +use uv_platform_tags::PlatformTag; use crate::lock::{Lock, LockError, WheelWireSource}; @@ -153,8 +154,23 @@ impl PexLock { // Create locked requirement let mut artifacts = Vec::new(); - // Add wheels + // Add wheels (excluding Windows-specific wheels for Linux/Mac targets) 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 { WheelWireSource::Url { url } => url.to_string(), WheelWireSource::Path { path } => format!("file://{}", path.to_string_lossy()), @@ -212,7 +228,8 @@ impl PexLock { .find(|pkg| pkg.id.name == dep.package_id.name) .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)); } }