#!/usr/bin/env python3 """Create Deflate Level 9 Delivery Package for PROD2U-MIN-20261012.r3.""" import hashlib import os import zipfile from pathlib import Path ROOT = Path("/workspace/cpld-temperature-control") OUT_ZIP = ROOT / "prod2u-final-delivery-20261012.r3.zip" EXCLUDE_DIRS = { ".git", "__pycache__", ".pytest_cache", ".mypy_cache", "scratch", "tmp", } EXCLUDE_EXTS = { ".pyc", ".vvp", ".vpi", } def main(): print(f"Creating {OUT_ZIP} with compression level 9...") if OUT_ZIP.exists(): OUT_ZIP.unlink() file_count = 0 with zipfile.ZipFile(OUT_ZIP, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as zf: for root, dirs, files in os.walk(ROOT): dirs[:] = [d for d in dirs if d not in EXCLUDE_DIRS and not d.startswith(".")] for f in files: if f.endswith(".zip") or any(f.endswith(ext) for ext in EXCLUDE_EXTS): continue path = Path(root) / f rel_path = path.relative_to(ROOT) zf.write(path, arcname=str(rel_path)) file_count += 1 size = OUT_ZIP.stat().st_size sha256 = hashlib.sha256(OUT_ZIP.read_bytes()).hexdigest() print(f"Package created: {OUT_ZIP}") print(f"Files: {file_count}, Size: {size:,} bytes") print(f"SHA-256: {sha256}") # Write package info pkg_info = Path("/workspace/cpld-temperature-control/receipts/PACKAGE-INFO.json") pkg_info.write_text(f'{{\n "package": "{OUT_ZIP.name}",\n "size_bytes": {size},\n "files_count": {file_count},\n "sha256": "{sha256}"\n}}\n') if __name__ == "__main__": main()