36 lines
972 B
Python
36 lines
972 B
Python
"""Quick check: which plugin dirs are bundled in the EXE."""
|
|||
|
|
import zipfile, io, sys
|
||
|
|
from pathlib import Path
|
||
|
|
|
||
|
|
exe = Path("dist/sakuradownloader.exe")
|
||
|
|
if not exe.exists():
|
||
|
|
print("EXE not found")
|
||
|
|
sys.exit(1)
|
||
|
|
|
||
|
|
with open(exe, "rb") as f:
|
||
|
|
raw = f.read()
|
||
|
|
|
||
|
|
# Find PyInstaller CArchive magic
|
||
|
|
magic = b"MEI\x14\x14"
|
||
|
|
pos = raw.rfind(magic)
|
||
|
|
if pos == -1:
|
||
|
|
print("CArchive marker not found")
|
||
|
|
sys.exit(1)
|
||
|
|
|
||
|
|
z = zipfile.ZipFile(io.BytesIO(raw[pos:]))
|
||
|
|
plugin_dirs = set()
|
||
|
|
for name in z.namelist():
|
||
|
|
parts = name.replace("\\", "/").split("/")
|
||
|
|
if len(parts) >= 2 and parts[0] == "plugins":
|
||
|
|
plugin_dirs.add(parts[1])
|
||
|
|
|
||
|
|
print("Plugins included in EXE:")
|
||
|
|
for p in sorted(plugin_dirs):
|
||
|
|
print(f" - {p}")
|
||
|
|
|
||
|
|
excluded = {"ao3", "changpei"}
|
||
|
|
included_but_should_not = excluded & plugin_dirs
|
||
|
|
if included_but_should_not:
|
||
|
|
print(f"\nWARNING: these should be excluded: {included_but_should_not}")
|
||
|
|
else:
|
||
|
|
print("\nOK: ao3 and changpei are correctly excluded.")
|