(executable=None, lib='', version='', chunksize=16384)
return lib, version
Tries to determine the libc version that the file executable
        (which defaults to the Python interpreter) is linked against.

        Returns a tuple of strings (lib,version) which default to the
        given parameters in case the lookup fails.

        Note that the function has intimate knowledge of how different
        libc versions add symbols to the executable and thus is probably
        only useable for executables compiled using gcc.

        The file is read and scanned in chunks of chunksize bytes.
Tries to determine the libc version that the file executable
        (which defaults to the Python interpreter) is linked against.
Tries to determine the libc version that the file executable ( which defaults to the Python interpreter ) is linked against .
def libc_ver(executable=None, lib='', version='', chunksize=16384):

    """ Tries to determine the libc version that the file executable
        (which defaults to the Python interpreter) is linked against.

        Returns a tuple of strings (lib,version) which default to the
        given parameters in case the lookup fails.

        Note that the function has intimate knowledge of how different
        libc versions add symbols to the executable and thus is probably
        only useable for executables compiled using gcc.

        The file is read and scanned in chunks of chunksize bytes.

    """
    if not executable:
        try:
            ver = os.confstr('CS_GNU_LIBC_VERSION')
            # parse 'glibc 2.28' as ('glibc', '2.28')
            parts = ver.split(maxsplit=1)
            if len(parts) == 2:
                return tuple(parts)
        except (AttributeError, ValueError, OSError):
            # os.confstr() or CS_GNU_LIBC_VERSION value not available
            pass

        executable = sys.executable

    V = _comparable_version
    if hasattr(os.path, 'realpath'):
        # Python 2.2 introduced os.path.realpath(); it is used
        # here to work around problems with Cygwin not being
        # able to open symlinks for reading
        executable = os.path.realpath(executable)
    with open(executable, 'rb') as f:
        binary = f.read(chunksize)
        pos = 0
        while pos < len(binary):
            if b'libc' in binary or b'GLIBC' in binary:
                m = _libc_search.search(binary, pos)
            else:
                m = None
            if not m or m.end() == len(binary):
                chunk = f.read(chunksize)
                if chunk:
                    binary = binary[max(pos, len(binary) - 1000):] + chunk
                    pos = 0
                    continue
                if not m:
                    break
            libcinit, glibc, glibcversion, so, threads, soversion = [
                s.decode('latin1') if s is not None else s
                for s in m.groups()]
            if libcinit and not lib:
                lib = 'libc'
            elif glibc:
                if lib != 'glibc':
                    lib = 'glibc'
                    version = glibcversion
                elif V(glibcversion) > V(version):
                    version = glibcversion
            elif so:
                if lib != 'glibc':
                    lib = 'libc'
                    if soversion and (not version or V(soversion) > V(version)):
                        version = soversion
                    if threads and version[-len(threads):] != threads:
                        version = version + threads
            pos = m.end()
    return lib, version
def libc_ver ( executable = None , lib = '' , version = '' , chunksize = 16384 ) : if not executable : try : ver = os . confstr ( 'CS_GNU_LIBC_VERSION' ) # parse 'glibc 2.28' as ('glibc', '2.28') parts = ver . split ( maxsplit = 1 ) if len ( parts ) == 2 : return tuple ( parts ) except ( AttributeError , ValueError , OSError ) : # os.confstr() or CS_GNU_LIBC_VERSION value not available pass executable = sys . executable V = _comparable_version if hasattr ( os . path , 'realpath' ) : # Python 2.2 introduced os.path.realpath(); it is used # here to work around problems with Cygwin not being # able to open symlinks for reading executable = os . path . realpath ( executable ) with open ( executable , 'rb' ) as f : binary = f . read ( chunksize ) pos = 0 while pos < len ( binary ) : if b'libc' in binary or b'GLIBC' in binary : m = _libc_search . search ( binary , pos ) else : m = None if not m or m . end ( ) == len ( binary ) : chunk = f . read ( chunksize ) if chunk : binary = binary [ max ( pos , len ( binary ) - 1000 ) : ] + chunk pos = 0 continue if not m : break libcinit , glibc , glibcversion , so , threads , soversion = [ s . decode ( 'latin1' ) if s is not None else s for s in m . groups ( ) ] if libcinit and not lib : lib = 'libc' elif glibc : if lib != 'glibc' : lib = 'glibc' version = glibcversion elif V ( glibcversion ) > V ( version ) : version = glibcversion elif so : if lib != 'glibc' : lib = 'libc' if soversion and ( not version or V ( soversion ) > V ( version ) ) : version = soversion if threads and version [ - len ( threads ) : ] != threads : version = version + threads pos = m . end ( ) return lib , version