New submission from STINNER Victor <[email protected]>:
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.
Example:
$ cat x.c
#include <gnu/libc-version.h>
#include <stdlib.h>
#include <stdio.h>
int
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());
exit(EXIT_SUCCESS);
}
$ ./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/libc.so.6
GNU C Library (GNU libc) stable release version 2.28.
...
$ rpm -q glibc
glibc-2.28-17.fc29.x86_64
...
etc.
--
See also discussions on platform.libc_ver() performance:
https://github.com/python/cpython/pull/10868
----------
components: Library (Lib)
messages: 330952
nosy: vstinner
priority: normal
severity: normal
status: open
title: Use gnu_get_libc_version() in platform.libc_ver()?
versions: Python 3.8
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue35389>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com