Script: build.py
Hodge: source and evidence
build.py
This is the original source text. Reading it does not run or verify the program.
1 """Build the Hodge monograph and its companion visual guide."""
2 from pathlib import Path
3 import argparse
4 import shutil
5 import subprocess
6 import sys
7
8 ROOT = Path(__file__).resolve().parent
9 parser = argparse.ArgumentParser()
10 parser.add_argument('--figures', action='store_true')
11 parser.add_argument('--only', choices=['paper', 'visual'])
12 args = parser.parse_args()
13 if args.figures:
14 subprocess.run([sys.executable, str(ROOT / 'visual/figures.py')], check=True)
15 names = {
16 'paper': 'Komorebi_Hodge_Conjecture_Piece_v1.0.pdf',
17 'visual': 'Komorebi_Hodge_Visual_Guide_v1.0.pdf',
18 }
19 (ROOT / 'pdf').mkdir(exist_ok=True)
20 for project in ([args.only] if args.only else names):
21 folder = ROOT / project
22 for pass_index in range(5):
23 proc = subprocess.run(
24 ['pdflatex', '-interaction=nonstopmode', '-halt-on-error', 'main.tex'],
25 cwd=folder, capture_output=True,
26 )
27 (folder / 'build_stdout.log').write_bytes(proc.stdout + proc.stderr)
28 if proc.returncode:
29 print(proc.stdout[-7000:].decode('utf-8', errors='replace'), file=sys.stderr)
30 raise SystemExit(proc.returncode)
31 log = (folder / 'main.log').read_text(errors='replace')
32 needs_another_pass = ('Label(s) may have changed' in log or
33 'Rerun to get' in log or
34 'Please rerun' in log)
35 if pass_index >= 1 and not needs_another_pass:
36 break
37 else:
38 raise SystemExit(f'References did not stabilize after five passes: {project}')
39 target = ROOT / 'pdf' / names[project]
40 shutil.copyfile(folder / 'main.pdf', target)
41 print(target)
Other PDFs for this work
Original file and source record
This copy matches the recorded source file. Its publication here does not change the work’s review status.
SHA-256: d1ed3bf480e18709e25cb1e14be28608cd2587208d74fc195764b12da120cf33