fix: filter Windows-only dependencies from requires_dists

- Filter dependencies that only have Windows-specific artifacts
- Check each dependency for compatible (non-Windows) wheels or sdist
- Exclude Windows-only packages like pywin32 from dependency lists
- Fixes "Dependency on pywin32 not satisfied, no candidates found" error

This prevents Windows-only dependencies from being included in the
requires_dists field when targeting Linux/Mac platforms, ensuring
PEX can resolve all declared dependencies.

🤖 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:14:38 +00:00
parent 67e3aaa6db
commit a1ccbb7605

View file

@ -219,19 +219,36 @@ impl PexLock {
if let Some(version) = &package.id.version {
// Only include packages that have at least one artifact
if !artifacts.is_empty() {
// Collect dependencies for this package
// Collect dependencies for this package (only those with compatible artifacts)
let mut requires_dists = Vec::new();
for dep in &package.dependencies {
if let Some(dep_version) = lock
if let Some(dep_package) = lock
.packages()
.iter()
.find(|pkg| pkg.id.name == dep.package_id.name)
.and_then(|pkg| pkg.id.version.as_ref())
{
// Check if the dependency has any non-Windows artifacts
let has_compatible_artifacts = dep_package.wheels.iter().any(|wheel| {
!wheel.filename.platform_tags().iter().any(|tag| {
matches!(
tag,
PlatformTag::Win32
| PlatformTag::WinAmd64
| PlatformTag::WinArm64
| PlatformTag::WinIa64
)
})
}) || dep_package.sdist.is_some();
// Only include dependencies that have compatible artifacts
if has_compatible_artifacts {
if let Some(dep_version) = dep_package.id.version.as_ref() {
requires_dists
.push(format!("{}=={}", dep.package_id.name, dep_version));
}
}
}
}
locked_requirements.push(PexLockedRequirement {
artifacts,