-
-
Notifications
You must be signed in to change notification settings - Fork 139
Expand file tree
/
Copy pathAudioMuse-AI.spec
More file actions
154 lines (135 loc) · 4.93 KB
/
Copy pathAudioMuse-AI.spec
File metadata and controls
154 lines (135 loc) · 4.93 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
# -*- mode: python ; coding: utf-8 -*-
import glob
import importlib.util
import os
import platform
import sys
from PyInstaller.utils.hooks import collect_data_files, collect_dynamic_libs, collect_submodules
ROOT = SPECPATH
NATIVE = os.path.join(ROOT, "native-build")
sys.path.insert(0, NATIVE)
_cfg_path = os.path.join(ROOT, "scripts", "standalone", "config.py")
_cfg_spec = importlib.util.spec_from_file_location("_amai_build_config", _cfg_path)
_cfg = importlib.util.module_from_spec(_cfg_spec)
_cfg_spec.loader.exec_module(_cfg)
target = _cfg.resolve_target(os.environ.get("AUDIOMUSE_BUILD_TARGET"))
cfg = _cfg.PLATFORMS[target]
arch = _cfg.normalize_arch(platform.machine(), target)
USE_PGSERVER = _cfg.use_pgserver(cfg["use_pgserver"], arch)
_app_ver = _cfg.read_app_version(ROOT)
if cfg["bundle"]:
cfg["bundle"]["info_plist"]["CFBundleShortVersionString"] = _app_ver or "0.0.0"
datas = [
(os.path.join(ROOT, "templates"), "templates"),
(os.path.join(ROOT, "static"), "static"),
(os.path.join(ROOT, "model"), "model"),
(os.path.join(ROOT, "mood_centroids_real_080_clap.json"), "."),
# The plugins admin page lives in the blueprint's own template folder; without
# this entry every native build 500s with TemplateNotFound on /plugins.
(os.path.join(ROOT, "plugin", "templates"), os.path.join("plugin", "templates")),
]
for _src, _dst in cfg["extra_datas"]:
datas.append((os.path.join(ROOT, _src), _dst))
if USE_PGSERVER:
try:
datas += collect_data_files("pgserver")
except Exception:
USE_PGSERVER = False
if not USE_PGSERVER:
datas += [(os.path.join(ROOT, cfg["vendor_dir"], "postgres", arch), "pgsql")]
for _pkg in ("librosa", "resampy", "flasgger", "wn", "langdetect"):
datas += collect_data_files(_pkg)
datas += collect_data_files("transformers", include_py_files=False)
binaries = [
(os.path.join(ROOT, cfg["vendor_dir"], "redis", arch, cfg["redis_bin"]), "."),
]
for _pkg in ("av", "psycopg2"):
binaries += collect_dynamic_libs(_pkg)
# Chromaprint's fpcalc: bundled only if vendored. Absent, the standalone build still
# runs; it just ships without acoustic-fingerprint collection (dedup falls back to the
# MusiCNN embedding + duration exactly as before). See native-build/<os>/vendor/README.
_fpcalc = os.path.join(
ROOT, cfg["vendor_dir"], "fpcalc", arch,
"fpcalc.exe" if target == "windows" else "fpcalc",
)
if os.path.exists(_fpcalc):
binaries.append((_fpcalc, "."))
# numkong's Windows wheel links LLVM's libomp but, unlike its mac/linux wheels, does not bundle it.
if target == "windows":
_omp = os.path.join(ROOT, cfg["vendor_dir"], "numkong", arch, _cfg.windows_omp_dll(arch))
if not os.path.exists(_omp):
raise SystemExit(f"Missing vendored OpenMP runtime: {_omp} "
"(see native-build/windows/vendor/README.md).")
binaries.append((_omp, "numkong"))
if USE_PGSERVER:
_pg_contrib = os.path.join(ROOT, cfg["vendor_dir"], "pg-contrib", arch)
_pg_dst = "pgserver/pginstall"
for _f in glob.glob(os.path.join(_pg_contrib, "extension", "*")):
datas.append((_f, f"{_pg_dst}/share/postgresql/extension"))
for _f in glob.glob(os.path.join(_pg_contrib, "tsearch_data", "*")):
datas.append((_f, f"{_pg_dst}/share/postgresql/tsearch_data"))
for _f in glob.glob(os.path.join(_pg_contrib, "lib", cfg["pg_contrib_glob"])):
binaries.append((_f, f"{_pg_dst}/lib/postgresql"))
hiddenimports = [
"app",
"rq_worker",
"rq_worker_high_priority",
"rq_heartbeat_worker",
"rq_janitor",
"restart_listener",
"waitress",
"flasgger",
"numkong",
"numkong._numkong",
]
hiddenimports += cfg["extra_hiddenimports"]
for _mod in ("tasks", "lyrics", "sklearn", "joblib", *cfg["collect_submodules"]):
hiddenimports += collect_submodules(_mod)
hiddenimports = list(dict.fromkeys(hiddenimports))
excludes = list(cfg["excludes_base"])
if not USE_PGSERVER:
excludes.append("pgserver")
hiddenimports = [h for h in hiddenimports if not h.startswith("pgserver")]
a = Analysis(
[os.path.join(ROOT, cfg["launcher"])],
pathex=[ROOT, NATIVE],
binaries=binaries,
datas=datas,
hiddenimports=hiddenimports,
hookspath=[os.path.join(NATIVE, "macos", "hooks")],
hooksconfig={},
runtime_hooks=[],
excludes=excludes,
noarchive=False,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name="AudioMuse-AI",
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=False,
console=cfg["console"],
**({"icon": os.path.join(ROOT, cfg["exe_icon"])} if cfg["exe_icon"] else {}),
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=False,
name="AudioMuse-AI",
)
if cfg["bundle"]:
_b = cfg["bundle"]
app = BUNDLE(
coll,
name=_b["name"],
icon=os.path.join(ROOT, _b["icon"]),
bundle_identifier=_b["bundle_identifier"],
info_plist=_b["info_plist"],
)