@@ -38,6 +38,7 @@ def build_ninja():
3838 # If we are on windows, we don't need to compile ninja, we just download the executable
3939 if os .name == "nt" :
4040 ninja_exe_url = "https://github.com/ninja-build/ninja/releases/download/v1.13.0/ninja-win.zip"
41+ ninja_zip_path = os .path .join (sys .path [0 ], "ninja-win.zip" )
4142
4243 # Try to execute ninja, if it fails, download .exe from github
4344 try :
@@ -48,18 +49,18 @@ def build_ninja():
4849 except OSError :
4950 print ("Downloading ninja ... " )
5051 try :
51- urllib .request .urlretrieve (ninja_exe_url , "ninja-win.zip" )
52- except :
52+ urllib .request .urlretrieve (ninja_exe_url , ninja_zip_path )
53+ except Exception as e :
5354 print (e )
5455 print ("Download of ninja executable failed." )
5556 print ("Get archive at " + ninja_exe_url )
5657 print ("extract ninja.exe in the source code root folder." )
5758 print ("Run meson.py again." )
5859 sys .exit (1 )
5960
60- zipf = zipfile .ZipFile (sys . path [ 0 ] + os . path . sep + "ninja-win.zip" )
61- zipf .extractall (sys .path [0 ])
62- remove_file (sys . path [ 0 ] + os . path . sep + "ninja-win.zip" )
61+ with zipfile .ZipFile (ninja_zip_path ) as zipf :
62+ zipf .extractall (sys .path [0 ])
63+ remove_file (ninja_zip_path )
6364 else :
6465 ninjapath = sys .path [0 ] + os .path .sep + "externals" + os .path .sep + "ninja"
6566 try :
@@ -75,7 +76,10 @@ def build_ninja():
7576 subprocess .run (
7677 ["python3" , "configure.py" , "--bootstrap" ], cwd = ninjapath , env = env
7778 )
78- shutil .copy (ninjapath + os .path .sep + "ninja" , "." )
79+ shutil .copy (
80+ os .path .join (ninjapath , "ninja" ),
81+ os .path .join (sys .path [0 ], "ninja" ),
82+ )
7983
8084
8185def run (
0 commit comments