PEP 508 (11 years ago) permits marker expressions with the variable on either side:
python_version >= '3.9' # variable on LHS — worked before
'3.9' <= python_version # variable on RHS — broken before this fix
'3.13.*' == python_full_version # wildcard failed entirely
However, packaging has never supported this. Someone noticed late last year, opened an issue, and now there are no fewer than three open PRs to add this (some clearly assisted or more by AI):
- Fix marker version comparison when variable is on the RHS (issue #934) by r266-tech · Pull Request #1126 · pypa/packaging · GitHub
- Fix RHS marker-variable version comparisons by SergioChan · Pull Request #1112 · pypa/packaging · GitHub
- fix(markers): handle version pattern on LHS when marker variable is on RHS by armorbreak001 · Pull Request #1172 · pypa/packaging · GitHub
uv also doesn’t fully support this, but it partially does, which I think is why we’ve started getting PRs to fix it now after all these years. (Specifically, uv pip install "tqdm; '3.13' <= python_version" works with uv, but uv pip install "tqdm; '3.14.*' == python_full_version" doesn’t work - it just always installs regardless of the python version.) Though maybe it’s just because someone noticed it, opened an issue, then people are picking it as an easy thing to fix, I don’t know. No one has pointed at a real package trying to use this.
The question is, do we want to allow these reversed expressions, or do we want to tighten the spec (with a PEP) to match current practice (minus a small number of packages that might have only been tested on uv and do have flipped values here). I’m neutral; I feel as a user I’d expect to be able to write it however I want, but as a developer, I like strict rules and I don’t like arbitrary choice. What do people think?
If people are happy with packaging allowing reversed order, we can merge on of the PRs, I think 1126 was the nicest implementation.
- Make the standard match packaging (no flipped order)
- Make packaging match the standard (support either order)