Skip to content

Commit a55a923

Browse files
committed
self reviewed
1 parent bac3e80 commit a55a923

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

circuitpython_build_tools/build.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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)

circuitpython_build_tools/scripts/build_bundles.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ def build_bundles(filename_prefix, output_directory, library_location, library_d
257257
mpy_cross = pkg_resources.resource_filename(
258258
target_versions.__name__, "data/mpy-cross-" + version["name"])
259259
else:
260-
mpy_cross = "build_deps/mpy-cross-" + version["name"]
260+
mpy_cross = "build_deps/mpy-cross-" + version["name"] + (".exe" * (os.name == "nt"))
261261
build.mpy_cross(mpy_cross, version["tag"])
262262
zip_filename = os.path.join(output_directory,
263263
filename_prefix + '-{TAG}-mpy-{VERSION}.zip'.format(

0 commit comments

Comments
 (0)