Files
ecs-relay-service/deployment-source/scripts/package_wheels.py
T

26 lines
1.4 KiB
Python

"""Create an optional ARM64 Python dependency bundle, not container base images."""
import argparse
import hashlib
import json
import zipfile
from pathlib import Path
parser = argparse.ArgumentParser()
parser.add_argument("--wheel-directory", type=Path, required=True)
parser.add_argument("--output", type=Path, required=True)
args = parser.parse_args()
wheels = sorted(args.wheel_directory.glob("*.whl"))
if not wheels or any("win_" in x.name or "x86_64" in x.name for x in wheels):
raise SystemExit("expected only ARM64 or platform-independent wheels")
manifest = {p.name: hashlib.sha256(p.read_bytes()).hexdigest() for p in wheels}
with zipfile.ZipFile(args.output, "w", zipfile.ZIP_DEFLATED) as archive:
for path in wheels:
archive.write(path, "wheelhouse/" + path.name)
archive.writestr("wheelhouse/SHA256SUMS.json", json.dumps(manifest, indent=2) + "\n")
archive.writestr("README.txt", "Linux ARM64, CPython 3.12 dependency wheels.\n"
"python -m pip install --no-index --find-links wheelhouse -r hainuo-relay/requirements.lock\n"
"Docker base images are NOT included. ARM64 runtime and kernel compatibility still require target verification.\n")
digest = hashlib.sha256(args.output.read_bytes()).hexdigest()
args.output.with_suffix(".zip.sha256").write_text(digest + "\n", encoding="ascii")
print(json.dumps({"archive": str(args.output), "wheels": len(wheels), "sha256": digest}, ensure_ascii=False))