File size: 1,150 Bytes
5a8e268
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
from __future__ import annotations

import importlib
import json
import sys
from pathlib import Path

import runtime_bootstrap

root = runtime_bootstrap.activate(Path(__file__).resolve().parent)
mods = [
    "numpy",
    "soundfile",
    "torch",
    "transformers",
    "fish_audio_s2_runtime",
]
optional_mods = [
    "fish_speech",
]
report = {"root": str(root), "imports": {}}
for name in mods:
    try:
        module = importlib.import_module(name)
        report["imports"][name] = {"ok": True, "file": getattr(module, "__file__", None), "required": True}
    except Exception as exc:
        report["imports"][name] = {"ok": False, "error": repr(exc), "required": True}
for name in optional_mods:
    try:
        module = importlib.import_module(name)
        report["imports"][name] = {"ok": True, "file": getattr(module, "__file__", None), "required": False}
    except Exception as exc:
        report["imports"][name] = {"ok": False, "error": repr(exc), "required": False}
print(json.dumps(report, ensure_ascii=False, indent=2))
if not all(item["ok"] for item in report["imports"].values() if item.get("required", True)):
    sys.exit(1)