Repository navigation
platform.libc_ver() returns no information on Alpine Linux #87414
Description
Activity
When calling platform.libc_ver() on Alpine I get the following tuple: ('', '')
Instead, I expect to get ('muslc', '<version number>') or an exception if the libc type & version cannot be detected.
If one of them is not detected, the returned value shouldn't be an empty string but None.
The current API is not what most people would expect it to be.
This is verified on Python 3.8 since that's the latest one available on Alpine.This code reliably detects musl libc and its version: https://github.com/lovell/detect-libc/blob/master/lib/detect-libc.js
I'd be happy to contribute a PR if needed.
@Omer.Katz
This issue should be fixed, feel free to submit the PR
Any progress on this? Is there any other function to check whether the host system is using musl or glibc?
How about just integrating packaging's musl detection code into the standard library?
https://github.com/pypa/packaging/blob/main/src/packaging/_musllinux.py(Actually, I'm a bit surprised this wasn't done directly on the implementation of PEP 656.)
Reacted by Manuel Kaufmann- addedstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
on Dec 1, 2023 - added a commit that references this issue
on Oct 30, 2024 - added a commit that references this issue
on Apr 15, 2025 This issue also causes
platform.platform()to return a nonsensical output:Linux-6.15.6-0-stable-x86_64-with(The-withdoesn't makes sense whenlibcname+libcversionis empty)Edit: tested a version without #131313 , probably works fine with
~/cpython $ ./python Python 3.15.0a0 (heads/main:c117b03, Sep 6 2025, 22:03:51) [GCC 14.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import platform >>> platform.platform() 'Linux-6.15.10-200.fc42.x86_64-x86_64-with-musl1.2.5' >>> platform.libc_ver() ('musl', '1.2.5')Reacted by mara004
Metadata
Metadata
Assignees
Labels
Projects
- StatusShow more project fieldsDone
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
Linked PRs