#!/usr/bin/env python3 """Export Hermes dependencies without attempting to build Hermes itself.""" from __future__ import annotations import re import sys import tomllib from pathlib import Path def main() -> None: document = tomllib.loads(Path(sys.argv[1]).read_text(encoding="utf-8")) project = document["project"] optional = project.get("optional-dependencies", {}) pending = list(project.get("dependencies", [])) + list(optional.get("all", [])) emitted: set[str] = set() while pending: requirement = pending.pop(0) match = re.fullmatch(r"hermes-agent(?:\[([^]]+)\])?", requirement.strip()) if match: extras = [item.strip() for item in (match.group(1) or "").split(",") if item.strip()] for extra in extras: if extra not in optional: raise SystemExit(f"Unknown Hermes extra: {extra}") pending[:0] = optional[extra] continue if requirement not in emitted: print(requirement) emitted.add(requirement) if __name__ == "__main__": main()