from __future__ import annotations
import sys
import zipfile
from pathlib import Path
EXPECTED = {
"spget",
"spput",
"spmonitor",
"spinfo",
"splist",
"spexplore",
"spsearch",
"spsine",
"spget_compare",
"spserver",
"sptable",
"spdodeca",
}
def scripts_in(wheel: Path) -> set[str]:
names = set()
with zipfile.ZipFile(wheel) as zf:
for entry in zf.namelist():
parts = entry.split("/")
if len(parts) == 3 and parts[0].endswith(".data") and parts[1] == "scripts":
if parts[2]:
names.add(Path(parts[2]).stem)
return names
def main() -> int:
if len(sys.argv) != 2:
print(__doc__, file=sys.stderr)
return 2
dist = Path(sys.argv[1])
wheels = sorted(dist.glob("*.whl"))
if not wheels:
print(f"no wheel found in {dist}", file=sys.stderr)
return 1
failed = False
for wheel in wheels:
found = scripts_in(wheel)
missing = EXPECTED - found
if missing:
failed = True
print(
f"{wheel.name}: missing {len(missing)} of {len(EXPECTED)} tools: "
f"{', '.join(sorted(missing))}",
file=sys.stderr,
)
continue
extra = found - EXPECTED
note = f" (plus {', '.join(sorted(extra))})" if extra else ""
print(f"{wheel.name}: all {len(EXPECTED)} tools present{note}")
return 1 if failed else 0
if __name__ == "__main__":
sys.exit(main())