1
0
mirror of https://github.com/EDCD/EDMarketConnector.git synced 2025-04-17 17:42:20 +03:00

#2040 Integrate Builder and Installer

This commit is contained in:
David Sangrey 2023-07-27 14:14:36 -04:00
parent dd1442f37b
commit 6f91e6ce4e
No known key found for this signature in database
GPG Key ID: 3AEADBB0186884BC
3 changed files with 29 additions and 21 deletions

View File

@ -33,6 +33,7 @@ WizardStyle=modern
InfoBeforeFile=dist.win32\Changelog.md InfoBeforeFile=dist.win32\Changelog.md
OutputDir=. OutputDir=.
LicenseFile=LICENSE LicenseFile=LICENSE
LanguageDetectionMethod=uilanguage
[Languages] [Languages]

View File

@ -9,8 +9,9 @@ import os
import shutil import shutil
import sys import sys
import pathlib import pathlib
import py2exe from typing import List, Tuple
from os.path import join, isdir from os.path import join, isdir
import py2exe
from config import ( from config import (
appcmdname, appcmdname,
appname, appname,
@ -18,7 +19,6 @@ from config import (
copyright, copyright,
git_shorthash_from_head, git_shorthash_from_head,
) )
from typing import List, Tuple
def system_check(dist_dir: str) -> str: def system_check(dist_dir: str) -> str:
@ -45,7 +45,7 @@ def system_check(dist_dir: str) -> str:
def generate_data_files( def generate_data_files(
app_name: str, gitversion_file: str app_name: str, gitversion_file: str, plugins: List[str]
) -> List[Tuple[str, List[str]]]: ) -> List[Tuple[str, List[str]]]:
"""Create the required datafiles to build.""" """Create the required datafiles to build."""
l10n_dir = "L10n" l10n_dir = "L10n"
@ -81,26 +81,27 @@ def generate_data_files(
join(fdevids_dir, "rare_commodity.csv"), join(fdevids_dir, "rare_commodity.csv"),
], ],
), ),
("plugins", PLUGINS), ("plugins", plugins),
] ]
return data_files return data_files
if __name__ == "__main__": def build() -> None:
DIST_DIR: str = "dist.win32" """Build EDMarketConnector using Py2Exe."""
GITVERSION_FILENAME: str = system_check(DIST_DIR) dist_dir: str = "dist.win32"
gitversion_filename: str = system_check(dist_dir)
# Constants # Constants
PLUGINS: List[str] = [ plugins: List[str] = [
"plugins/coriolis.py", "plugins/coriolis.py",
"plugins/eddn.py", "plugins/eddn.py",
"plugins/edsm.py", "plugins/edsm.py",
"plugins/edsy.py", "plugins/edsy.py",
"plugins/inara.py", "plugins/inara.py",
] ]
OPTIONS: dict = { options: dict = {
"py2exe": { "py2exe": {
"dist_dir": DIST_DIR, "dist_dir": dist_dir,
"optimize": 2, "optimize": 2,
"packages": [ "packages": [
"asyncio", "asyncio",
@ -125,8 +126,8 @@ if __name__ == "__main__":
} }
# Function to generate DATA_FILES list # Function to generate DATA_FILES list
DATA_FILES: List[Tuple[str, List[str]]] = generate_data_files( data_files: List[Tuple[str, List[str]]] = generate_data_files(
appname, GITVERSION_FILENAME appname, gitversion_filename, plugins
) )
version_info: dict = { version_info: dict = {
@ -161,6 +162,10 @@ if __name__ == "__main__":
version_info=version_info, version_info=version_info,
windows=[windows_config], windows=[windows_config],
console=[console_config], console=[console_config],
data_files=DATA_FILES, data_files=data_files,
options=OPTIONS, options=options,
) )
if __name__ == "__main__":
build()

View File

@ -7,9 +7,10 @@ See LICENSE file.
""" """
import os import os
import subprocess import subprocess
from build import build
def run_inno_setup_installer(iss_file_path: str) -> None: def run_inno_setup_installer(iss_path: str) -> None:
"""Run the Inno installer, building the installation exe.""" """Run the Inno installer, building the installation exe."""
# Get the path to the Inno Setup compiler (iscc.exe) (Currently set to default path) # Get the path to the Inno Setup compiler (iscc.exe) (Currently set to default path)
inno_setup_compiler_path: str = "C:\\Program Files (x86)\\Inno Setup 6\\ISCC.exe" inno_setup_compiler_path: str = "C:\\Program Files (x86)\\Inno Setup 6\\ISCC.exe"
@ -21,22 +22,23 @@ def run_inno_setup_installer(iss_file_path: str) -> None:
# Check if the provided .iss file exists # Check if the provided .iss file exists
if not os.path.isfile(iss_file_path): if not os.path.isfile(iss_file_path):
print(f"Error: The provided .iss file '{iss_file_path}' not found.") print(f"Error: The provided .iss file '{iss_path}' not found.")
return return
# Run the Inno Setup compiler with the provided .iss file # Run the Inno Setup compiler with the provided .iss file
try: try:
subprocess.run([inno_setup_compiler_path, iss_file_path], check=True) subprocess.run([inno_setup_compiler_path, iss_file_path], check=True)
except subprocess.CalledProcessError as e: except subprocess.CalledProcessError as err:
print( print(
f"Error: Inno Setup compiler returned an error (exit code {e.returncode}):" f"Error: Inno Setup compiler returned an error (exit code {err.returncode}):"
) )
print(e.output.decode()) print(err.output.decode())
except Exception as e: except Exception as err:
print(f"Error: An unexpected error occurred: {e}") print(f"Error: An unexpected error occurred: {err}")
if __name__ == "__main__": if __name__ == "__main__":
build()
# Replace 'your_iss_file.iss' with the path to your actual .iss file # Replace 'your_iss_file.iss' with the path to your actual .iss file
iss_file_path: str = "./EDMC_Installer_Config.iss" iss_file_path: str = "./EDMC_Installer_Config.iss"
run_inno_setup_installer(iss_file_path) run_inno_setup_installer(iss_file_path)