Merge branch 'main' into setup_more_apworld

This commit is contained in:
Fabian Dill
2025-08-02 05:41:59 +02:00
committed by GitHub
329 changed files with 7925 additions and 9916 deletions

View File

@@ -9,6 +9,7 @@ import subprocess
import sys
import sysconfig
import threading
import urllib.error
import urllib.request
import warnings
import zipfile
@@ -16,6 +17,10 @@ from collections.abc import Iterable, Sequence
from hashlib import sha3_512
from pathlib import Path
SNI_VERSION = "v0.0.100" # change back to "latest" once tray icon issues are fixed
# This is a bit jank. We need cx-Freeze to be able to run anything from this script, so install it
requirement = 'cx-Freeze==8.2.0'
try:
@@ -77,7 +82,8 @@ def download_SNI() -> None:
machine_name = platform.machine().lower()
# force amd64 on macos until we have universal2 sni, otherwise resolve to GOARCH
machine_name = "universal" if platform_name == "darwin" else machine_to_go.get(machine_name, machine_name)
with urllib.request.urlopen("https://api.github.com/repos/alttpo/sni/releases/latest") as request:
sni_version_ref = "latest" if SNI_VERSION == "latest" else f"tags/{SNI_VERSION}"
with urllib.request.urlopen(f"https://api.github.com/repos/alttpo/SNI/releases/{sni_version_ref}") as request:
data = json.load(request)
files = data["assets"]
@@ -91,8 +97,8 @@ def download_SNI() -> None:
# prefer "many" builds
if "many" in download_url:
break
# prefer the correct windows or windows7 build
if platform_name == "windows" and ("windows7" in download_url) == (sys.version_info < (3, 9)):
# prefer non-windows7 builds to get up-to-date dependencies
if platform_name == "windows" and "windows7" not in download_url:
break
if source_url and source_url.endswith(".zip"):
@@ -131,15 +137,16 @@ def download_SNI() -> None:
print(f"No SNI found for system spec {platform_name} {machine_name}")
signtool: str | None
if os.path.exists("X:/pw.txt"):
print("Using signtool")
with open("X:/pw.txt", encoding="utf-8-sig") as f:
pw = f.read()
signtool = r'signtool sign /f X:/_SITS_Zertifikat_.pfx /p "' + pw + \
r'" /fd sha256 /td sha256 /tr http://timestamp.digicert.com/ '
else:
signtool = None
signtool: str | None = None
try:
with urllib.request.urlopen('http://192.168.206.4:12345/connector/status') as response:
html = response.read()
if b"status=OK\n" in html:
signtool = (r'signtool sign /sha1 6df76fe776b82869a5693ddcb1b04589cffa6faf /fd sha256 /td sha256 '
r'/tr http://timestamp.digicert.com/ ')
print("Using signtool")
except (ConnectionError, TimeoutError, urllib.error.URLError) as e:
pass
build_platform = sysconfig.get_platform()
@@ -184,9 +191,10 @@ extra_libs = ["libssl.so", "libcrypto.so"] if is_linux else []
def remove_sprites_from_folder(folder: Path) -> None:
for file in os.listdir(folder):
if file != ".gitignore":
os.remove(folder / file)
if os.path.isdir(folder):
for file in os.listdir(folder):
if file != ".gitignore":
os.remove(folder / file)
def _threaded_hash(filepath: str | Path) -> str:
@@ -395,13 +403,14 @@ class BuildExeCommand(cx_Freeze.command.build_exe.build_exe):
os.system(signtool + os.path.join(self.buildfolder, "lib", "worlds", "oot", "data", *exe_path))
remove_sprites_from_folder(self.buildfolder / "data" / "sprites" / "alttpr")
remove_sprites_from_folder(self.buildfolder / "data" / "sprites" / "alttp" / "remote")
self.create_manifest()
if is_windows:
# Inno setup stuff
with open("setup.ini", "w") as f:
min_supported_windows = "6.2.9200" if sys.version_info > (3, 9) else "6.0.6000"
min_supported_windows = "6.2.9200"
f.write(f"[Data]\nsource_path={self.buildfolder}\nmin_windows={min_supported_windows}\n")
with open("installdelete.iss", "w") as f:
f.writelines("Type: filesandordirs; Name: \"{app}\\lib\\worlds\\"+world_directory+"\"\n"
@@ -468,7 +477,7 @@ tmp="${{exe#*/}}"
if [ ! "${{#tmp}}" -lt "${{#exe}}" ]; then
exe="{default_exe.parent}/$exe"
fi
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$APPDIR/{default_exe.parent}/lib"
export LD_LIBRARY_PATH="${{LD_LIBRARY_PATH:+$LD_LIBRARY_PATH:}}$APPDIR/{default_exe.parent}/lib"
$APPDIR/$exe "$@"
""")
launcher_filename.chmod(0o755)