Download make_zip.py from benchflow/frontierphysics-icecube-pointsource-unbinned: direct link, hf CLI and curl.
- Browser
- Download file 1.23 kB
-
https://huggingface.co/datasets/benchflow/frontierphysics-icecube-pointsource-unbinned/resolve/main/make_zip.py
- Command line
-
hf download hf://datasets/benchflow/frontierphysics-icecube-pointsource-unbinned/make_zip.py
-
curl -L -o make_zip.py https://huggingface.co/datasets/benchflow/frontierphysics-icecube-pointsource-unbinned/resolve/main/make_zip.py
1.23 kB
| """Build a deterministic zip of the verified IceCube release directory. | |
| usage: python3 -I make_zip.py <release_dir> <out.zip> <manifest.sha256> | |
| Entries: every file listed in the manifest, sorted, fixed timestamp, mode 0644. | |
| """ | |
| import hashlib, sys, zipfile | |
| from pathlib import Path | |
| src, out, manifest = Path(sys.argv[1]), Path(sys.argv[2]), Path(sys.argv[3]) | |
| want = {} | |
| for line in manifest.read_text().splitlines(): | |
| digest, name = line.split(None, 1) | |
| want[name.strip().removeprefix("./")] = digest | |
| on_disk = sorted(str(p.relative_to(src)) for p in src.rglob("*") if p.is_file()) | |
| assert on_disk == sorted(want), (set(on_disk) ^ set(want)) | |
| with zipfile.ZipFile(out, "w", compression=zipfile.ZIP_DEFLATED, compresslevel=9) as zf: | |
| for name in sorted(want): | |
| data = (src / name).read_bytes() | |
| assert hashlib.sha256(data).hexdigest() == want[name], name | |
| info = zipfile.ZipInfo(name, date_time=(2021, 1, 26, 0, 0, 0)) | |
| info.compress_type = zipfile.ZIP_DEFLATED | |
| info.external_attr = 0o100644 << 16 | |
| info.create_system = 3 | |
| zf.writestr(info, data, compress_type=zipfile.ZIP_DEFLATED, compresslevel=9) | |
| print(out, out.stat().st_size, hashlib.sha256(out.read_bytes()).hexdigest()) | |