@@ -45,7 +45,7 @@ def implFindMsvcUpTo2015() -> typing.List[MsvcInstall]:
4545 valueName = "InstallDir"
4646 key = keyTemplate .replace ("__VERSION__" , version )
4747 installDir = env_utils .readRegistryValueLocalMachine (key , valueName )
48- if installDir is not None :
48+ if installDir is not None and os . path . isdir ( installDir ) :
4949 result .append (MsvcInstall (version , installDir ))
5050 return result
5151
@@ -67,10 +67,12 @@ def findMsvc() -> typing.List[MsvcInstall]:
6767def implfindClExesForOldMsvc (msvcInstall : MsvcInstall ) -> typing .List [ClInfo ]:
6868 result = []
6969 mainClPath = env_utils .dirNameAbsolute (msvcInstall .installDir + "\\ ..\\ ..\\ vc\\ bin" )
70+ if not os .path .isdir (mainClPath ):
71+ return []
7072 subDirs = env_utils .listSubdirs (mainClPath , appendFolder = False ) + ["." ]
7173 def hasClExe (subdir ):
7274 return os .path .isfile (mainClPath + "\\ " + subdir + "\\ cl.exe" )
73- dirsWithCl = [ dir for dir in subDirs if hasClExe (dir )]
75+ dirsWithCl = [dir for dir in subDirs if hasClExe (dir )]
7476 # dirWithCl is something like
7577 # ['amd64', 'amd64_arm', 'amd64_x86', 'x86_amd64', 'x86_arm', '.']
7678 # in this ist : "." = x86_x86 and amd64 = amd64_amd64
@@ -86,14 +88,14 @@ def hasClExe(subdir):
8688 tokens = dirWithCl .split ("_" )
8789 hostArch = tokens [0 ]
8890 targetArch = tokens [1 ]
89- result .append ( ClInfo (msvcInstall , fullDir , hostArch , targetArch ) )
91+ result .append (ClInfo (msvcInstall , fullDir , hostArch , targetArch ) )
9092 return result
9193
9294
9395def implfindClExesForMsvc2017 (msvcInstall : MsvcInstall ) -> typing .List [ClInfo ]:
9496 result = []
9597 topDir = msvcInstall .installDir + "\\ VC\\ Tools\\ MSVC"
96- for dirpath , dirnames , filenames in os .walk (topDir ):
98+ for dirpath , _ , filenames in os .walk (topDir ):
9799 for file in filenames :
98100 if file == "cl.exe" :
99101 # dirpath looks like
@@ -120,14 +122,14 @@ def findClExesList() -> typing.List[ClInfo]:
120122
121123def printClList (clInfoList : typing .List [ClInfo ]) -> str :
122124 def clInfoToData (clInfo : ClInfo ):
123- return [clInfo .msvcInstall .version , clInfo .targetArch ,
125+ return [clInfo .msvcInstall .version , clInfo .targetArch ,
124126 clInfo .hostArch , env_utils .shortDirectoryName (clInfo .installDir )]
125127 headers = ["#" , "version" , "targetArch" , "hostArch" , "folder (shortened)" ]
126128 data = [clInfoToData (clInfo ) for clInfo in clInfoList ]
127129 rowFormat = "{:>4}{:>18}{:>11}{:>11}{:>80}"
128130
129131 print (rowFormat .format (* headers ))
130- id = 1
132+ rowId = 1
131133 for version in data :
132- print (rowFormat .format (id , * version ))
133- id = id + 1
134+ print (rowFormat .format (rowId , * version ))
135+ rowId = rowId + 1
0 commit comments