#!/usr/bin/env python3 # /// script # requires-python = ">=3.11" # dependencies = ["numpy", "scipy", "shapely", "trimesh", "manifold3d", "mapbox-earcut", "networkx", "rtree", "playwright"] # /// """Build the whole Green Man kit and publish it into ../greenman. uv run build.py build everything, then copy the page into ../greenman uv run build.py --no-publish build into out/ only Order matters: the print files are checked first because the guides quote the results.""" import shutil, sys, zipfile from pathlib import Path from paths import ROOT, OUT, ASSETS, SITE STAMP = (2026, 1, 1, 0, 0, 0) # fixed date inside the zips, so an unchanged kit gives an unchanged zip def zip_write(path, entries): with zipfile.ZipFile(path, 'w', zipfile.ZIP_DEFLATED) as z: for name, src in sorted(entries): zi = zipfile.ZipInfo(name, STAMP); zi.compress_type = zipfile.ZIP_DEFLATED; zi.external_attr = 0o644 << 16 z.writestr(zi, Path(src).read_bytes()) def main(publish=True): import stl_build report = stl_build.build() bad = {n: r['verdict'] for n, r in report.items() if r['verdict'].startswith('FAIL')} assert not bad, f'print files failed the printability check: {bad}' import audit_run problems = audit_run.run() assert not problems, f'audit found problems: {problems}' import build_templates, build_guides, build_web pdfs = [build_templates.build(), build_guides.build('build'), build_guides.build('paint')] build_web.build() dl = OUT / 'dl'; shutil.rmtree(dl, ignore_errors=True); dl.mkdir() stls = sorted((OUT / 'stl').glob('*.stl')) assert {p.name for p in stls} == set(report), 'out/stl holds files the report does not know about' for p in pdfs: shutil.copy(p, dl) zip_write(dl / 'GreenMan_print_files.zip', [(p.name, p) for p in stls]) kit = 'GreenMan_mask_kit/' zip_write(dl / 'GreenMan_mask_kit.zip', [(kit + Path(p).name, p) for p in pdfs] + [(kit + 'print_files/' + p.name, p) for p in stls] + [(kit + 'README.txt', ASSETS / 'kit_README.txt')]) if publish: SITE.mkdir(exist_ok=True) shutil.copy(OUT / 'index.html', SITE / 'index.html') shutil.copy(ASSETS / 'og-image.jpg', SITE / 'og-image.jpg') for sub, src in (('img', ASSETS / 'img'), ('dl', dl)): shutil.rmtree(SITE / sub, ignore_errors=True); shutil.copytree(src, SITE / sub) print(f'published to {SITE}') if __name__ == '__main__': main(publish='--no-publish' not in sys.argv)