@@ -259,7 +259,6 @@ def library(library_path, output_directory, package_folder_prefix,
259259 filename .relative_to (library_path ).with_suffix (new_extension )
260260 )
261261 temp_filename = ""
262- mpy_success = 1
263262 with tempfile .NamedTemporaryFile (delete = False ) as temp_file :
264263 _munge_to_temp (full_path , temp_file , library_version )
265264
@@ -270,15 +269,17 @@ def library(library_path, output_directory, package_folder_prefix,
270269 "-s" , str (filename .relative_to (library_path )),
271270 temp_file .name
272271 ])
272+ if mpy_success != 0 :
273+ raise RuntimeError ("mpy-cross failed on" , full_path )
273274 temp_filename = temp_file .name
274- if mpy_cross and mpy_success != 0 :
275- raise RuntimeError ("mpy-cross failed on" , full_path )
276275 shutil .copyfile (temp_filename , output_file )
277276 os .remove (temp_filename )
278277
279278 for filename in package_files :
280279 full_path = os .path .join (library_path , filename )
281- with tempfile .NamedTemporaryFile () as temp_file :
280+ temp_filename = ""
281+ output_file = ""
282+ with tempfile .NamedTemporaryFile (delete = False ) as temp_file :
282283 _munge_to_temp (full_path , temp_file , library_version )
283284 if not mpy_cross or os .stat (full_path ).st_size == 0 :
284285 output_file = os .path .join (output_directory ,
@@ -298,8 +299,8 @@ def library(library_path, output_directory, package_folder_prefix,
298299 ])
299300 if mpy_success != 0 :
300301 raise RuntimeError ("mpy-cross failed on" , full_path )
301- if not mpy_cross or os . stat ( full_path ). st_size == 0 :
302- shutil .copyfile (temp_file . name , output_file )
302+ if temp_filename and output_file :
303+ shutil .copyfile (temp_filename , output_file )
303304 os .remove (temp_filename )
304305
305306 requirements_files = lib_path .glob ("requirements.txt*" )
@@ -326,5 +327,5 @@ def library(library_path, output_directory, package_folder_prefix,
326327 with tempfile .NamedTemporaryFile (delete = False ) as temp_file :
327328 _munge_to_temp (full_path , temp_file , library_version )
328329 temp_filename = temp_file .name
329- shutil .copyfile (temp_file . name , output_file )
330+ shutil .copyfile (temp_filename , output_file )
330331 os .remove (temp_filename )
0 commit comments