Script: build.py
Strong Artin: source and evidence
build.py
This is the original source text. Reading it does not run or verify the program.
1 """Build the Strong Artin 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_Strong_Artin_Conjecture_Piece_v1.0.pdf',
17 'visual': 'Komorebi_Strong_Artin_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, text=True, capture_output=True,
26 )
27 (folder / 'build_stdout.log').write_text(proc.stdout + proc.stderr)
28 if proc.returncode:
29 print(proc.stdout[-7000:], 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: 4e55b37e5575e11191e2e7d830efe43e2ee782eb675f6ee55d1bee6d7c8786e0