mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-17 17:42:20 +03:00
#2040 Type Annotations
This commit is contained in:
parent
1690f8f3a9
commit
58a3f4504f
40
build.py
40
build.py
@ -23,9 +23,10 @@ from config import (
|
|||||||
copyright,
|
copyright,
|
||||||
git_shorthash_from_head,
|
git_shorthash_from_head,
|
||||||
)
|
)
|
||||||
|
from typing import List, Tuple
|
||||||
|
|
||||||
|
|
||||||
def system_check(dist_dir):
|
def system_check(dist_dir: str) -> str:
|
||||||
"""Check if the system is able to build."""
|
"""Check if the system is able to build."""
|
||||||
if sys.version_info < (3, 11):
|
if sys.version_info < (3, 11):
|
||||||
sys.exit(f"Unexpected Python version {sys.version}")
|
sys.exit(f"Unexpected Python version {sys.version}")
|
||||||
@ -48,7 +49,9 @@ def system_check(dist_dir):
|
|||||||
return gitversion_file
|
return gitversion_file
|
||||||
|
|
||||||
|
|
||||||
def generate_data_files(app_name, gitversion_file):
|
def generate_data_files(
|
||||||
|
app_name: str, gitversion_file: str
|
||||||
|
) -> List[Tuple[str, List[str]]]:
|
||||||
"""Create the required datafiles to build."""
|
"""Create the required datafiles to build."""
|
||||||
l10n_dir = "L10n"
|
l10n_dir = "L10n"
|
||||||
fdevids_dir = "FDevIDs"
|
fdevids_dir = "FDevIDs"
|
||||||
@ -88,7 +91,7 @@ def generate_data_files(app_name, gitversion_file):
|
|||||||
return data_files
|
return data_files
|
||||||
|
|
||||||
|
|
||||||
def windows_installer_display_lang(app_name, filename):
|
def windows_installer_display_lang(app_name: str, filename: str) -> None:
|
||||||
"""Configure the Windows Installer Display Language."""
|
"""Configure the Windows Installer Display Language."""
|
||||||
lcids = [
|
lcids = [
|
||||||
int(x)
|
int(x)
|
||||||
@ -111,7 +114,7 @@ def windows_installer_display_lang(app_name, filename):
|
|||||||
)
|
)
|
||||||
os.system(
|
os.system(
|
||||||
rf'"{SDKPATH}\MsiTran.Exe" -g {gettempdir()}\{app_name}_1033.msi'
|
rf'"{SDKPATH}\MsiTran.Exe" -g {gettempdir()}\{app_name}_1033.msi'
|
||||||
rf' {gettempdir()}\{app_name}_{lcid}.msi {gettempdir()}\{lcid}.mst'
|
rf" {gettempdir()}\{app_name}_{lcid}.msi {gettempdir()}\{lcid}.mst"
|
||||||
)
|
)
|
||||||
os.system(
|
os.system(
|
||||||
rf'cscript /nologo "{SDKPATH}\WiSubStg.vbs" {filename} {gettempdir()}\{lcid}.mst {lcid}'
|
rf'cscript /nologo "{SDKPATH}\WiSubStg.vbs" {filename} {gettempdir()}\{lcid}.mst {lcid}'
|
||||||
@ -119,19 +122,20 @@ def windows_installer_display_lang(app_name, filename):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
DIST_DIR = "dist.win32"
|
DIST_DIR: str = "dist.win32"
|
||||||
GITVERSION_FILENAME = system_check(DIST_DIR)
|
GITVERSION_FILENAME: str = system_check(DIST_DIR)
|
||||||
|
|
||||||
# Constants
|
# Constants
|
||||||
WIXPATH = rf"{os.environ['WIX']}\bin"
|
WIXPATH: str = rf"{os.environ['WIX']}\bin"
|
||||||
SDKPATH = r"C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86"
|
SDKPATH: str = r"C:\Program Files (x86)\Windows Kits\10\bin\10.0.19041.0\x86"
|
||||||
PLUGINS = [
|
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 = {
|
OPTIONS: dict = {
|
||||||
"py2exe": {
|
"py2exe": {
|
||||||
"dist_dir": DIST_DIR,
|
"dist_dir": DIST_DIR,
|
||||||
"optimize": 2,
|
"optimize": 2,
|
||||||
@ -158,9 +162,11 @@ if __name__ == "__main__":
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Function to generate DATA_FILES list
|
# Function to generate DATA_FILES list
|
||||||
DATA_FILES = generate_data_files(appname, GITVERSION_FILENAME)
|
DATA_FILES: List[Tuple[str, List[str]]] = generate_data_files(
|
||||||
|
appname, GITVERSION_FILENAME
|
||||||
|
)
|
||||||
|
|
||||||
version_info = {
|
version_info: dict = {
|
||||||
"description": "Downloads commodity market and other station data from the game"
|
"description": "Downloads commodity market and other station data from the game"
|
||||||
" Elite Dangerous for use with all popular online and offline trading tools.",
|
" Elite Dangerous for use with all popular online and offline trading tools.",
|
||||||
"company_name": "EDCD", # Used by WinSparkle
|
"company_name": "EDCD", # Used by WinSparkle
|
||||||
@ -171,7 +177,7 @@ if __name__ == "__main__":
|
|||||||
"language": "English (United States)",
|
"language": "English (United States)",
|
||||||
}
|
}
|
||||||
|
|
||||||
windows_config = {
|
windows_config: dict = {
|
||||||
"dest_base": appname,
|
"dest_base": appname,
|
||||||
"script": "EDMarketConnector.py",
|
"script": "EDMarketConnector.py",
|
||||||
"icon_resources": [(0, f"{appname}.ico")],
|
"icon_resources": [(0, f"{appname}.ico")],
|
||||||
@ -180,7 +186,7 @@ if __name__ == "__main__":
|
|||||||
],
|
],
|
||||||
}
|
}
|
||||||
|
|
||||||
console_config = {
|
console_config: dict = {
|
||||||
"dest_base": appcmdname,
|
"dest_base": appcmdname,
|
||||||
"script": "EDMC.py",
|
"script": "EDMC.py",
|
||||||
"other_resources": [
|
"other_resources": [
|
||||||
@ -299,8 +305,10 @@ if __name__ == "__main__":
|
|||||||
raise AssertionError(f"No {appname}.wixobj: candle.exe failed?")
|
raise AssertionError(f"No {appname}.wixobj: candle.exe failed?")
|
||||||
|
|
||||||
package_filename = f"{appname}_win_{appversion_nobuild()}.msi"
|
package_filename = f"{appname}_win_{appversion_nobuild()}.msi"
|
||||||
light_command = rf'"{WIXPATH}\light.exe" -b {DIST_DIR}\ -sacl -spdb ' \
|
light_command = (
|
||||||
rf'-sw1076 {appname}.wixobj -out {package_filename}'
|
rf'"{WIXPATH}\light.exe" -b {DIST_DIR}\ -sacl -spdb '
|
||||||
|
rf"-sw1076 {appname}.wixobj -out {package_filename}"
|
||||||
|
)
|
||||||
subprocess.run(light_command, shell=True, check=True)
|
subprocess.run(light_command, shell=True, check=True)
|
||||||
|
|
||||||
if not exists(package_filename):
|
if not exists(package_filename):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user