#!/usr/bin/env python3 """Stage a self-contained Windows native editor and its TeX resource trees.""" import argparse import hashlib import json import lzma from pathlib import Path import shutil import struct import tarfile import tempfile MIRROR = "https://ctan.math.illinois.edu/systems/texlive/tlnet" WEB_FILES = ("index.html", "styles.css", "favicon.svg", "app.js") TOOLS = { "bibtex.windows": ("bibtex.exe",), "kpathsea.windows": ("kpsewhich.exe", "kpathsealibw64.dll", "msvcr100.dll"), } def digest(path, algorithm="sha256"): with path.open("rb") as stream: return hashlib.file_digest(stream, algorithm).hexdigest() def require_amd64_pe(path): with path.open("rb") as stream: header = stream.read(64) if len(header) == 64 and header[:2] == b"MZ": stream.seek(struct.unpack_from("