Format: text/x-python
⬇ Download File (1.0 KB)
   1  """is64bit.Python() --> boolean value of detected Python word size. is64bit.os() --> os build version"""
   2  
   3  import sys
   4  
   5  
   6  def Python():
   7      return sys.maxsize > 2147483647
   8  
   9  
  10  def os():
  11      import platform
  12  
  13      pm = platform.machine()
  14      if pm != ".." and pm.endswith("64"):  # recent 64 bit Python
  15          return True
  16      else:
  17          import os
  18  
  19          if "PROCESSOR_ARCHITEW6432" in os.environ:
  20              return True  # 32 bit program running on 64 bit Windows
  21          try:
  22              return os.environ["PROCESSOR_ARCHITECTURE"].endswith(
  23                  "64"
  24              )  # 64 bit Windows 64 bit program
  25          except (IndexError, KeyError):
  26              pass  # not Windows
  27          try:
  28              return "64" in platform.architecture()[0]  # this often works in Linux
  29          except:
  30              return False  # is an older version of Python, assume also an older os (best we can guess)
  31  
  32  
  33  if __name__ == "__main__":
  34      print("is64bit.Python() =", Python(), "is64bit.os() =", os())
  35