def _FindDirectXInstallation():
 if hasattr(_FindDirectXInstallation, 'dxsdk_dir'):
  return _FindDirectXInstallation.dxsdk_dir
 dxsdk_dir = os.environ.get('DXSDK_DIR')
 if (not dxsdk_dir):
  cmd = ['reg.exe', 'query', 'HKLM\\Software\\Microsoft\\DirectX', '/s']
  p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
  for line in p.communicate()[0].splitlines():
   if ('InstallPath' in line):
    dxsdk_dir = (line.split('    ')[3] + '\\')
 _FindDirectXInstallation.dxsdk_dir = dxsdk_dir
 return dxsdk_dir

def _FindDirectXInstallation ( ) : if hasattr ( _FindDirectXInstallation , 'dxsdk_dir' ) : return _FindDirectXInstallation . dxsdk_dir dxsdk_dir = os . environ . get ( 'DXSDK_DIR' ) if ( not dxsdk_dir ) : cmd = [ 'reg.exe' , 'query' , 'HKLM\\Software\\Microsoft\\DirectX' , '/s' ] p = subprocess . Popen ( cmd , stdout = subprocess . PIPE , stderr = subprocess . PIPE ) for line in p . communicate ( ) [ 0 ] . splitlines ( ) : if ( 'InstallPath' in line ) : dxsdk_dir = ( line . split ( '    ' ) [ 3 ] + '\\' ) _FindDirectXInstallation . dxsdk_dir = dxsdk_dir return dxsdk_dir
try to find an installation location for the directx sdk .