MCPcopy Index your code
hub / github.com/RustPython/RustPython / architecture

Function architecture

Lib/platform.py:759–834  ·  view source on GitHub ↗

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 retur

(executable=sys.executable, bits='', linkage='')

Source from the content-addressed store, hash-verified

757}
758
759def architecture(executable=sys.executable, bits='', linkage=''):
760
761 """ Queries the given executable (defaults to the Python interpreter
762 binary) for various architecture information.
763
764 Returns a tuple (bits, linkage) which contains information about
765 the bit architecture and the linkage format used for the
766 executable. Both values are returned as strings.
767
768 Values that cannot be determined are returned as given by the
769 parameter presets. If bits is given as '', the sizeof(pointer)
770 (or sizeof(long) on Python version < 1.5.2) is used as
771 indicator for the supported pointer size.
772
773 The function relies on the system&#x27;s "file" command to do the
774 actual work. This is available on most if not all Unix
775 platforms. On some non-Unix platforms where the "file" command
776 does not exist and the executable is set to the Python interpreter
777 binary defaults from _default_architecture are used.
778
779 """
780 # Use the sizeof(pointer) as default number of bits if nothing
781 # else is given as default.
782 if not bits:
783 import struct
784 size = struct.calcsize('P')
785 bits = str(size * 8) + 'bit'
786
787 # Get data from the 'file' system command
788 if executable:
789 fileout = _syscmd_file(executable, '')
790 else:
791 fileout = ''
792
793 if not fileout and \
794 executable == sys.executable:
795 # "file" command did not return anything; we'll try to provide
796 # some sensible defaults then...
797 if sys.platform in _default_architecture:
798 b, l = _default_architecture[sys.platform]
799 if b:
800 bits = b
801 if l:
802 linkage = l
803 return bits, linkage
804
805 if 'executable' not in fileout and 'shared object' not in fileout:
806 # Format not supported
807 return bits, linkage
808
809 # Bits
810 if '32-bit' in fileout:
811 bits = '32bit'
812 elif '64-bit' in fileout:
813 bits = '64bit'
814
815 # Linkage
816 if 'ELF' in fileout:

Callers 1

platformFunction · 0.85

Calls 2

strFunction · 0.85
_syscmd_fileFunction · 0.85

Tested by

no test coverage detected