Skip to content

fix(install-wheel): parse wheel version components as integers before comparison - #19479

Closed
thesayakmondal wants to merge 3 commits into
astral-sh:mainfrom
thesayakmondal:fix/wheel-version-numeric-comparison
Closed

thesayakmondal wants to merge 3 commits into
astral-sh:mainfrom
thesayakmondal:fix/wheel-version-numeric-comparison

Conversation

@thesayakmondal

Copy link
Copy Markdown
Contributor

Summary

When parsing the WHEEL metadata file, the Wheel-Version major and minor
components were compared as raw &str slices rather than parsed integers.
The minor version check wheel_version.1 > "0" uses lexicographic ordering,
which produces incorrect results for two-digit minor versions: e.g., "10" > "9"
is false as strings (since '1' < '9'), so a Wheel-Version: 1.10 would
silently skip the unsupported-minor-version warning. The major version check
wheel_version.0 != "1" has the same structural problem (e.g., "01" != "1"
is true as strings despite being numerically equal).

This PR parses both components as u32 before comparison, matching the intent
described in the comment above the checks and aligning with PEP 427 semantics.
Invalid (non-numeric) version components now return Error::InvalidWheel
consistently with other parse failures in the same function.

Test Plan

Existing tests in test_parse_wheel_version continue to pass (1.0 succeeds,
2.0 errors). The fix can be manually verified by constructing a WHEEL file
with Wheel-Version: 1.10 and confirming the unsupported-minor-version warning
is now emitted, whereas previously it was silently swallowed due to the
lexicographic comparison.

@codspeed

codspeed Bot commented May 19, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 5 untouched benchmarks


Comparing Dev-X25874:fix/wheel-version-numeric-comparison (496e160) with main (57df0e4)

Open in CodSpeed

@zanieb

zanieb commented May 19, 2026

Copy link
Copy Markdown
Member

Wheel-Version: 1.10 would silently skip the unsupported-minor-version warning.

Is this true? Codex claims not.

pip does not enforce that the version is two components, what does the spec say about that?

Please don't open pull requests without test cases.

@thesayakmondal

Copy link
Copy Markdown
Contributor Author

You're right, I overstated the impact. This is a correctness
improvement — non-numeric version strings like "1.invalid"
were never properly validated. Adding test cases now.

@thesayakmondal
thesayakmondal deleted the fix/wheel-version-numeric-comparison branch May 20, 2026 10:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants