platformutils.py (2297B)
1 #Embedded file name: C:\BuildAgent\work\20d73f1b24eed06e\eve\release\V24.01\packages\brennivin\platformutils.py 2 import os as _os 3 import struct as _struct 4 import sys as _sys 5 try: 6 import multiprocessing as _multiprocessing 7 except ImportError: 8 _multiprocessing = None 9 10 from .dochelpers import ignore as _ignore 11 EXE_MAYA = 'Maya Python' 12 EXE_MAYA27 = 'Maya Python 2.7' 13 EXE_EXEFILE = 'Exefile Python' 14 EXE_VANILLA26 = 'Pure Python 2.6' 15 EXE_VANILLA27 = 'Pure Python 2.7' 16 17 def get_interpreter_flavor(_exepath = _ignore, _vinfo = _ignore): 18 _exepath = _exepath or _sys.executable 19 _vinfo = _vinfo or _sys.version_info 20 21 def getType(path): 22 path = path.lower().replace('_debug.exe', '.exe').replace('_internal.exe', '.exe') 23 if path.endswith(('exefile.exe', 'exefileconsole.exe')): 24 return EXE_EXEFILE 25 if path.endswith(('maya.exe', 'mayabatch.exe', 'mayapy.exe')): 26 if _vinfo[1] == 6: 27 return EXE_MAYA 28 if _vinfo[1] == 7: 29 return EXE_MAYA27 30 if path.endswith(('python.exe', 'pythonw.exe', 'python')): 31 try: 32 import stackless 33 return EXE_EXEFILE 34 except ImportError: 35 if _vinfo[1] == 6: 36 return EXE_VANILLA26 37 if _vinfo[1] == 7: 38 return EXE_VANILLA27 39 40 raise NameError("Could not identify executable path '%s'" % path) 41 42 return getType(_exepath) 43 44 45 def is_64bit_windows(): 46 return 'PROGRAMFILES(x86)' in _os.environ 47 48 49 def is_64bit_process(_structmod = _ignore): 50 _structmod = _structmod or _struct 51 size = _structmod.calcsize('P') 52 if size == 8: 53 return True 54 if size == 4: 55 return False 56 raise OSError('Could not determine process architecture for %s' % size) 57 58 59 def cpu_count(_multiprocmod = _ignore): 60 _multiprocmod = _multiprocmod or _multiprocessing 61 if _multiprocessing: 62 try: 63 return _multiprocmod.cpu_count() 64 except (NotImplementedError, AttributeError): 65 pass 66 67 try: 68 res = int(_os.environ['NUMBER_OF_PROCESSORS']) 69 if res > 0: 70 return res 71 except (KeyError, ValueError): 72 pass 73 74 raise SystemError('Number of processors could not be determined.')