views:

99

answers:

1

We have this code, but it doesn't work any more:

def get_vcvarsall(generator):
 value = None
 type = None
 key_name = r'SOFTWARE\Microsoft\VisualStudio\SxS\VC7'
 key = _winreg.OpenKey(_winreg.HKEY_LOCAL_MACHINE, key_name)
 if generator.startswith('Visual Studio 8'):
  value,type = _winreg.QueryValueEx(key, '8.0')
 elif generator.startswith('Visual Studio 9'):
  value,type = _winreg.QueryValueEx(key, '9.0')
 elif generator.startswith('Visual Studio 10'):
  value,type = _winreg.QueryValueEx(key, '10.0')
 else:
  raise Exception('Cannot determin vcvarsall.bat location for: ' + generator)
 path = value + 'vcvarsall.bat'
 if not os.path.exists(path):
  raise Exception("'%s' not found.")
 return path

This seems to have stopped working since I upgraded to Python 2.6 x64 from x86 (but I can't be sure). Could have been upgrading to Win7 that caused the problem.

+1  A: 

It's the x64 part.

Since Visual Studio is a 32-bit application, it's registry entries get shoved in the 32-bit WoW dungeon. You'll want to look in

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\SxS\VS7

Note that if you run Python as a 32-bit executable, it'll get redirected as well -- so everything "just works". It's only when you look for 32-bit information from a 64-bit application or vice versa that you run into problems.

Stu
Nice, thanks - I assume this key would not work for 32-bit Windows?
nbolton
Correct, Wow6432Node will not be there.
Stu