MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / architecture

Function architecture

tools/python-3.11.9-amd64/Lib/platform.py:646–719  ·  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

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

Source from the content-addressed store, hash-verified

644}
645
646def architecture(executable=sys.executable, bits='', linkage=''):
647
648 """ Queries the given executable (defaults to the Python interpreter
649 binary) for various architecture information.
650
651 Returns a tuple (bits, linkage) which contains information about
652 the bit architecture and the linkage format used for the
653 executable. Both values are returned as strings.
654
655 Values that cannot be determined are returned as given by the
656 parameter presets. If bits is given as '', the sizeof(pointer)
657 (or sizeof(long) on Python version < 1.5.2) is used as
658 indicator for the supported pointer size.
659
660 The function relies on the system&#x27;s "file" command to do the
661 actual work. This is available on most if not all Unix
662 platforms. On some non-Unix platforms where the "file" command
663 does not exist and the executable is set to the Python interpreter
664 binary defaults from _default_architecture are used.
665
666 """
667 # Use the sizeof(pointer) as default number of bits if nothing
668 # else is given as default.
669 if not bits:
670 import struct
671 size = struct.calcsize('P')
672 bits = str(size * 8) + 'bit'
673
674 # Get data from the 'file' system command
675 if executable:
676 fileout = _syscmd_file(executable, '')
677 else:
678 fileout = ''
679
680 if not fileout and \
681 executable == sys.executable:
682 # "file" command did not return anything; we'll try to provide
683 # some sensible defaults then...
684 if sys.platform in _default_architecture:
685 b, l = _default_architecture[sys.platform]
686 if b:
687 bits = b
688 if l:
689 linkage = l
690 return bits, linkage
691
692 if 'executable' not in fileout and 'shared object' not in fileout:
693 # Format not supported
694 return bits, linkage
695
696 # Bits
697 if '32-bit' in fileout:
698 bits = '32bit'
699 elif '64-bit' in fileout:
700 bits = '64bit'
701
702 # Linkage
703 if 'ELF' in fileout:

Callers 2

help_about.pyFile · 0.90
platformFunction · 0.85

Calls 2

strFunction · 0.85
_syscmd_fileFunction · 0.85

Tested by

no test coverage detected