Skip to content

fix: honor manylinux aliases in graft policy selection - #747

Merged
auvipy merged 2 commits into
pypa:mainfrom
AryanRG:fix/policy-alias-graft-budget
Nov 16, 2026
Merged

auvipy merged 2 commits into
pypa:mainfrom
AryanRG:fix/policy-alias-graft-budget

Conversation

@AryanRG

@AryanRG AryanRG commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

When a wheel needs an external library, requesting a legacy manylinux alias can drop older compatible output tags. For example, --plat manylinux2010_x86_64 omits manylinux1_x86_64 / manylinux_2_5_x86_64 for a compatible wheel, while the equivalent --plat manylinux_2_12_x86_64 includes them.

The requested policy's graft budget currently matches only Policy.name, which contains the canonical name. An alias therefore matches nothing and falls back to zero. Match both the canonical name and Policy.aliases when calculating that budget. The existing maximum graft count and highest-compatible-policy behavior from #649 and the discussion in #690 are preserved.

Adds three regression cases comparing manylinux1, manylinux2010, and manylinux2014 with their canonical policies using the existing cffi wheel. These assert nonempty external dependencies, a nongeneric canonical graft policy, and alias/canonical equivalence. The tests fail on the base and pass with this change. This concerns policy selection before output tags are written; it is separate from the WHEEL metadata normalization in #745.

Validation on Linux with CPython 3.12.15 and patchelf 0.18.0:

  • Unit tests and integration tests excluding tests/integration/test_manylinux.py: 337 passed, 4 skipped on both x86_64 (emulated) and aarch64 (native).
  • Ruff check, Ruff format check, and mypy for both changed files: passed.
  • A generated x86_64 wheel passed six public CLI repairs and loader checks, with equal filename/WHEEL tags for all three alias/canonical pairs.
  • An independent aarch64 probe passed twelve repairs/loaders, alias equivalence, --only-plat, and unsupported-alias rejection. An additional x86_64 whitelist-boundary fixture confirmed the graft-count safeguard.

The full Docker manylinux/musllinux distribution/toolchain/patcher matrix was not run. The complete Python/architecture matrix, distribution-build sessions, and all-repository pre-commit suite were not run locally. These checks remain for upstream CI; current-Debian loader checks do not establish execution on the oldest advertised glibc versions.

AI assistance was used to prepare the implementation and regression tests.

Match canonical policy names and aliases when deriving the requested graft budget. Add regression coverage for the three legacy manylinux aliases.

Prepared with AI assistance, including independent AI technical review.
@auvipy
auvipy self-requested a review October 17, 2026 04:24
@codecov

codecov Bot commented Oct 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.08%. Comparing base (f7828ff) to head (f551f49).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #747   +/-   ##
=======================================
  Coverage   96.08%   96.08%           
=======================================
  Files          23       23           
  Lines        2041     2041           
  Branches      390      390           
=======================================
  Hits         1961     1961           
  Misses         46       46           
  Partials       34       34           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Franky100-pig Franky100-pig left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the two pieces that have to line up here and they do: main_repair.py strips the arch suffix off --plat before passing it as requested_policy_base_name, while _Policy.aliases in policy/__init__.py stores aliases with the arch suffix (manylinux2014_x86_64, etc.). So startswith(f"{base}_") matches legacy aliases and canonical names on the same footing — the fix addresses the real asymmetry.

One scenario the test doesn't cover: a wheel whose external refs span more than one policy, where only the alias-named policy contributes libs. Because graft_lib_count is a min() over the matching refs, a wrong count silently lowers graft_policy rather than erroring, so a regression here would be easy to miss. A test with two bundled wheels (one canonical-named, one alias-named) where the alias one is the limiting factor would give the change stronger protection. Otherwise this is a small, targeted fix and the parametrized alias/canonical equivalence test is a good addition.

@auvipy
auvipy merged commit 7e7bcd6 into pypa:main Nov 16, 2026
3 checks passed
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.

4 participants