forked from J-M-PUNK/tideway
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTideway-mac.spec
More file actions
215 lines (198 loc) · 6.77 KB
/
Copy pathTideway-mac.spec
File metadata and controls
215 lines (198 loc) · 6.77 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
# -*- mode: python ; coding: utf-8 -*-
#
# macOS PyInstaller spec. Build with:
# pyinstaller Tideway-mac.spec --noconfirm
#
# Produces dist/Tideway.app — a proper .app bundle. Distributing
# outside the App Store still requires:
# 1. A Developer ID Application certificate.
# 2. codesign --deep --options runtime --sign "<Team ID>" dist/Tideway.app
# 3. Notarization via `xcrun notarytool submit ... --wait` then
# `xcrun stapler staple dist/Tideway.app`.
# Without notarization, Gatekeeper blocks the app on a user's first
# launch and the only bypass is right-click → Open.
#
# Prerequisite: run `npm --prefix web run build` first.
from pathlib import Path
from PyInstaller.utils.hooks import collect_all
block_cipher = None
repo_root = Path(SPECPATH).resolve()
dist_dir = repo_root / "web" / "dist"
# Single-source version read from the repo-root VERSION file so the
# spec's Info.plist, the FastAPI /api/version endpoint, and the
# frontend update-check banner all agree. Defaults to "0.0.0" if the
# file is missing (keeps the build running on a fresh checkout).
_version_file = repo_root / "VERSION"
APP_VERSION = _version_file.read_text().strip() if _version_file.is_file() else "0.0.0"
if not dist_dir.is_dir():
raise SystemExit(
f"web/dist not found at {dist_dir}. Run "
f"`npm --prefix web run build` first."
)
datas = [
(str(dist_dir), "web/dist"),
]
# Ship the VERSION file so server.py's _read_app_version() can find it
# when running frozen. Lives at the bundle root; spec path "." stages
# into <bundle>/Contents/Frameworks at runtime (that's _MEIPASS).
if _version_file.is_file():
datas.append((str(_version_file), "."))
# Audio + video I/O is handled entirely by PyAV (libav), which
# ships its own libav binaries in its wheel — no external ffmpeg
# needed anywhere in the app.
binaries: list[tuple[str, str]] = []
# Pull pydantic_core's Rust extension in explicitly — default static
# analysis misses the .so and the app crashes on import at launch.
# Same applies to async-upnp-client's transitive stack (aiohttp + its
# C extensions, yarl, multidict, frozenlist, defusedxml,
# python-didl-lite, voluptuous) — the UPnP discovery path imports
# them on a daemon thread at startup and missing submodules there
# show up as a SIGTRAP on Thread-N with no other clue.
for pkg in (
"pydantic",
"pydantic_core",
"async_upnp_client",
"aiohttp",
"yarl",
"multidict",
"frozenlist",
"defusedxml",
"didl_lite",
"voluptuous",
# curl-cffi ships its own libcurl-impersonate dylib + a CFFI
# binding that PyInstaller's static analysis routinely misses.
# Without this the packaged app falls back to plain requests
# silently, losing the TLS-fingerprint match. Also serves as the
# transport for spotapi via app/spotify_curl_session.py — see
# below for why we no longer bundle tls_client.
"curl_cffi",
# NOTE: tls_client is intentionally NOT bundled. spotapi imports
# it transitively, but its `tls-client-{arch}.dylib` Go-CGO
# library panics with STATUS_BREAKPOINT on first request and
# crashes the app. app/spotify_curl_session.py installs no-op
# stubs for the `tls_client` module tree at startup and routes
# spotapi's requests through curl-cffi instead. Skipping the
# collect_all here keeps the broken dylib out of the bundle.
):
try:
_d, _b, _h = collect_all(pkg)
datas += _d
binaries += _b
except Exception:
# Optional deps the project will boot without (async-upnp-client
# is flagged optional in app/audio/upnp.py) shouldn't break the
# build if the user hasn't installed them.
pass
hiddenimports = [
"tidalapi",
"tidalapi.album",
"tidalapi.artist",
"tidalapi.media",
"tidalapi.page",
"tidalapi.playlist",
"tidalapi.user",
"uvicorn.logging",
"uvicorn.loops.auto",
"uvicorn.protocols.http.auto",
"uvicorn.protocols.websockets.auto",
"uvicorn.lifespan.on",
"sse_starlette",
"webview.platforms.cocoa",
# async-upnp-client + transitive hidden imports. collect_all
# above pulls most of these as data, but several submodules
# are loaded dynamically (async_upnp_client.search picks a
# backend at runtime) and need to be spelled out explicitly.
"async_upnp_client",
"async_upnp_client.search",
"async_upnp_client.aiohttp",
"async_upnp_client.client_factory",
"aiohttp",
"aiohttp.resolver",
"yarl",
"multidict",
"frozenlist",
"didl_lite",
"voluptuous",
"defusedxml",
"defusedxml.ElementTree",
# Global media-key listener dependencies. pynput's macOS backend
# pulls Quartz via pyobjc; PyInstaller's static analysis misses
# the dynamic import.
"pynput",
"pynput.keyboard",
"pynput.keyboard._darwin",
"Quartz",
"AppKit",
"Foundation",
# curl-cffi-backed transport for spotapi. Imported lazily inside
# app.spotify_public._ensure_client; declare explicitly so
# PyInstaller's static analysis picks it up regardless of whether
# the function-body import is traced.
"app.spotify_curl_session",
]
a = Analysis(
["desktop.py"],
pathex=[str(repo_root)],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
# tkinter isn't imported by anything we ship, but Python's stdlib
# _includes_ it, so PyInstaller will happily bundle it unless we
# say otherwise. Exclude to keep the bundle lean.
excludes=[
"tkinter",
],
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
icon_path = repo_root / "assets" / "icon.icns"
icon_arg = str(icon_path) if icon_path.is_file() else None
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name="Tideway",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=False,
disable_windowed_traceback=False,
argv_emulation=True,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=icon_arg,
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=False,
upx_exclude=[],
name="Tideway",
)
app = BUNDLE(
coll,
name="Tideway.app",
icon=icon_arg,
bundle_identifier="com.tidaldownloader.app",
info_plist={
# LSUIElement=False means a proper Dock icon + menu bar; the
# default True would make us a background-only agent.
"LSUIElement": False,
"CFBundleName": "Tideway",
"CFBundleDisplayName": "Tideway",
"CFBundleShortVersionString": APP_VERSION,
"CFBundleVersion": APP_VERSION,
# Required by pywebview's WKWebView backend on modern macOS.
"NSHighResolutionCapable": True,
},
)