-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathbuild_sff.spec
More file actions
238 lines (212 loc) · 7.33 KB
/
Copy pathbuild_sff.spec
File metadata and controls
238 lines (212 loc) · 7.33 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# -*- mode: python ; coding: utf-8 -*-
# SteaMidra - Steam game setup and manifest tool (SFF)
# Copyright (c) 2025-2026 Midrag (https://github.com/Midrags)
#
# This file is part of SteaMidra.
#
# SteaMidra is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# SteaMidra is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with SteaMidra. If not, see <https://www.gnu.org/licenses/>.
#
# SteaMidra Build Configuration
#
# Expected warnings you can ignore:
# - "pkg_resources is deprecated" from win10toast / PyInstaller: from dependencies; build is fine.
# - "Hidden import tzdata not found": optional timezone data; safe to ignore unless you use timezone features.
import os
import sys
from pathlib import Path
from PyInstaller.utils.hooks import collect_data_files
block_cipher = None
def _validate_rich_packaging(hidden_imports, data_entries):
"""Abort the build before Analysis runs if rich packaging is incomplete.
The frozen DLC check loads `rich._unicode_data` lazily; missing it has
crashed users in the past. The validator catches the regression at spec
load time so a bad spec never produces an artifact.
"""
required_hidden = ("rich._unicode_data", "rich.box", "rich.text")
missing_hidden = [name for name in required_hidden if name not in hidden_imports]
if missing_hidden:
raise SystemExit(
"build_sff.spec validation failed: hiddenimports is missing "
+ ", ".join(missing_hidden)
)
has_rich_data = False
for entry in data_entries:
if isinstance(entry, tuple) and len(entry) == 2:
src, dst = entry
if "rich" in str(src) or "rich" in str(dst):
has_rich_data = True
break
if not has_rich_data:
raise SystemExit(
"build_sff.spec validation failed: collect_data_files('rich', "
"include_py_files=False) must contribute to datas"
)
# Get the directory where this spec file is located (where Main.py, sff.ico, etc. live)
spec_root = os.path.abspath(SPECPATH)
icon_path = os.path.join(spec_root, 'SFF.ico')
# Find win10toast data directory
def get_win10toast_data():
"""Get win10toast data directory for inclusion"""
try:
import win10toast
win10toast_dir = os.path.dirname(win10toast.__file__)
data_dir = os.path.join(win10toast_dir, 'data')
if os.path.exists(data_dir):
return (data_dir, 'win10toast/data')
except Exception as e:
print(f"Warning: Could not find win10toast data: {e}")
return None
# Collect data files
datas = [
]
# Include third_party tools if present
third_party_dir = os.path.join(spec_root, 'third_party')
if os.path.exists(third_party_dir):
datas.append((third_party_dir, 'third_party'))
# DLC unlocker bundled resources (CreamAPI, SmokeAPI, Koaloader, UplayR1/R2 DLLs)
dlc_resources_dir = os.path.join(spec_root, 'sff', 'dlc_unlockers', 'resources')
if os.path.exists(dlc_resources_dir):
datas.append((dlc_resources_dir, 'sff/dlc_unlockers/resources'))
# Lua depot keys / tokens (required for manifest depot key operations)
lua_dir = os.path.join(spec_root, 'sff', 'lua')
if os.path.exists(lua_dir):
datas.append((lua_dir, 'sff/lua'))
# MIDI player library, soundfont, and MIDI files
c_dir = os.path.join(spec_root, 'c')
if os.path.exists(c_dir):
datas.append((c_dir, 'c'))
# Add icon assets if they exist
if os.path.exists(os.path.join(spec_root, 'SFF.png')):
datas.append(('SFF.png', '.'))
if os.path.exists(os.path.join(spec_root, 'SFF.ico')):
datas.append(('SFF.ico', '.'))
# Include all_games.txt for offline game name resolution in Cloud Saves
all_games_txt = os.path.join(spec_root, 'all_games.txt')
if os.path.exists(all_games_txt):
datas.append((all_games_txt, '.'))
# Bundle the offline store catalog (SteamTools GameList + steamappidlist
# name maps). Without this a fresh install has an empty Store until the
# GitHub mirrors are fetched — "Stray" and friends would not show up.
store_metadata_dir = os.path.join(spec_root, 'store_metadata')
if os.path.isdir(store_metadata_dir):
datas.append((store_metadata_dir, 'store_metadata'))
# Add win10toast data
win10toast_data = get_win10toast_data()
if win10toast_data:
datas.append(win10toast_data)
print(f"Including win10toast data from: {win10toast_data[0]}")
# Bundle the rich package's data files (including _unicode_data tables) so the
# DLC check path stays import-clean inside the frozen build.
datas.extend(collect_data_files("rich", include_py_files=False))
hiddenimports = [
'InquirerPy',
'prompt_toolkit',
'selenium',
'selenium.webdriver',
'selenium.webdriver.chrome',
'selenium.webdriver.chrome.service',
'selenium.webdriver.chrome.options',
'selenium.webdriver.common.by',
'selenium.webdriver.common.keys',
'selenium.webdriver.support',
'selenium.webdriver.support.ui',
'selenium.webdriver.support.expected_conditions',
'selenium.common.exceptions',
'steam',
'steam.client',
'gevent',
'sff.manifest.collections',
'sff.manifest.workshop_tracker',
'sff.cloud.cloud_saves',
'sff.cloud.google_drive',
'sff.core._gc',
'google.auth',
'google.auth.transport.requests',
'google.oauth2.credentials',
'google_auth_oauthlib',
'google_auth_oauthlib.flow',
'googleapiclient',
'googleapiclient.discovery',
'googleapiclient.http',
'sff.game.fix_game.online_fix_applier',
'sff.linux.steam_process',
'psutil',
'colorama',
'httpx',
'keyring',
'cryptography',
'win10toast',
'seleniumbase',
'undetected_chromedriver',
'bs4',
'bs4.builder',
'bs4.builder._html5lib',
'bs4.builder._lxml',
'bs4.builder._htmlparser',
'rich._unicode_data',
'rich.box',
'rich.text',
# pkg_resources.py2_warn / pkg_resources.markers removed: not present in newer setuptools
]
_validate_rich_packaging(hiddenimports, datas)
a = Analysis(
['Main.py'],
pathex=[spec_root],
binaries=[],
datas=datas,
hiddenimports=hiddenimports,
hookspath=['hooks'],
hooksconfig={},
runtime_hooks=[],
excludes=[
'tkinter',
'matplotlib',
'numpy',
'pandas',
'scipy',
'PIL',
],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
exclude_binaries=True,
name='SteaMidra',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
upx_exclude=[],
console=True, # IMPORTANT: Must be True for interactive prompts!
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=icon_path if os.path.exists(icon_path) else None,
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
upx_exclude=[],
name='SteaMidra',
)