From: garyo Date: Mon, 11 Jan 2010 01:38:00 +0000 (+0000) Subject: Fix #2515: use better way to detect 64-bit OS. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=71e77af7d11797cc24e18752e9f893c787145014;p=scons.git Fix #2515: use better way to detect 64-bit OS. git-svn-id: http://scons.tigris.org/svn/scons/trunk@4601 fdb21ef1-2011-0410-befe-b5e4ea1792b1 --- diff --git a/src/engine/SCons/Tool/MSCommon/common.py b/src/engine/SCons/Tool/MSCommon/common.py index 017892cf..bb13e9b2 100644 --- a/src/engine/SCons/Tool/MSCommon/common.py +++ b/src/engine/SCons/Tool/MSCommon/common.py @@ -60,12 +60,27 @@ def is_win64(): # Unfortunately, python does not provide a useful way to determine # if the underlying Windows OS is 32-bit or 64-bit. Worse, whether # the Python itself is 32-bit or 64-bit affects what it returns, - # so nothing in sys.* or os.* help. So we go to the registry to - # look directly for a clue from Windows, caching the result to - # avoid repeated registry calls. + # so nothing in sys.* or os.* help. + + # Apparently the best solution is to use env vars that Windows + # sets. If PROCESSOR_ARCHITECTURE is not x86, then the python + # process is running in 64 bit mode (on a 64-bit OS, 64-bit + # hardware, obviously). + # If this python is 32-bit but the OS is 64, Windows will set + # ProgramW6432 and PROCESSOR_ARCHITEW6432 to non-null. + # (Checking for HKLM\Software\Wow6432Node in the registry doesn't + # work, because some 32-bit installers create it.) global _is_win64 if _is_win64 is None: - _is_win64 = has_reg(r"Software\Wow6432Node") + # I structured these tests to make it easy to add new ones or + # add exceptions in the future, because this is a bit fragile. + _is_win64 = False + if os.environ.get('PROCESSOR_ARCHITECTURE','x86') != 'x86': + _is_win64 = True + if os.environ.get('PROCESSOR_ARCHITEW6432'): + _is_win64 = True + if os.environ.get('ProgramW6432'): + _is_win64 = True return _is_win64