Core: default distribute Factorio and Subnautica as .apworld (#1260)
This commit is contained in:
parent
7c3af68e59
commit
5273812039
|
@ -48,7 +48,7 @@ Output Logs/
|
||||||
/freeze_requirements.txt
|
/freeze_requirements.txt
|
||||||
/Archipelago.zip
|
/Archipelago.zip
|
||||||
/setup.ini
|
/setup.ini
|
||||||
|
/installdelete.iss
|
||||||
|
|
||||||
# Byte-compiled / optimized / DLL files
|
# Byte-compiled / optimized / DLL files
|
||||||
__pycache__/
|
__pycache__/
|
||||||
|
|
|
@ -152,6 +152,7 @@ Type: dirifempty; Name: "{app}"
|
||||||
[InstallDelete]
|
[InstallDelete]
|
||||||
Type: files; Name: "{app}\ArchipelagoLttPClient.exe"
|
Type: files; Name: "{app}\ArchipelagoLttPClient.exe"
|
||||||
Type: filesandordirs; Name: "{app}\lib\worlds\rogue-legacy*"
|
Type: filesandordirs; Name: "{app}\lib\worlds\rogue-legacy*"
|
||||||
|
#include "installdelete.iss"
|
||||||
|
|
||||||
[Registry]
|
[Registry]
|
||||||
|
|
||||||
|
|
25
setup.py
25
setup.py
|
@ -3,6 +3,7 @@ import shutil
|
||||||
import sys
|
import sys
|
||||||
import sysconfig
|
import sysconfig
|
||||||
import platform
|
import platform
|
||||||
|
import zipfile
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from hashlib import sha3_512
|
from hashlib import sha3_512
|
||||||
import base64
|
import base64
|
||||||
|
@ -14,6 +15,11 @@ import setuptools
|
||||||
from Launcher import components, icon_paths
|
from Launcher import components, icon_paths
|
||||||
|
|
||||||
|
|
||||||
|
apworlds: set = {
|
||||||
|
"Subnautica",
|
||||||
|
"Factorio",
|
||||||
|
}
|
||||||
|
|
||||||
# This is a bit jank. We need cx-Freeze to be able to run anything from this script, so install it
|
# This is a bit jank. We need cx-Freeze to be able to run anything from this script, so install it
|
||||||
import subprocess
|
import subprocess
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
|
@ -185,11 +191,26 @@ class BuildExeCommand(cx_Freeze.command.build_exe.BuildEXE):
|
||||||
from WebHostLib.options import create
|
from WebHostLib.options import create
|
||||||
create()
|
create()
|
||||||
from worlds.AutoWorld import AutoWorldRegister
|
from worlds.AutoWorld import AutoWorldRegister
|
||||||
|
assert not apworlds - set(AutoWorldRegister.world_types), "Unknown world designated for .apworld"
|
||||||
|
folders_to_remove: typing.List[str] = []
|
||||||
for worldname, worldtype in AutoWorldRegister.world_types.items():
|
for worldname, worldtype in AutoWorldRegister.world_types.items():
|
||||||
if not worldtype.hidden:
|
if not worldtype.hidden:
|
||||||
file_name = worldname+".yaml"
|
file_name = worldname+".yaml"
|
||||||
shutil.copyfile(os.path.join("WebHostLib", "static", "generated", "configs", file_name),
|
shutil.copyfile(os.path.join("WebHostLib", "static", "generated", "configs", file_name),
|
||||||
self.buildfolder / "Players" / "Templates" / file_name)
|
self.buildfolder / "Players" / "Templates" / file_name)
|
||||||
|
if worldname in apworlds:
|
||||||
|
file_name = os.path.split(os.path.dirname(worldtype.__file__))[1]
|
||||||
|
world_directory = self.libfolder / "worlds" / file_name
|
||||||
|
# this method creates an apworld that cannot be moved to a different OS or minor python version,
|
||||||
|
# which should be ok
|
||||||
|
with zipfile.ZipFile(self.libfolder / "worlds" / (file_name + ".apworld"), "x", zipfile.ZIP_DEFLATED,
|
||||||
|
compresslevel=9) as zf:
|
||||||
|
entry: os.DirEntry
|
||||||
|
for path in world_directory.rglob("*.*"):
|
||||||
|
relative_path = os.path.join(*path.parts[path.parts.index("worlds")+1:])
|
||||||
|
zf.write(path, relative_path)
|
||||||
|
folders_to_remove.append(file_name)
|
||||||
|
shutil.rmtree(world_directory)
|
||||||
shutil.copyfile("meta.yaml", self.buildfolder / "Players" / "Templates" / "meta.yaml")
|
shutil.copyfile("meta.yaml", self.buildfolder / "Players" / "Templates" / "meta.yaml")
|
||||||
# TODO: fix LttP options one day
|
# TODO: fix LttP options one day
|
||||||
shutil.copyfile("playerSettings.yaml", self.buildfolder / "Players" / "Templates" / "A Link to the Past.yaml")
|
shutil.copyfile("playerSettings.yaml", self.buildfolder / "Players" / "Templates" / "A Link to the Past.yaml")
|
||||||
|
@ -218,9 +239,13 @@ class BuildExeCommand(cx_Freeze.command.build_exe.BuildEXE):
|
||||||
self.create_manifest()
|
self.create_manifest()
|
||||||
|
|
||||||
if is_windows:
|
if is_windows:
|
||||||
|
# Inno setup stuff
|
||||||
with open("setup.ini", "w") as f:
|
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" if sys.version_info > (3, 9) else "6.0.6000"
|
||||||
f.write(f"[Data]\nsource_path={self.buildfolder}\nmin_windows={min_supported_windows}\n")
|
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"
|
||||||
|
for world_directory in folders_to_remove)
|
||||||
else:
|
else:
|
||||||
# make sure extra programs are executable
|
# make sure extra programs are executable
|
||||||
enemizer_exe = self.buildfolder / 'EnemizerCLI/EnemizerCLI.Core'
|
enemizer_exe = self.buildfolder / 'EnemizerCLI/EnemizerCLI.Core'
|
||||||
|
|
Loading…
Reference in New Issue