Skip to content

test(tags): make the test suite pass on musl/Alpine (#850) - #1226

Merged
henryiii merged 1 commit into
pypa:mainfrom
r266-tech:test-musl-alpine-isolation-850
Jun 7, 2026
Merged

henryiii merged 1 commit into
pypa:mainfrom
r266-tech:test-musl-alpine-isolation-850

Conversation

@r266-tech

Copy link
Copy Markdown
Contributor

Fixes the test-suite failures on musl/Alpine reported in #850.

Two independent issues:

  1. _linux_platforms() assertions leak musllinux tags. TestManylinuxPlatform / TestSysTags monkeypatch manylinux/glibc detection and assert exact tag lists with no musllinux_* entries. On a musl host _get_musl_version() returns a real version, so musllinux tags get appended and the == assertions fail. This adds a small shared fixture (applied to both classes via usefixtures) that neutralizes musl detection by default, mirroring the existing monkeypatch.setattr(tags._musllinux, "_get_musl_version", ...) idiom. test_linux_platforms_musllinux re-patches it itself, so it is unaffected.

  2. test_is_manylinux_compatible_old asserts glibc under a Linux-only skip. musl is Linux, but with no glibc _get_glibc_version() returns the (-1, -1) sentinel and _is_compatible("any", _GLibCVersion(2, 0)) is False, so the bare assert fails. The skip is extended to also skip when glibc is absent. It uses the uncached _glibc_version_string() rather than the cached _get_glibc_version() so the marker does not populate the lru_cache at collection time.

Verified locally: simulating a musl host turns 19 of these into failures on main; with the patch they pass, and the normal (glibc/non-musl) run is unchanged.

@brettcannon noted on #850 that it might be worth centralizing the monkeypatching — I kept this minimal and scoped to the two affected classes, but happy to fold it into a broader fixture refactor if you prefer.

@henryiii

henryiii commented Jun 5, 2026 •

Copy link
Copy Markdown
Contributor

Should we add a musl job? (Edit: #1227)

The manylinux platform tests assert exact platform-tag lists and don't
expect musllinux_* entries. On a musl host (Alpine) _get_musl_version()
returns a real version, so musllinux_* tags leak into _linux_platforms()
/ sys_tags() and break the assertions. Neutralize musl detection by
default in TestManylinuxPlatform and TestSysTags via a shared fixture
(test_linux_platforms_musllinux re-patches _get_musl_version itself).

test_is_manylinux_compatible_old is guarded only by a Linux-only skip,
but musl is Linux; with no glibc _is_compatible() returns False and the
assertion fails. Skip it when glibc is absent (uncached probe, so the
marker doesn't populate the _get_glibc_version cache at collection time).
@henryiii
henryiii force-pushed the test-musl-alpine-isolation-850 branch from 2b9f008 to ccf360c Compare June 6, 2026 05:22
@henryiii
henryiii merged commit 4f4d8c3 into pypa:main Jun 7, 2026
58 checks passed
henryiii added a commit to henryiii/packaging that referenced this pull request Jun 7, 2026
Run the test suite inside an Alpine container so the musllinux tag
detection code paths are exercised on a genuinely musl-linked Python.
This provides coverage for the musl/Alpine fixes in pypa#1226.

Assisted-by: ClaudeCode:claude-opus-4.8
henryiii added a commit that referenced this pull request Jun 7, 2026
Run the test suite inside an Alpine container so the musllinux tag
detection code paths are exercised on a genuinely musl-linked Python.
This provides coverage for the musl/Alpine fixes in #1226.

Assisted-by: ClaudeCode:claude-opus-4.8
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