"""全処理の再実行 (冪等)。 python3 scripts/pipeline.py [--skip-render]"""
import subprocess, sys
from pathlib import Path
S = Path(__file__).resolve().parent
steps = ["ingest.py", "render.py", "layout.py", "jg_markers_from_spec.py", "toyo_cover_notes.py", "segment.py", "crop.py", "transcribe.py", "build_problems.py", "verify/run_all.py", "build_problems.py", "build_catalog.py", "export.py"]
for s in steps:
    if "--skip-render" in sys.argv and s == "render.py": continue
    print("==>", s); r = subprocess.run([sys.executable, str(S / s)], cwd=S)
    if r.returncode != 0: sys.exit(f"失敗: {s}")
print("pipeline done")
