from pathlib import Path import hashlib import json import os import subprocess import zipfile root = Path.cwd() name = 'ArcadiaStudio-0.2.0-preview.authoring.20260911-x86_64-pc-windows-gnullvm' archive = root / '.local/authoring-prerelease-20260911/packages' / (name + '.zip') assert hashlib.sha256(archive.read_bytes()).hexdigest() == '664f30b6217689aca1492eb263b3d15777067d732fa890eeb028f435209dadfa' trial = root / '.local/authoring-prerelease-gui-20260911-v2' trial.mkdir(exist_ok=False) extract = trial / 'extracted' extract.mkdir() with zipfile.ZipFile(archive) as z: names = z.namelist() assert len(names) == len(set(n.casefold() for n in names)) == 559 assert all(n.startswith(name + '/') and '..' not in Path(n).parts for n in names) z.extractall(extract) package = extract / name for line in (package / 'SHA256SUMS.txt').read_text().splitlines(): digest, path = line.split(' ', 1) assert hashlib.sha256((package / path).read_bytes()).hexdigest() == digest, path for folder in ['profile/local', 'profile/roaming']: (trial / folder).mkdir(parents=True) env = os.environ.copy() env['LOCALAPPDATA'] = str(trial / 'profile/local') env['APPDATA'] = str(trial / 'profile/roaming') env['PATH'] = os.pathsep.join([str(package), str(Path(env['SYSTEMROOT']) / 'System32'), env['SYSTEMROOT']]) exe = package / 'arcadia-studio.exe' assert hashlib.sha256(exe.read_bytes()).hexdigest() == 'd4d9c2bd937e301ff1009d7cb93a34ee5aa6dfc837ff7e87d468c85371b20c31' with (trial / 'stdout.log').open('wb') as out, (trial / 'stderr.log').open('wb') as err: process = subprocess.Popen([str(exe)], cwd=package, env=env, stdout=out, stderr=err) result = {'pid': process.pid, 'exe': str(exe), 'archive_sha256': hashlib.sha256(archive.read_bytes()).hexdigest(), 'files': len(names), 'path': env['PATH'], 'local_appdata': env['LOCALAPPDATA'], 'appdata': env['APPDATA']} (trial / 'launch.json').write_text(json.dumps(result, indent=2), encoding='utf-8') print(json.dumps(result, indent=2))