(executable=sys.executable, bits='', linkage='')
return bits, linkage
Queries the given executable (defaults to the Python interpreter
        binary) for various architecture information.

        Returns a tuple (bits, linkage) which contains information about
        the bit architecture and the linkage format used for the
        executable. Both values are returned as strings.

        Values that cannot be determined are returned as given by the
        parameter presets. If bits is given as '', the sizeof(pointer)
        (or sizeof(long) on Python version < 1.5.2) is used as
        indicator for the supported pointer size.

        The function relies on the system's "file" command to do the
        actual work. This is available on most if not all Unix
        platforms. On some non-Unix platforms where the "file" command
        does not exist and the executable is set to the Python interpreter
        binary defaults from _default_architecture are used.
Queries the given executable (defaults to the Python interpreter
        binary) for various architecture information.
Queries the given executable ( defaults to the Python interpreter binary ) for various architecture information .
def architecture(executable=sys.executable, bits='', linkage=''):

    """ Queries the given executable (defaults to the Python interpreter
        binary) for various architecture information.

        Returns a tuple (bits, linkage) which contains information about
        the bit architecture and the linkage format used for the
        executable. Both values are returned as strings.

        Values that cannot be determined are returned as given by the
        parameter presets. If bits is given as '', the sizeof(pointer)
        (or sizeof(long) on Python version < 1.5.2) is used as
        indicator for the supported pointer size.

        The function relies on the system's "file" command to do the
        actual work. This is available on most if not all Unix
        platforms. On some non-Unix platforms where the "file" command
        does not exist and the executable is set to the Python interpreter
        binary defaults from _default_architecture are used.

    """
    # Use the sizeof(pointer) as default number of bits if nothing
    # else is given as default.
    if not bits:
        import struct
        size = struct.calcsize('P')
        bits = str(size * 8) + 'bit'

    # Get data from the 'file' system command
    if executable:
        fileout = _syscmd_file(executable, '')
    else:
        fileout = ''

    if not fileout and \
       executable == sys.executable:
        # "file" command did not return anything; we'll try to provide
        # some sensible defaults then...
        if sys.platform in _default_architecture:
            b, l = _default_architecture[sys.platform]
            if b:
                bits = b
            if l:
                linkage = l
        return bits, linkage

    if 'executable' not in fileout and 'shared object' not in fileout:
        # Format not supported
        return bits, linkage

    # Bits
    if '32-bit' in fileout:
        bits = '32bit'
    elif '64-bit' in fileout:
        bits = '64bit'

    # Linkage
    if 'ELF' in fileout:
        linkage = 'ELF'
    elif 'PE' in fileout:
        # E.g. Windows uses this format
        if 'Windows' in fileout:
            linkage = 'WindowsPE'
        else:
            linkage = 'PE'
    elif 'COFF' in fileout:
        linkage = 'COFF'
    elif 'MS-DOS' in fileout:
        linkage = 'MSDOS'
    else:
        # XXX the A.OUT format also falls under this class...
        pass

    return bits, linkage
def architecture ( executable = sys . executable , bits = '' , linkage = '' ) : # Use the sizeof(pointer) as default number of bits if nothing # else is given as default. if not bits : import struct size = struct . calcsize ( 'P' ) bits = str ( size * 8 ) + 'bit' # Get data from the 'file' system command if executable : fileout = _syscmd_file ( executable , '' ) else : fileout = '' if not fileout and executable == sys . executable : # "file" command did not return anything; we'll try to provide # some sensible defaults then... if sys . platform in _default_architecture : b , l = _default_architecture [ sys . platform ] if b : bits = b if l : linkage = l return bits , linkage if 'executable' not in fileout and 'shared object' not in fileout : # Format not supported return bits , linkage # Bits if '32-bit' in fileout : bits = '32bit' elif '64-bit' in fileout : bits = '64bit' # Linkage if 'ELF' in fileout : linkage = 'ELF' elif 'PE' in fileout : # E.g. Windows uses this format if 'Windows' in fileout : linkage = 'WindowsPE' else : linkage = 'PE' elif 'COFF' in fileout : linkage = 'COFF' elif 'MS-DOS' in fileout : linkage = 'MSDOS' else : # XXX the A.OUT format also falls under this class... pass return bits , linkage