Evaluate PEP 508 environment markers when parsing requirements - #520
Open
dchaudhari7177 wants to merge 1 commit into
Open
Evaluate PEP 508 environment markers when parsing requirements#520dchaudhari7177 wants to merge 1 commit into
dchaudhari7177 wants to merge 1 commit into
Conversation
dchaudhari7177
force-pushed
the
fix/evaluate-environment-markers
branch
from
August 9, 2026 03:33
7b234cb to
400a0f7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #517.
parse_pipignored PEP 508 environment markers, so a line likecolorama==0.4.6 ; sys_platform == 'win32'was always treated as an expected requirement — a false-positive mismatch on any environment the marker excludes (e.g.colorama"missing" on Linux).Now each requirement's marker is evaluated with
packaging.markers.Marker, and lines whose marker doesn't apply to the current environment are skipped. A malformed marker is left for pip to report rather than silently dropping the requirement. Splitting on;before parsing also makes name/version extraction robust to markers written without surrounding spaces.Dependency note
This adds
packagingtodependencies(the project was zero-dependency). Correct PEP 508 marker evaluation really needs it, andpackagingis present in every environment where pip runs, so it shouldn't change pip-lock's practical footprint. If you'd rather keep the zero-dependency install, I'm happy to switch to an optional import (evaluate markers whenpackagingis importable, otherwise fall back to current behaviour) — just say the word.Tests
Added cases for a marker that matches (kept), doesn't match (skipped), has no surrounding spaces, is combined with extras, and is malformed (kept). The skip cases fail on
mainand pass with the change; full suite green;ruff check/formatclean. Added a CHANGELOG entry.