From 45804dafc179af8c7aedd62284cf100482dc09aa Mon Sep 17 00:00:00 2001 From: David Sangrey Date: Tue, 1 Aug 2023 16:30:59 -0400 Subject: [PATCH] #2040 Dynamically Build iss File --- .gitignore | 1 + ...ig.iss => EDMC_Installer_Config_template.txt | 5 +++-- installer.py | 17 ++++++++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) rename EDMC_Installer_Config.iss => EDMC_Installer_Config_template.txt (95%) diff --git a/.gitignore b/.gitignore index b19207d9..35fa7565 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ appcast_win_*.xml appcast_mac_*.xml EDMarketConnector.VisualElementsManifest.xml *.zip +EDMC_Installer_Config.iss .idea .vscode diff --git a/EDMC_Installer_Config.iss b/EDMC_Installer_Config_template.txt similarity index 95% rename from EDMC_Installer_Config.iss rename to EDMC_Installer_Config_template.txt index 0a34f1ff..b7cb4052 100644 --- a/EDMC_Installer_Config.iss +++ b/EDMC_Installer_Config_template.txt @@ -1,5 +1,5 @@ #define MyAppName "EDMarketConnector" -#define MyAppVersion "5.9.1-alpha2" +#define MyAppVersion "$appver" #define MyAppPublisher "EDCD" #define MyAppURL "https://edcd.github.io/" #define SuppURL "https://github.com/EDCD/EDMarketConnector/" @@ -29,7 +29,8 @@ WizardStyle=modern InfoBeforeFile=dist.win32\Changelog.md OutputDir=. LicenseFile=LICENSE -LanguageDetectionMethod=uilanguage +AlwaysShowDirOnReadyPage=yes +UninstallDisplayIcon={app}\{#MyAppExeName} [Languages] diff --git a/installer.py b/installer.py index 659286ac..a96a8f08 100644 --- a/installer.py +++ b/installer.py @@ -7,7 +7,19 @@ See LICENSE file. """ import os import subprocess +from string import Template from build import build +from config import _static_appversion as appversion + + +def iss_build(template_path: str, output_file: str) -> None: + """Build the .iss file needed for building the installer EXE.""" + sub_vals = {"appver": appversion} + with open(template_path, encoding="UTF8") as template_file: + src = Template(template_file.read()) + newfile = src.substitute(sub_vals) + with open(output_file, "w", encoding="UTF8") as new_file: + new_file.write(newfile) def run_inno_setup_installer(iss_path: str) -> None: @@ -39,6 +51,9 @@ def run_inno_setup_installer(iss_path: str) -> None: if __name__ == "__main__": build() - # Replace 'your_iss_file.iss' with the path to your actual .iss file + # Add the ISS Template File + iss_template_path: str = "./EDMC_Installer_Config_template.txt" iss_file_path: str = "./EDMC_Installer_Config.iss" + # Build the ISS file + iss_build(iss_template_path, iss_file_path) run_inno_setup_installer(iss_file_path)