Author vstinner
Recipients vstinner
Date 2018-12-03.16:02:13
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Currently, platform.libc_ver() opens Python binary file (ex: /usr/bin/python3) and looks for a string like "GLIBC-2.28".

Maybe gnu_get_libc_version() should be exposed in Python to get the version of the running glibc version? And use it if available, or fall back on parsing the binary file (as done currenetly) otherwise.


$ cat x.c 
#include <gnu/libc-version.h>
#include <stdlib.h>
#include <stdio.h>

main(int argc, char *argv[])
    printf("GNU libc version: %s\n", gnu_get_libc_version());
    printf("GNU libc release: %s\n", gnu_get_libc_release());

$ ./x
GNU libc version: 2.28
GNU libc release: stable

I'm not sure if it's possible that Python is compiled with glibc but run with a different libc implementation?


Alternative: run a program to get the libc version which *might* be different than the libc version of Python if the libc is upgraded in the meanwhile (unlikely, but is technically possible on a server running for days):

$ ldd --version
ldd (GNU libc) 2.28

$ /lib64/ 
GNU C Library (GNU libc) stable release version 2.28.

$ rpm -q glibc



See also discussions on platform.libc_ver() performance:
Date User Action Args
2018-12-03 16:02:13vstinnersetrecipients: + vstinner
2018-12-03 16:02:13vstinnersetmessageid: <>
2018-12-03 16:02:13vstinnerlinkissue35389 messages
2018-12-03 16:02:13vstinnercreate