Fix platform-specific packages causing resolution errors
Summary
Fixes #6028
When a package has a sys_platform or other marker that doesn't match the current platform, skip adding it to the constraint set before resolution. This prevents pip from trying to resolve packages that don't exist for the current platform.
Problem
Previously, packages like:
[packages]
pywin32 = {version = "*", sys_platform = "== 'win32'"}
Would cause resolution failures on Linux because the constraint was added to pip's resolver even though the marker didn't match. The error would be:
ERROR: No matching distribution found for pywin32
Solution
Now, packages with non-matching markers are:
- Skipped from the constraint set before resolution
- Added to the skipped packages dict
- Still recorded in the lockfile with their markers
This allows cross-platform Pipfiles to work correctly - packages that don't apply to the current platform are simply skipped during resolution rather than causing errors.
Changes
-
pipenv/utils/resolver.py: Check marker evaluation before adding to constraints -
tests/integration/test_lock.py: Add test forsys_platformkey syntax
Testing
Added a new test test_resolve_skip_unmatched_sys_platform that verifies packages with non-matching sys_platform markers are properly skipped during resolution.
Pull Request opened by Augment Code with guidance from the PR author