From 4b38cb4c2e8a511c9ea68017a798f418b8a53595 Mon Sep 17 00:00:00 2001 From: Fabian Dill Date: Fri, 6 Aug 2021 19:33:17 +0200 Subject: [PATCH] Setup: various small adjustments and fixes --- Utils.py | 2 +- inno_setup_38.iss | 19 +++++++++++++------ setup.py | 35 +++++++++++++++++++++-------------- 3 files changed, 35 insertions(+), 21 deletions(-) diff --git a/Utils.py b/Utils.py index 09a525d8..75b64876 100644 --- a/Utils.py +++ b/Utils.py @@ -3,7 +3,7 @@ from __future__ import annotations import typing -def tuplize_version(version: str) -> typing.Tuple[int, ...]: +def tuplize_version(version: str) -> Version: return Version(*(int(piece, 10) for piece in version.split("."))) diff --git a/inno_setup_38.iss b/inno_setup_38.iss index 007b88e2..f8734b1e 100644 --- a/inno_setup_38.iss +++ b/inno_setup_38.iss @@ -1,19 +1,25 @@ -#define sourcepath "build\exe.win-amd64-3.8\" +#define sourcepath "build\exe.win-amd64-3.8" #define MyAppName "Archipelago" #define MyAppExeName "ArchipelagoServer.exe" #define MyAppIcon "data/icon.ico" +#dim VersionTuple[4] +#define MyAppVersion ParseVersion('build\exe.win-amd64-3.8\ArchipelagoServer.exe', VersionTuple[0], VersionTuple[1], VersionTuple[2], VersionTuple[3]) +#define MyAppVersionText Str(VersionTuple[0])+"."+Str(VersionTuple[1])+"."+Str(VersionTuple[2]) + [Setup] ; NOTE: The value of AppId uniquely identifies this application. ; Do not use the same AppId value in installers for other applications. AppId={{918BA46A-FAB8-460C-9DFF-AE691E1C865B}} AppName={#MyAppName} -AppVerName={#MyAppName} +AppCopyright=Distributed under MIT License +AppVerName={#MyAppName} {#MyAppVersionText} +VersionInfoVersion={#MyAppVersion} DefaultDirName={commonappdata}\{#MyAppName} DisableProgramGroupPage=yes DefaultGroupName=Archipelago OutputDir=setups -OutputBaseFilename=Setup {#MyAppName} +OutputBaseFilename=Setup {#MyAppName} {#MyAppVersionText} Compression=lzma2 SolidCompression=yes LZMANumBlockThreads=8 @@ -27,6 +33,7 @@ SignTool= signtool LicenseFile= LICENSE WizardStyle= modern SetupLogging=yes +ShowComponentSizes=no [Languages] Name: "english"; MessagesFile: "compiler:Default.isl" @@ -52,8 +59,8 @@ Name: "client/factorio"; Description: "Factorio"; Types: full playing NAME: "{app}"; Flags: setntfscompression; Permissions: everyone-modify users-modify authusers-modify; [Files] -Source: "{code:GetROMPath}"; DestDir: "{app}"; DestName: "Zelda no Densetsu - Kamigami no Triforce (Japan).sfc"; Flags: external; Components: client/lttp or server -Source: "{#sourcepath}*"; Excludes: "*.sfc, *.log, data\sprites\alttpr, SNI, EnemizerCLI, *exe"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs +Source: "{code:GetROMPath}"; DestDir: "{app}"; DestName: "Zelda no Densetsu - Kamigami no Triforce (Japan).sfc"; Flags: external; Components: client/lttp or generator +Source: "{#sourcepath}\*"; Excludes: "*.sfc, *.log, data\sprites\alttpr, SNI, EnemizerCLI, *exe"; DestDir: "{app}"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "{#sourcepath}\SNI"; Excludes: "*.sfc, *.log"; DestDir: "{app}\SNI"; Flags: ignoreversion recursesubdirs createallsubdirs; Components: client/lttp Source: "{#sourcepath}\EnemizerCLI"; Excludes: "*.sfc, *.log"; DestDir: "{app}\EnemizerCLI"; Flags: ignoreversion recursesubdirs createallsubdirs; Components: generator @@ -77,7 +84,7 @@ Name: "{commondesktop}\{#MyAppName} Factorio Client"; Filename: "{app}\Archipela [Run] Filename: "{tmp}\vc_redist.x64.exe"; Parameters: "/passive /norestart"; Check: IsVCRedist64BitNeeded; StatusMsg: "Installing VC++ redistributable..." -Filename: "{app}\ArchipelagoLttPAdjuster"; Parameters: "--update_sprites"; StatusMsg: "Updating Sprite Library..."; Components: client/lttp or server +Filename: "{app}\ArchipelagoLttPAdjuster"; Parameters: "--update_sprites"; StatusMsg: "Updating Sprite Library..."; Components: client/lttp or generator [UninstallDelete] Type: dirifempty; Name: "{app}" diff --git a/setup.py b/setup.py index b081336e..01658a5a 100644 --- a/setup.py +++ b/setup.py @@ -5,11 +5,12 @@ import sysconfig from pathlib import Path import cx_Freeze from kivy_deps import sdl2, glew +from Utils import version_tuple is_64bits = sys.maxsize > 2 ** 32 arch_folder = "exe.{platform}-{version}".format(platform=sysconfig.get_platform(), - version=sysconfig.get_python_version()) + version=sysconfig.get_python_version()) buildfolder = Path("build", arch_folder) sbuildfolder = str(buildfolder) libfolder = Path(buildfolder, "lib") @@ -39,20 +40,25 @@ def _threaded_hash(filepath): os.makedirs(buildfolder, exist_ok=True) -def manifest_creation(folder): +def manifest_creation(folder, create_hashes=False): + # Since the setup is now split into components and the manifest is not, + # it makes most sense to just remove the hashes for now. Not aware of anyone using them. hashes = {} manifestpath = os.path.join(folder, "manifest.json") - from concurrent.futures import ThreadPoolExecutor - pool = ThreadPoolExecutor() - for dirpath, dirnames, filenames in os.walk(folder): - for filename in filenames: - path = os.path.join(dirpath, filename) - hashes[os.path.relpath(path, start=folder)] = pool.submit(_threaded_hash, path) + if create_hashes: + from concurrent.futures import ThreadPoolExecutor + pool = ThreadPoolExecutor() + for dirpath, dirnames, filenames in os.walk(folder): + for filename in filenames: + path = os.path.join(dirpath, filename) + hashes[os.path.relpath(path, start=folder)] = pool.submit(_threaded_hash, path) + import json - from Utils import version_tuple - manifest = {"buildtime": buildtime.isoformat(sep=" ", timespec="seconds"), - "hashes": {path: hash.result() for path, hash in hashes.items()}, - "version": version_tuple} + manifest = { + "buildtime": buildtime.isoformat(sep=" ", timespec="seconds"), + "hashes": {path: hash.result() for path, hash in hashes.items()}, + "version": version_tuple} + json.dump(manifest, open(manifestpath, "wt"), indent=4) print("Created Manifest") @@ -90,7 +96,7 @@ buildtime = datetime.datetime.utcnow() cx_Freeze.setup( name="Archipelago", - version=f"{buildtime.year}.{buildtime.month}.{buildtime.day}.{buildtime.hour}", + version=f"{version_tuple.major}.{version_tuple.minor}.{version_tuple.build}", description="Archipelago", executables=exes, options={ @@ -124,7 +130,8 @@ def installfile(path, keep_content=False): else: print('Warning,', path, 'not found') -for folder in sdl2.dep_bins+glew.dep_bins: + +for folder in sdl2.dep_bins + glew.dep_bins: shutil.copytree(folder, libfolder, dirs_exist_ok=True) print('copying', folder, '->', libfolder)