from pathlib import Path import bpy from .blendjob import BlenderJobRuntime from .server import server DEFAULT_STORAGE_ROOT = Path.home() / ".snapform" def configured_storage_root(): addon = bpy.context.preferences.addons.get(__package__) configured = getattr(getattr(addon, "preferences", None), "storage_root", "") if configured: return Path(bpy.path.abspath(configured)) return DEFAULT_STORAGE_ROOT ENVIRONMENT = { "python": "3.12", "packages": [ "numpy==2.4.2", "pillow==12.1.1", "av==17.0.0", "trimesh==4.11.2", "huggingface-hub==1.4.1", ], "platform_packages": { "windows": ["onnxruntime-directml==1.24.4"], "default": ["onnxruntime==1.24.4"], }, } def post_install(job_runtime): errors = [] for model in ("MOGE2_VITS_NORMAL", "BEN2_BASE"): try: job_runtime.request("download-model", {"model": model}) except RuntimeError as error: errors.append(str(error)) if errors: raise RuntimeError("; ".join(errors)) runtime = BlenderJobRuntime( server, storage_root=configured_storage_root, environment=ENVIRONMENT, post_install=post_install, ) JobOperatorBase = runtime.JobOperatorBase