@@ -37,7 +37,7 @@ def embed(wheel: Path, sbom: Path) -> None:
3737 for name in contents
3838 if name .endswith (".dist-info/RECORD" ) and name .count ("/" ) == 1
3939 )
40- dist_info = record_name .rsplit ("/" , 1 )[0 ]
40+ dist_info = record_name .split ("/" , 1 )[0 ]
4141
4242 sbom_bytes = sbom .read_bytes ()
4343 sbom_path = f"{ dist_info } /sboms/{ sbom .name } "
@@ -47,14 +47,12 @@ def embed(wheel: Path, sbom: Path) -> None:
4747 lines .append (record_entry (sbom_path , sbom_bytes ))
4848 contents [record_name ] = b"\n " .join (lines ) + b"\n "
4949
50- tmp = wheel .with_name (wheel .name + ".tmp" )
51- with zipfile .ZipFile (tmp , "w" , zipfile .ZIP_DEFLATED ) as zf :
52- # Re-use each original ZipInfo to preserve timestamps, mode bits and
53- # compression; only RECORD's contents change.
54- for info in infos :
55- zf .writestr (info , contents [info .filename ])
56- zf .writestr (sbom_path , sbom_bytes )
57- tmp .replace (wheel )
50+ with zipfile .ZipFile (wheel , "w" , zipfile .ZIP_DEFLATED ) as zf :
51+ # Re-use each original ZipInfo to preserve timestamps, mode bits and
52+ # compression; only RECORD's contents change
53+ for info in infos :
54+ zf .writestr (info , contents [info .filename ])
55+ zf .writestr (sbom_path , sbom_bytes )
5856
5957 print (f"Embedded { sbom .name } in { wheel .name } " )
6058
0 commit comments