-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathopensak.spec
More file actions
147 lines (136 loc) · 4.88 KB
/
Copy pathopensak.spec
File metadata and controls
147 lines (136 loc) · 4.88 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# opensak.spec — PyInstaller build spec
# Used by GitHub Actions CI/CD.
#
# Build locally:
# pyinstaller opensak.spec
import sys
from pathlib import Path
from PyInstaller.utils.hooks import collect_data_files
block_cipher = None
# certifi's cacert.pem is required for HTTPS calls (update checker) to work
# from a bundled .exe — without it, Windows builds can fail SSL verification
# even though the same code works fine from a normal Python install, because
# urllib falls back to a system certificate store PyInstaller's bundle does
# not always expose correctly.
import certifi
certifi_datas = [(certifi.where(), "certifi")]
# Qt's own translation catalogs (qtbase_xx.qm) — needed so Qt's built-in
# dialog strings (Ok/Cancel/Close/Yes/No etc. from
# QDialogButtonBox.StandardButton) are translated too, not just OpenSAK's
# own tr() strings. See app.py::_install_qt_translator(). Only bundle the
# languages OpenSAK actually supports, to avoid dragging in unused
# catalogs for every Qt-supported locale.
import PySide6
_qt_translations_dir = Path(PySide6.__file__).parent / "Qt" / "translations"
_QT_LANG_FILES = {
"da": "qtbase_da.qm",
"en": "qtbase_en.qm",
"fr": "qtbase_fr.qm",
"nl": "qtbase_nl.qm",
"pt": "qtbase_pt_BR.qm", # no European-Portuguese qtbase catalog upstream; pt_BR is closest
"cs": "qtbase_cs.qm",
"se": "qtbase_sv.qm", # OpenSAK uses "se" for Swedish; Qt's own ISO code is "sv"
"de": "qtbase_de.qm",
}
qt_translation_datas: list[tuple[str, str]] = []
for _fname in _QT_LANG_FILES.values():
_fpath = _qt_translations_dir / _fname
if _fpath.exists():
qt_translation_datas.append((str(_fpath), "PySide6/Qt/translations"))
# Boundary baseline (country/state only — generated by
# tools/boundaries/gsak_to_opensak.py; gitignored). Counties are never
# bundled: they're fetched on demand per country from OpenSAK-Data, same as
# a source checkout without a local data/ folder at all. Build runners must
# fetch/generate the baseline into data/ before invoking pyinstaller.
_data = Path("data")
boundary_datas: list[tuple[str, str]] = []
if (_data / "boundaries.db").exists():
boundary_datas = [
(str(_data / "boundaries.db"), "data"),
(str(_data / "countries"), "data/countries"),
(str(_data / "states"), "data/states"),
]
# Platform-specific icon
if sys.platform == "win32":
ICON = str(Path("assets/icons/opensak.ico"))
elif sys.platform == "darwin":
ICON = str(Path("assets/icons/opensak.icns"))
else:
ICON = str(Path("assets/icons/opensak.png"))
a = Analysis(
["run.py"],
pathex=["."],
binaries=[],
datas=[
("assets/icons/opensak.png", "assets/icons/"),
("assets/icons/opensak.ico", "assets/icons/"),
("assets/icons/opensak.icns", "assets/icons/"),
("src/opensak/lang/", "opensak/lang/"),
# Issue #519: bundled cache-type / found-smiley icon assets and the
# icon-naming guide. These were previously NOT listed here at all —
# meaning packaged builds (Windows/macOS/AppImage) silently fell
# back to the hand-coded fallback SVGs for every cache type/smiley,
# since _ASSETS_DIR only ever resolved correctly when running from
# a source checkout. Discovered while wiring up the icon guide
# button, fixed here rather than left for a future report.
("src/opensak/assets/icons/cache_types", "opensak/assets/icons/cache_types"),
("src/opensak/assets/icons/cache_found", "opensak/assets/icons/cache_found"),
("src/opensak/assets/icon_guide.html", "opensak/assets/icon_guide.html"),
] + certifi_datas + boundary_datas + qt_translation_datas,
hiddenimports=[
"PySide6.QtWebEngineWidgets",
"PySide6.QtWebEngineCore",
"sqlalchemy.dialects.sqlite",
"certifi",
"shapely",
"shapely.geometry",
],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name="opensak",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=ICON,
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name="opensak",
)
# macOS .app bundle
if sys.platform == "darwin":
app = BUNDLE(
coll,
name="OpenSAK.app",
icon=ICON,
bundle_identifier="dk.opensak.app",
info_plist={
"CFBundleDisplayName": "OpenSAK",
"CFBundleShortVersionString": "1.0.0",
"CFBundleVersion": "1.0.0",
"NSHighResolutionCapable": True,
"NSRequiresAquaSystemAppearance": False,
},
)