Skip to content

Prefer newest manylinux wheels by sorting expanded platforms#218

Open
eloisekp wants to merge 1 commit intojvolkman:mainfrom
eloisekp:eloisekp-canva-reorder-manylinux-wheels
Open

Prefer newest manylinux wheels by sorting expanded platforms#218
eloisekp wants to merge 1 commit intojvolkman:mainfrom
eloisekp:eloisekp-canva-reorder-manylinux-wheels

Conversation

@eloisekp
Copy link

@eloisekp eloisekp commented Feb 10, 2026

Problem

After switching to rules_pycross, we discovered that some packages (e.g. XGBoost) were resolving to the manylinux2014 wheel instead of the manylinux_2_28 wheel on Linux, which led to slower or less optimal builds when the newer wheel is preferred.

  • In _expand_manylinux_platforms(), the expanded platform list was ordered with a regular sorted(platforms) .
  • So in the environment’s tag list, manylinux2014_x86_64 appeared before manylinux_2_28_x86_64.
  • Then pip’s CandidateEvaluator.compute_best_candidate() ranks wheels by Wheel.support_index_min(self._supported_tags): the first compatible tag in the list wins.
  • Because manylinux2014 came first, pip always chose the manylinux2014 wheel when both manylinux2014 and manylinux_2_28 wheels were compatible.

Solution

Sort the expanded platforms so newer manylinux variants come first, and use this key in _expand_manylinux_platforms() instead of sorted(platforms).

Example

With some print debugging while building xgboost
Before
compute_best_candidate filters manylinux_2_28 out of being the "best candidate"

Candidates for xgboost: [<InstallationCandidate('xgboost', <Version('3.0.1')>, <Link xgboost-3.0.1-py3-none-manylinux2014_x86_64.whl>)>, <InstallationCandidate('xgboost', <Version('3.0.1')>, <Link xgboost-3.0.1-py3-none-manylinux_2_28_x86_64.whl>)>, <InstallationCandidate('xgboost', <Version('3.0.1')>, <Link xgboost-3.0.1.tar.gz>)>]

Best candidate for xgboost: 'xgboost' candidate (version 3.0.1 at xgboost-3.0.1-py3-none-manylinux2014_x86_64.whl)

After
compute_best_candidate chooses manylinux_2_28 as the "best candidate"

Candidates for xgboost: [<InstallationCandidate('xgboost', <Version('3.0.1')>, <Link xgboost-3.0.1-py3-none-manylinux2014_x86_64.whl>)>, <InstallationCandidate('xgboost', <Version('3.0.1')>, <Link xgboost-3.0.1-py3-none-manylinux_2_28_x86_64.whl>)>, <InstallationCandidate('xgboost', <Version('3.0.1')>, <Link xgboost-3.0.1.tar.gz>)>]

Best candidate for xgboost: 'xgboost' candidate (version 3.0.1 at xgboost-3.0.1-py3-none-manylinux_2_28_x86_64.whl)

Note

I'm not sure if something like this covers all edge cases

Use _platform_sort_key() to order platforms: manylinux_2_N_* by
descending N (newest first), then other platforms (linux_, macosx_, etc.).
Use this key in _expand_manylinux_platforms() instead of plain sorted().

Pip orders candidates by version, then: existing installs, wheels (ordered
via Wheel.support_index_min(self._supported_tags)), then source archives
(prefer_binary moves all wheels above sources). Putting the newest manylinux
tag first in the platform list therefore influences which wheel is chosen
via support_index_min(_supported_tags).
@eloisekp eloisekp marked this pull request as ready for review February 10, 2026 23:38
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.

1 participant