pipenv icon indicating copy to clipboard operation
pipenv copied to clipboard

Fix platform-specific packages causing resolution errors

Open matteius opened this issue 1 month ago • 0 comments

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:

  1. Skipped from the constraint set before resolution
  2. Added to the skipped packages dict
  3. 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 for sys_platform key 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

matteius avatar Dec 10 '25 23:12 matteius