_is_win64 = None
def is_win64():
- """Return true if running on windows 64 bits."""
+ """Return true if running on windows 64 bits.
+
+ Works whether python itself runs in 64 bits or 32 bits."""
# 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,
# avoid repeated registry calls.
global _is_win64
if _is_win64 is None:
- try:
- yo = read_reg(r'Software\Wow6432Node')
- except WindowsError:
- yo = None
- _is_win64 = (yo is not None)
+ _is_win64 = has_reg(r"Software\Wow6432Node")
return _is_win64
def read_reg(value):
return SCons.Util.RegGetValue(SCons.Util.HKEY_LOCAL_MACHINE, value)[0]
+def has_reg(value):
+ """Return True if the given key exists in HKEY_LOCAL_MACHINE, False
+ otherwise."""
+ try:
+ SCons.Util.RegOpenKeyEx(SCons.Util.HKEY_LOCAL_MACHINE, value)
+ ret = True
+ except WindowsError:
+ ret = False
+ return ret
# Functions for fetching environment variable settings from batch files.