131 lines
3.4 KiB
Python
Executable File
131 lines
3.4 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""
|
|
Install ComfyUI-TrellisMac dependencies into the current Python environment.
|
|
|
|
Run this with the same Python that launches ComfyUI. For example:
|
|
|
|
/path/to/ComfyUI/.venv/bin/python custom_nodes/ComfyUI-TrellisMac/install.py \
|
|
--trellis-mac /path/to/trellis-mac
|
|
|
|
After this succeeds, keep launching ComfyUI normally.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import argparse
|
|
import json
|
|
import os
|
|
import platform
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parent
|
|
CONFIG_FILE = ROOT / "config.json"
|
|
|
|
|
|
PYPI_DEPS = [
|
|
"accelerate",
|
|
"easydict",
|
|
"huggingface_hub",
|
|
"safetensors",
|
|
"pillow",
|
|
"numpy",
|
|
"trimesh",
|
|
"scipy",
|
|
"tqdm",
|
|
"timm",
|
|
"transformers",
|
|
"kornia",
|
|
"imageio",
|
|
"opencv-python-headless",
|
|
"xatlas",
|
|
"fast-simplification",
|
|
]
|
|
|
|
METAL_DEPS = [
|
|
"deps/mtlbvh",
|
|
"deps/mtldiffrast",
|
|
"deps/mtlmesh",
|
|
"deps/mtlgemm",
|
|
"deps/trellis2-apple/o-voxel",
|
|
]
|
|
|
|
|
|
def run(cmd: list[str], env: dict[str, str] | None = None) -> None:
|
|
print("+", " ".join(cmd), flush=True)
|
|
subprocess.check_call(cmd, env=env)
|
|
|
|
|
|
def looks_like_trellis_mac(path: Path) -> bool:
|
|
return (path / "TRELLIS.2" / "trellis2").is_dir() and (path / "stubs").is_dir()
|
|
|
|
|
|
def save_config(trellis_mac: Path) -> None:
|
|
CONFIG_FILE.write_text(
|
|
json.dumps({"trellis_mac_path": str(trellis_mac)}, indent=2) + "\n",
|
|
encoding="utf-8",
|
|
)
|
|
|
|
|
|
def main() -> int:
|
|
parser = argparse.ArgumentParser(
|
|
description="Install ComfyUI-TrellisMac dependencies into the current Python environment."
|
|
)
|
|
parser.add_argument(
|
|
"--trellis-mac",
|
|
required=True,
|
|
help="Path to a completed trellis-mac checkout.",
|
|
)
|
|
parser.add_argument(
|
|
"--skip-metal",
|
|
action="store_true",
|
|
help="Skip local Metal packages. Export will use the slower KDTree fallback.",
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
trellis_mac = Path(args.trellis_mac).expanduser().resolve()
|
|
if not looks_like_trellis_mac(trellis_mac):
|
|
raise SystemExit(
|
|
f"{trellis_mac} does not look like trellis-mac. "
|
|
"Expected TRELLIS.2/trellis2 and stubs/."
|
|
)
|
|
|
|
print(f"Python: {sys.executable}")
|
|
print(f"trellis-mac: {trellis_mac}")
|
|
if platform.machine() != "arm64":
|
|
print("WARNING: this node pack targets Apple Silicon (arm64).")
|
|
|
|
run([sys.executable, "-m", "pip", "install", *PYPI_DEPS])
|
|
run([sys.executable, "-m", "pip", "install", str(trellis_mac / "deps" / "utils3d")])
|
|
|
|
if not args.skip_metal:
|
|
run([sys.executable, "-m", "pip", "install", "setuptools", "wheel", "pybind11"])
|
|
env = os.environ.copy()
|
|
env.setdefault("MACOSX_DEPLOYMENT_TARGET", "12.0")
|
|
run(
|
|
[
|
|
sys.executable,
|
|
"-m",
|
|
"pip",
|
|
"install",
|
|
"--no-build-isolation",
|
|
*[str(trellis_mac / rel) for rel in METAL_DEPS],
|
|
],
|
|
env=env,
|
|
)
|
|
|
|
save_config(trellis_mac)
|
|
|
|
print("\nInstall complete.")
|
|
print(f"Wrote {CONFIG_FILE}")
|
|
print("Run doctor.py with the same Python to verify the setup:")
|
|
print(f" {sys.executable} {ROOT / 'doctor.py'}")
|
|
print("\nYou can keep launching ComfyUI normally after this.")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|