Skip to content

Commit 531f6cf

Browse files
committed
make Penpot paper exports deterministic
1 parent b515edd commit 531f6cf

1 file changed

Lines changed: 18 additions & 3 deletions

File tree

‎figures/penpot/install_exports.py‎

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
from __future__ import annotations
55

66
import shutil
7-
import subprocess
8-
import sys
97
from pathlib import Path
108

119
ROOT = Path(__file__).resolve().parents[2]
@@ -16,6 +14,23 @@
1614
ALTERNATIVES = ROOT / "figures" / "alternatives"
1715

1816

17+
def verify_frozen_exports() -> None:
18+
"""Require portable, already-normalized Penpot exports.
19+
20+
Normalization is an explicit authoring step because PDF/PNG renderers can
21+
produce byte-level differences across platforms. Paper reproduction copies
22+
the frozen exports verbatim instead of rerendering them in CI.
23+
"""
24+
for svg_path in sorted(EXPORTS.glob("fig1_variant_*.svg")):
25+
svg = svg_path.read_text(encoding="utf-8")
26+
if 'width="180mm"' not in svg or 'height="112mm"' not in svg:
27+
raise RuntimeError(
28+
f"Penpot export is not normalized to publication size: {svg_path}"
29+
)
30+
if "http://localhost:9001" in svg:
31+
raise RuntimeError(f"Unresolved local Penpot URL in {svg_path}")
32+
33+
1934
def copy_triplet(stem: str, destination: Path) -> None:
2035
destination.mkdir(parents=True, exist_ok=True)
2136
for suffix in ("svg", "pdf", "png"):
@@ -26,7 +41,7 @@ def copy_triplet(stem: str, destination: Path) -> None:
2641

2742

2843
def main() -> None:
29-
subprocess.run([sys.executable, str(PENPOT / "normalize_exports.py")], check=True)
44+
verify_frozen_exports()
3045

3146
selected = "fig1_variant_C_balanced"
3247
copy_triplet(selected, MAIN)

0 commit comments

Comments
 (0)