#!/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, PurePosixPath 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"), } UNICODE_PACKAGES = ("ctex", "xecjk", "zhnumber", "fandol", "xetex") UNICODE_NOTICES = { "ctex": {"doc/latex/ctex/README.md": "ctex-README.md"}, "xecjk": {"doc/xelatex/xecjk/README.md": "xeCJK-README.md"}, "zhnumber": {"doc/latex/zhnumber/README.md": "zhnumber-README.md"}, "fandol": { "doc/latex/fandol/COPYING": "Fandol-COPYING", "doc/latex/fandol/README": "Fandol-README", }, } 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("