-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild_installer.py
More file actions
66 lines (54 loc) · 2.24 KB
/
Copy pathbuild_installer.py
File metadata and controls
66 lines (54 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
import shutil
import subprocess
import sys
import urllib.request
from pathlib import Path
from build_openscr import APP_VERSION, ROOT_DIR
CHINESE_LANGUAGE_URL = "https://raw.githubusercontent.com/kira-96/Inno-Setup-Chinese-Simplified-Translation/main/ChineseSimplified.isl"
CACHE_DIR = ROOT_DIR / "installer" / "cache"
CHINESE_LANGUAGE = CACHE_DIR / "ChineseSimplified.isl"
ISS_FILE = ROOT_DIR / "installer" / "OpenSCR.iss"
RELEASE_DIR = ROOT_DIR / "release"
SOURCE_DIR = RELEASE_DIR / f"OpenSCR-{APP_VERSION}-Windows-amd64-Portable"
def find_iscc():
executable = shutil.which("ISCC.exe")
if executable:
return Path(executable)
candidates = (
Path(os.environ.get("LOCALAPPDATA", "")) / "Programs" / "Inno Setup 6" / "ISCC.exe",
Path(os.environ.get("ProgramFiles(x86)", "")) / "Inno Setup 6" / "ISCC.exe",
Path(os.environ.get("ProgramFiles", "")) / "Inno Setup 6" / "ISCC.exe",
)
return next((path for path in candidates if path.is_file()), None)
def download_installer_assets():
CACHE_DIR.mkdir(parents=True, exist_ok=True)
if not CHINESE_LANGUAGE.is_file():
print("Downloading the Simplified Chinese installer catalog...")
urllib.request.urlretrieve(CHINESE_LANGUAGE_URL, CHINESE_LANGUAGE)
def main():
if sys.platform != "win32":
raise SystemExit("O instalador Windows deve ser compilado no Windows.")
iscc = find_iscc()
if iscc is None:
raise SystemExit("Inno Setup 6 não encontrado. Instale-o e execute novamente.")
environment = os.environ.copy()
environment.pop("OPENSCR_ONEFILE", None)
subprocess.run([sys.executable, str(ROOT_DIR / "build_openscr.py")], check=True, env=environment)
source_dir = RELEASE_DIR / f"OpenSCR-{APP_VERSION}-Windows-amd64-Portable"
download_installer_assets()
subprocess.run(
[
str(iscc),
f"/DMyAppVersion={APP_VERSION}",
f"/DSourceDir={source_dir}",
f"/DChineseLanguage={CHINESE_LANGUAGE}",
f"/DOutputDir={RELEASE_DIR}",
"/DMyMinVersion=10.0.14393",
str(ISS_FILE),
],
check=True,
)
print(RELEASE_DIR / f"OpenSCR-{APP_VERSION}-Windows-x64-Setup.exe")
if __name__ == "__main__":
main()