[issue26544] platform.libc_ver() returns incorrect version number

Nathaniel Smith report at bugs.python.org
Sun Jul 10 02:00:48 EDT 2016


Nathaniel Smith added the comment:

We just ran into this in pip -- https://github.com/pypa/pip/pull/3836

I'd really recommend dropping the current "grovel through the binary doing a regex search" strategy -- it's incredibly error prone, and AFAICT doesn't really give any value. This code OTOH reliably lets you detect glibc and gives the exact version number with no fuss:
   https://github.com/pypa/pip/blob/master/pip/utils/glibc.py#L9

What about non-glibc systems? Unfortunately the current libc_ver() turns out not to work well for those either. Attached is a CSV file showing the return value of ~1.2 billion calls to platform.libc_ver() by the last 6 months of pip users. You can see that the current code basically never returns anything useful for non-glibc platforms. (The one exception is that it seems to be able to detect uclibc 0.9.32 and label it as "libc 0.9.32".)

Don't get me wrong: it'd be really really useful if there were some way to detect and distinguish between the common non-glibc libcs like musl/bionic/uclibc/..., but I'm not sure how to do that -- and unfortunately the current code definitely doesn't do the job :-(.

----------
nosy: +njs
Added file: http://bugs.python.org/file43672/results-20160709-224820.csv

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue26544>
_______________________________________


More information about the Python-bugs-list mailing list