Compare commits
2 commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b8c43ba3f | ||
|
|
7fce39f267 |
17 changed files with 2706 additions and 127 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
|
@ -14,6 +14,12 @@ release/
|
||||||
# not import rig.py at all ("No module named 'src.data'").
|
# not import rig.py at all ("No module named 'src.data'").
|
||||||
/data/
|
/data/
|
||||||
|
|
||||||
|
# Local reference ComfyUI install used to generate the managed-install artifacts
|
||||||
|
# (tools/gen-comfy-lock.mjs reads it; setup/comfyui.json + the lock are the only
|
||||||
|
# things that get committed). Multi-GB — code, a venv and models. Anchored to the
|
||||||
|
# repo root so it can't match anything nested.
|
||||||
|
/comfyui/
|
||||||
|
|
||||||
# Wiki author mode — presence of this file unlocks editing the Wiki.
|
# Wiki author mode — presence of this file unlocks editing the Wiki.
|
||||||
# Kept local (never synced) so the published docs are read-only for end users.
|
# Kept local (never synced) so the published docs are read-only for end users.
|
||||||
.wiki-author
|
.wiki-author
|
||||||
|
|
|
||||||
438
docs/COMFYUI_MANAGED.md
Normal file
438
docs/COMFYUI_MANAGED.md
Normal file
|
|
@ -0,0 +1,438 @@
|
||||||
|
# Managed ComfyUI (desktop app)
|
||||||
|
|
||||||
|
The desktop app can install and run its **own** ComfyUI, so a new user doesn't
|
||||||
|
have to set one up by hand. It becomes a third Python service alongside Mesh
|
||||||
|
Tools and Rigging: its own uv-provisioned venv in the per-user data dir, started
|
||||||
|
on demand, stoppable from Settings.
|
||||||
|
|
||||||
|
Users who already run their own ComfyUI are unaffected — the managed install is
|
||||||
|
opt-in and only writes `apis.comfyui.*` when they choose it.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Layout
|
||||||
|
|
||||||
|
Everything lives under the per-user data dir (`app.getPath('userData')`, or
|
||||||
|
`GENSTUDIO_DATA_ROOT`), because the installed app folder is read-only on
|
||||||
|
macOS/Linux and under `C:\Program Files` on Windows.
|
||||||
|
|
||||||
|
| Path | Contents |
|
||||||
|
| :--- | :--- |
|
||||||
|
| `<data>/comfyui/` | ComfyUI code + `custom_nodes/` (replaceable) |
|
||||||
|
| `<data>/comfy-venv/` | The Python environment |
|
||||||
|
| `<data>/comfy-data/` | `models/`, `input/`, `output/`, `user/` — ComfyUI's `--base-directory` |
|
||||||
|
| `<data>/logs/comfyui.log` | Service output |
|
||||||
|
|
||||||
|
Code and data are deliberately separate: reinstalling or upgrading ComfyUI never
|
||||||
|
touches the multi-GB model downloads.
|
||||||
|
|
||||||
|
On a successful install the app sets:
|
||||||
|
|
||||||
|
```
|
||||||
|
apis.comfyui.managed = true <- "this install is ours to start/stop"
|
||||||
|
apis.comfyui.path = <data>/comfyui
|
||||||
|
apis.comfyui.modelsPath = <data>/comfy-data/models
|
||||||
|
apis.comfyui.port = first free port from 8188
|
||||||
|
```
|
||||||
|
|
||||||
|
`managed` is what distinguishes it from a user-supplied ComfyUI. The port is
|
||||||
|
picked at install time so it never collides with a ComfyUI the user already runs.
|
||||||
|
|
||||||
|
Models are **not** installed here — the existing in-app Setup Wizard downloads
|
||||||
|
them, and it reads `path`/`modelsPath`, so it targets this install automatically.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Why a lock file, not per-pack `requirements.txt`
|
||||||
|
|
||||||
|
A working ComfyUI is a specific ~355-package resolution plus a handful of
|
||||||
|
hand-built CUDA wheels. Resolving each node pack's `requirements.txt` on the
|
||||||
|
user's machine drifts — numpy 2 vs 1.26, transformers majors, torch ABI — and is
|
||||||
|
the single most common way a ComfyUI install ends up subtly broken.
|
||||||
|
|
||||||
|
So the app ships a **lock generated from a known-good environment** and installs
|
||||||
|
it as one atomic resolution:
|
||||||
|
|
||||||
|
```
|
||||||
|
setup/comfyui.json manifest: ComfyUI pin, node packs, builds
|
||||||
|
setup/comfyui-lock-windows-py313-cu130.txt the resolved dependency set
|
||||||
|
```
|
||||||
|
|
||||||
|
`torch` is excluded from the lock and installed first from its own CUDA index —
|
||||||
|
the lock carries no index-url context, and every prebuilt wheel in it is
|
||||||
|
ABI-matched to exactly that torch version.
|
||||||
|
|
||||||
|
## No git, no compiler
|
||||||
|
|
||||||
|
- Node packs download as **pinned GitHub tarballs** (`/archive/<sha>.tar.gz`),
|
||||||
|
extracted by a small pure-Node ustar walk in `electron/comfysetup.cjs`. No git
|
||||||
|
binary, no zip library, no platform-specific `tar`.
|
||||||
|
- `git+https://…@<sha>` dependencies in the lock are rewritten to the equivalent
|
||||||
|
tarball URL for the same reason.
|
||||||
|
- Every binary dependency is a prebuilt wheel, from one of two places:
|
||||||
|
- **inside a node repo** (`ComfyUI-Trellis2/wheels/**`) — the download brings
|
||||||
|
it along, nothing to host;
|
||||||
|
- **`wheelHost`** — hand-built wheels with no upstream home.
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> Because node packs are tarballs rather than git checkouts, ComfyUI-Manager
|
||||||
|
> cannot update them in place. Upgrades happen by regenerating the manifest and
|
||||||
|
> shipping a new app version.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## The reference environment
|
||||||
|
|
||||||
|
The artifacts are generated from a real, working ComfyUI install. The repo's own
|
||||||
|
reference env lives at `comfyui/` (gitignored — it's multi-GB code + venv +
|
||||||
|
models, and only `setup/comfyui.json` and the lock get committed):
|
||||||
|
|
||||||
|
```
|
||||||
|
comfyui/ ComfyUI v0.29.0
|
||||||
|
comfyui/venv/ Python 3.13 · torch 2.10.0+cu130
|
||||||
|
comfyui/custom_nodes/ exactly the 11 shipped packs
|
||||||
|
```
|
||||||
|
|
||||||
|
Keeping the reference env minimal matters: the lock is a freeze of whatever is
|
||||||
|
installed there, so extra packs mean extra install weight for every user. This env
|
||||||
|
yields **230 packages**; one with 28 packs installed yielded 355.
|
||||||
|
|
||||||
|
## Which node packs ship
|
||||||
|
|
||||||
|
Only the packs the bundled workflows actually need — **11**:
|
||||||
|
|
||||||
|
| Pack | Nodes used |
|
||||||
|
| :--- | :--- |
|
||||||
|
| ComfyUI-Trellis2 | 21 |
|
||||||
|
| ComfyUI-Hunyuan3DWrapper | 6 |
|
||||||
|
| ComfyUI-Hunyuan3d-2-1 | 5 |
|
||||||
|
| ComfyUI_essentials | 4 |
|
||||||
|
| ComfyUI-KJNodes | 3 |
|
||||||
|
| ComfyUI-QwenVL | 2 |
|
||||||
|
| comfyui-flux2fun-controlnet | 2 |
|
||||||
|
| comfyui_controlnet_aux | 1 |
|
||||||
|
| ComfyUI-RMBG | 1 |
|
||||||
|
| ComfyUI-GGUF | 1 |
|
||||||
|
| rgthree-comfy | Display Any, Image Comparer |
|
||||||
|
|
||||||
|
The rest are listed in `excludeNodes` and not shipped. Pruning them is also what
|
||||||
|
makes the `open3d` / `torch_scatter` / `torch_cluster` exclusions safe: LATO.2 and
|
||||||
|
ComfyUI-Tools import those at module level, so shipping them without the wheels
|
||||||
|
would log pack-load errors on every startup.
|
||||||
|
|
||||||
|
`ComfyUI-Manager` is excluded deliberately. It can't manage tarball-pinned packs
|
||||||
|
properly, and an "update all" would silently break the locked environment the
|
||||||
|
whole design depends on. Add it back to `customNodes` if you decide the
|
||||||
|
node-browsing UI is worth that risk.
|
||||||
|
|
||||||
|
### What `ref` means
|
||||||
|
|
||||||
|
Each entry's `ref` is an exact commit SHA, and the installer downloads
|
||||||
|
`github.com/<repo>/archive/<ref>.tar.gz`. It is a **hard pin**: pushing to a
|
||||||
|
pack's default branch changes nothing for users until `ref` is updated here. That
|
||||||
|
is the point — it's what makes installs reproducible — but it has three
|
||||||
|
consequences worth internalising:
|
||||||
|
|
||||||
|
- Updating a pack means bumping `ref`, not just pushing.
|
||||||
|
- **Uncommitted work in the reference checkout never ships.** The tarball contains
|
||||||
|
the commit, not your working tree, so the reference env can run a workflow
|
||||||
|
perfectly while users get a pack missing that code.
|
||||||
|
- A `ref` that isn't on a remote branch makes the archive URL 404 for every user.
|
||||||
|
|
||||||
|
The generator checks the last two and reports them (`UNPUSHED COMMITS` is fatal,
|
||||||
|
locally-modified tracked files are a warning). Since it derives `ref` from each
|
||||||
|
checkout's `HEAD`, hand-editing a `ref` here is undone by the next run — move the
|
||||||
|
checkout to the commit you want pinned instead.
|
||||||
|
|
||||||
|
> [!CAUTION]
|
||||||
|
> When adding a bundled workflow that uses a new pack, add the pack to
|
||||||
|
> `customNodes` (or remove it from `excludeNodes`) by hand. The generator does
|
||||||
|
> **not** infer this from the workflows — a heuristic mapper would eventually drop
|
||||||
|
> a pack that IS needed, which fails much worse than shipping one too many. Note
|
||||||
|
> that `ComfyUI_essentials`, `rgthree-comfy` and the SAM3 packs register their
|
||||||
|
> nodes indirectly, so a naive grep for a class name gives false negatives; and
|
||||||
|
> `SAM3_Detect`, `TextEncodeBooguEdit`, `ImageScaleToMaxDimension` and `Preview3D`
|
||||||
|
> are ComfyUI **core**, not custom packs.
|
||||||
|
|
||||||
|
### Keep the reference env in sync
|
||||||
|
|
||||||
|
`excludeNodes` only stops a pack being *shipped*; it does not stop its
|
||||||
|
dependencies leaking into the lock, because the lock is a freeze of whatever is
|
||||||
|
installed in the reference env. So when you drop a pack from `customNodes`, also
|
||||||
|
uninstall it from `comfyui/custom_nodes/` (and rebuild the venv if its deps are
|
||||||
|
heavy) before regenerating.
|
||||||
|
|
||||||
|
## Regenerating after a ComfyUI or node upgrade
|
||||||
|
|
||||||
|
Run this against a reference env where ComfyUI **and all the packs the bundled
|
||||||
|
workflows need** actually work:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
node tools/gen-comfy-lock.mjs \
|
||||||
|
--comfy ./comfyui \
|
||||||
|
--venv ./comfyui/venv \
|
||||||
|
--cuda 13.0
|
||||||
|
```
|
||||||
|
|
||||||
|
The script exits non-zero and prints an `INCOMPLETE REFERENCE ENV` banner if any
|
||||||
|
`verifyImports` module can't be imported there — that means the lock it just wrote
|
||||||
|
cannot produce a working install, so fix the env (or reclassify the module) and
|
||||||
|
re-run. Don't commit a lock that produced that banner.
|
||||||
|
|
||||||
|
It rewrites `setup/comfyui.json` and the matching lock, and preserves the
|
||||||
|
hand-maintained fields (`wheelHost`, `launchArgs`, `verifyImports`). The lock is
|
||||||
|
platform-specific, so run it once per platform you ship; each run merges its
|
||||||
|
build into the manifest rather than replacing the others.
|
||||||
|
|
||||||
|
The script reports three things you should read every time:
|
||||||
|
|
||||||
|
- **git dependencies rewritten to tarballs** — informational.
|
||||||
|
- **`custom_nodes` folders that are not GitHub checkouts** — these are SKIPPED.
|
||||||
|
They can't be reproduced on a user's machine.
|
||||||
|
- **hand-built wheels with no upstream download** — see below.
|
||||||
|
|
||||||
|
### Hosted wheels
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> The current Windows build needs **none** — `hostedWheels` is empty and
|
||||||
|
> `wheelHost` is unset. This section applies only if a future build reintroduces a
|
||||||
|
> package with no installable upstream wheel.
|
||||||
|
|
||||||
|
Some CUDA extensions have no installable upstream build for the pinned
|
||||||
|
Python/torch combination. The generator lists them and the installer refuses to
|
||||||
|
start until they're reachable, so a missing wheel fails in seconds rather than 20
|
||||||
|
minutes into a torch download.
|
||||||
|
|
||||||
|
1. Publish the wheels somewhere with stable URLs (GitHub release assets work).
|
||||||
|
2. Set `wheelHost` in `setup/comfyui.json` to the base URL serving them.
|
||||||
|
|
||||||
|
Entries marked `BUILD FIRST` were compiled from source in the reference
|
||||||
|
environment (`pip install .`), so no wheel exists yet — build one with
|
||||||
|
`pip wheel <source dir>` and publish it under the exact filename the generator
|
||||||
|
printed. Before doing that, check whether the package is actually needed: several
|
||||||
|
CUDA extensions are imported lazily or inside `try/except`, and belong in
|
||||||
|
`optionalImports` / `excludePackages` instead (see below).
|
||||||
|
|
||||||
|
### Required vs optional modules
|
||||||
|
|
||||||
|
The installer's final step imports two lists from the manifest:
|
||||||
|
|
||||||
|
| Field | On failure | For |
|
||||||
|
| :--- | :--- | :--- |
|
||||||
|
| `verifyImports` | **fails the install** | wheels the bundled workflows genuinely need |
|
||||||
|
| `optionalImports` | logged as `optional`, install proceeds | capabilities that degrade rather than break |
|
||||||
|
|
||||||
|
A third field, `excludePackages`, drops a package from the generated lock
|
||||||
|
entirely. Use it for something optional that has no publishable wheel — otherwise
|
||||||
|
every install would depend on hosting a wheel nothing needs.
|
||||||
|
|
||||||
|
Currently classified optional, with the evidence:
|
||||||
|
|
||||||
|
| Package | Why it's optional |
|
||||||
|
| :--- | :--- |
|
||||||
|
| `natten` | Only the `TencentARC/Pixal3D-T` model needs it. Nothing in ComfyUI-Trellis2 imports it; `transformers` declares it as an *extra*, not a dependency. No bundled workflow uses that model. Kept in the Windows lock because the wheel ships inside the Trellis2 repo and costs nothing. |
|
||||||
|
| `custom_rasterizer` | In-function import (`mesh_render.py:161`, Hy 2.1 `MeshRender.py:373`) on the Hunyuan **texture-paint** path. The bundled Hunyuan workflows are "Gen Mesh Only" and never reach it; the node packs load fine without it. |
|
||||||
|
| `mesh_inpaint_processor` | Wrapped in `try/except` (Hy 2.1 `MeshRender.py:36`). |
|
||||||
|
| `udf_ext` | Nothing in the tree imports it by name. |
|
||||||
|
| `open3d` | **Cannot be installed at all on Python 3.13** — the newest release (0.19.0) publishes cp38–cp312 wheels only, on every platform. Excluded rather than merely optional. In ComfyUI-Trellis2 only `Trellis2PostProcessMesh` and `Trellis2LaplacianSmoothingWithOpen3d` use it, both in-function, and no bundled workflow uses either node. Every other importer belongs to a pack we don't ship. |
|
||||||
|
| `torch_cluster` | Top-level import only in ComfyUI-Tools (`unirig`), a pack no bundled workflow needs. In the Hunyuan packs it's an in-function import in the point-cloud FPS encoder, which the image→mesh workflows don't reach. |
|
||||||
|
| `torch_scatter` | Top-level import only in ComfyUI-LATO.2 and ComfyUI-Tools — neither needed by a bundled workflow. |
|
||||||
|
|
||||||
|
| `diso` | Only the `dmc` surface-extraction path uses it (`DMCSurfaceExtractor.run` → `from diso import DiffDMC`, lazy). The bundled Hunyuan workflows set `mc_algo: "mc"`, which routes to `MCSurfaceExtractor` → `skimage.measure.marching_cubes` (scikit-image is in the lock). Switch a workflow back to `"dmc"` and you must ship a `diso` wheel again. |
|
||||||
|
|
||||||
|
Dropped entirely (not even probed — nothing in the tree references them):
|
||||||
|
`autoretopo`, `drtk`.
|
||||||
|
|
||||||
|
**Net result: the Windows build needs no hosted wheels at all.** `wheelHost` can
|
||||||
|
stay empty; every binary dependency either comes from PyPI, from the CUDA torch
|
||||||
|
index, from inside the ComfyUI-Trellis2 repo, or from the flash-attn table.
|
||||||
|
|
||||||
|
### flash-attn comes from the shared wheel table
|
||||||
|
|
||||||
|
flash-attn is **not** in the lock and needs no hosting. It's selected at install
|
||||||
|
time from the same curated tables the rigging service uses:
|
||||||
|
|
||||||
|
```
|
||||||
|
thirdparty/skintokens/flash_attention_windows.txt
|
||||||
|
thirdparty/skintokens/flash_attention_linux.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
One table to maintain for both services, and those wheels are already hosted.
|
||||||
|
The match is on **torch version AND CUDA**, not CUDA alone — the wheel is
|
||||||
|
ABI-bound to a specific torch, and this build's torch is fixed by the prebuilt
|
||||||
|
CUDA wheels in the lock. A CUDA-only match could return a wheel for a different
|
||||||
|
torch that installs cleanly and dies at `import`.
|
||||||
|
|
||||||
|
The wheel is downloaded to disk first and then installed from the local file:
|
||||||
|
pip/uv cannot resolve Hugging Face Xet URLs (they 403), but a plain
|
||||||
|
redirect-following GET fetches them fine.
|
||||||
|
|
||||||
|
> [!IMPORTANT]
|
||||||
|
> If a build's torch version has no row in the table, the install fails with a
|
||||||
|
> message naming the version and what the table does offer. This is the situation
|
||||||
|
> a Linux build will hit — see below.
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Hunyuan3DWrapper's own `mesh_processor` needs no wheel either: it ships a pure
|
||||||
|
> Python `mesh_processor.py` beside a cp312 `.pyd`, and on cp313 the `.pyd`'s ABI
|
||||||
|
> tag doesn't match, so Python loads the `.py`.
|
||||||
|
|
||||||
|
### Validating that the packs still load
|
||||||
|
|
||||||
|
The strongest check available offline: start ComfyUI with `--quick-test-for-ci`
|
||||||
|
(loads every node, then exits) and confirm each node class the bundled workflows
|
||||||
|
use is registered. To prove a package really is unnecessary, shadow it with a stub
|
||||||
|
that raises `ImportError` and re-run — that simulates a user's machine where it was
|
||||||
|
never installed.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# a stub dir that makes `import open3d` fail, plus a hook that dumps the registry
|
||||||
|
mkdir -p stub/open3d
|
||||||
|
echo 'raise ImportError("simulated absence")' > stub/open3d/__init__.py
|
||||||
|
cat > stub/sitecustomize.py <<'EOF'
|
||||||
|
import atexit, os
|
||||||
|
def dump():
|
||||||
|
import nodes
|
||||||
|
open(os.environ['NODE_DUMP'], 'w', encoding='utf-8').write('\n'.join(sorted(nodes.NODE_CLASS_MAPPINGS)))
|
||||||
|
atexit.register(dump)
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cd comfyui
|
||||||
|
PYTHONPATH=../stub NODE_DUMP=../registered.txt PYTHONIOENCODING=utf-8 \
|
||||||
|
./venv/Scripts/python.exe main.py --quick-test-for-ci --cpu
|
||||||
|
# then diff the workflow node classes against registered.txt
|
||||||
|
```
|
||||||
|
|
||||||
|
Verified this way with **both `open3d` and `diso` absent**: all 11 packs load and
|
||||||
|
every workflow node class registers (0 missing of 95). `PYTHONIOENCODING=utf-8`
|
||||||
|
matters — without it ComfyUI's logger crashes on non-ASCII output under some
|
||||||
|
consoles and the run exits 1 for reasons unrelated to node loading.
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> Don't check the registry by calling `nodes.init_extra_nodes()` from your own
|
||||||
|
> script. rgthree-comfy needs `PromptServer.instance`, which only exists once
|
||||||
|
> main.py has created the server, so it silently fails to register and you get
|
||||||
|
> false "missing node" results.
|
||||||
|
|
||||||
|
**One known pre-existing gap:** `AILab_QwenVL_GGUF_PromptEnhancer` fails to load
|
||||||
|
(`No module named 'llama_cpp'`). No bundled workflow uses it, and the rest of
|
||||||
|
ComfyUI-QwenVL loads fine, so it's left alone — add `llama-cpp-python` to the
|
||||||
|
reference env if you ever ship a workflow using that node.
|
||||||
|
|
||||||
|
### Validating a regenerated lock without a full install
|
||||||
|
|
||||||
|
`materializeLock` and `verifyHostedWheels` are exported for this:
|
||||||
|
|
||||||
|
```js
|
||||||
|
const cs = require('./electron/comfysetup.cjs');
|
||||||
|
const m = cs.loadManifest('.');
|
||||||
|
m.wheelHost = 'file:///C:/Git/ComfyUI'; // stand-in for a real host
|
||||||
|
const build = cs.pickBuild(m);
|
||||||
|
const lock = cs.materializeLock({ appRoot: '.', build, manifest: m,
|
||||||
|
installDir: 'C:/Git/ComfyUI', venvDir: process.env.TEMP });
|
||||||
|
// then: uv pip install --python <throwaway venv> --dry-run -r <lock>
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Install sequence
|
||||||
|
|
||||||
|
`electron/comfysetup.cjs` → `setupComfyUI()`:
|
||||||
|
|
||||||
|
1. Pick the build row matching this platform and the driver's CUDA (newest build
|
||||||
|
the driver can run — same rule as the rigging wheel table).
|
||||||
|
2. **Verify every hosted wheel is reachable** (HEAD requests) — before any large download.
|
||||||
|
3. `uv python install <pythonVersion>` → `uv venv`.
|
||||||
|
4. Download ComfyUI, then each pinned node pack. Node packs come first because
|
||||||
|
the lock references wheels that live inside them.
|
||||||
|
5. Install torch from its CUDA index.
|
||||||
|
6. Install the materialized lock.
|
||||||
|
7. **Import-check** `verifyImports`. A wheel built against a different torch ABI
|
||||||
|
installs cleanly and only fails at `import` with `undefined symbol: …`;
|
||||||
|
catching it here beats a mystery node-import failure later.
|
||||||
|
8. Create the data folders, write the readiness marker, write the settings.
|
||||||
|
|
||||||
|
## Platform support
|
||||||
|
|
||||||
|
| Platform | Status |
|
||||||
|
| :--- | :--- |
|
||||||
|
| Windows x64 | Build shipped (Python 3.13, torch 2.10.0+cu130) |
|
||||||
|
| Linux x64 | **No build yet** — needs a generator run on Linux |
|
||||||
|
| macOS | Not possible (no CUDA) |
|
||||||
|
|
||||||
|
The install option is **hidden** on any platform without a shipped build:
|
||||||
|
`setup:status` reports `comfyuiAvailable`, and both the first-run screen and the
|
||||||
|
Settings card gate on it. A user on an unsupported platform is told to install
|
||||||
|
ComfyUI themselves and set the path/port, rather than being offered an install
|
||||||
|
that fails.
|
||||||
|
|
||||||
|
### Adding Linux
|
||||||
|
|
||||||
|
A Linux build is a separate generator run on a Linux machine with a working
|
||||||
|
ComfyUI — the lock can't be synthesised from the Windows one, because wheels are
|
||||||
|
platform-tagged (`win_amd64` vs `linux_x86_64`) and **the torch version differs**.
|
||||||
|
Each run merges into `builds`, so adding Linux doesn't disturb Windows.
|
||||||
|
|
||||||
|
Two things to know before starting:
|
||||||
|
|
||||||
|
- **ComfyUI-Trellis2's Linux cp313 wheels are built for torch 2.11.0**, not the
|
||||||
|
2.10.0 the Windows build pins (`wheels/Linux/Torch2110/`). The Linux build will
|
||||||
|
therefore be a different torch version — that's fine, the lock and the wheels
|
||||||
|
just have to agree with each other.
|
||||||
|
- Those Linux cp313 wheels are missing `custom_rasterizer` and `natten` — but
|
||||||
|
**neither is a blocker**: both are classified optional (see above), so a Linux
|
||||||
|
build simply won't have them and the install still succeeds. Nothing needs
|
||||||
|
building for cp313/torch-2.11 on their account.
|
||||||
|
|
||||||
|
- **`flash_attention_linux.txt` currently lists torch 2.13.0 only**, so a Linux
|
||||||
|
build pinned to torch 2.11 will fail flash-attn selection with a clear message.
|
||||||
|
Add a `2.11.0;<cuda>;<wheel url>;<torch install cmd>` row to that table (it is
|
||||||
|
shared with the rigging service, so keep the existing rows intact).
|
||||||
|
|
||||||
|
## Gotchas found the hard way
|
||||||
|
|
||||||
|
**Never pass `--base-directory`.** It relocates `custom_nodes` along with
|
||||||
|
everything else, and `main.py`'s `execute_prestartup_script()` then does
|
||||||
|
`os.listdir(<base>/custom_nodes)` and dies with `FileNotFoundError` before the
|
||||||
|
server binds. The node packs live next to the code in `<installDir>/custom_nodes`.
|
||||||
|
Use the per-directory flags instead (`--models-directory`, `--input-directory`,
|
||||||
|
`--output-directory`, `--user-directory`, `--temp-directory`) — each documents
|
||||||
|
"Overrides --base-directory", so they move exactly what we want. Note
|
||||||
|
`--user-directory` and `--models-directory` are validated with
|
||||||
|
`is_valid_directory`, which **rejects a path that doesn't exist**, so the launcher
|
||||||
|
creates all five before spawning.
|
||||||
|
|
||||||
|
**Ship exactly one opencv distribution.** `opencv-python`,
|
||||||
|
`opencv-contrib-python` and their two `-headless` variants all install into the
|
||||||
|
same `cv2/` package and overwrite each other — the build you end up with depends
|
||||||
|
on install order, which is not deterministic. With all four in the lock, the
|
||||||
|
reference env happened to get the contrib build and a fresh managed install got
|
||||||
|
the plain one, so `ComfyUI-Hunyuan3DWrapper` failed to import with
|
||||||
|
`cannot import name 'guidedFilter' from 'cv2.ximgproc'`. The lock now excludes
|
||||||
|
all but `opencv-contrib-python` (the superset that provides `ximgproc`). Watch for
|
||||||
|
this whenever a node pack's `requirements.txt` adds an opencv variant.
|
||||||
|
|
||||||
|
**Spawn Python services with `PYTHONIOENCODING=utf-8`.** We capture stdout and
|
||||||
|
stderr through pipes, and for a pipe Python defaults to the ANSI codepage on
|
||||||
|
Windows (cp1252) rather than utf-8. Several node packs log emoji at import time —
|
||||||
|
rgthree's `Loaded 48 fantastic nodes. 🎉` — which raises `UnicodeEncodeError`
|
||||||
|
inside `logging` and **kills ComfyUI with exit code 1** partway through loading.
|
||||||
|
It presents as a mystery startup crash, and it does not reproduce in a terminal
|
||||||
|
(where stdout is a console, so Python picks utf-8). Both launchers now set
|
||||||
|
`PYTHONIOENCODING=utf-8` and `PYTHONUTF8=1`.
|
||||||
|
|
||||||
|
**A crash used to look like a hang, then like a healthy service.** `ensureService`
|
||||||
|
now races the health poll against the process exiting, so a service that dies on
|
||||||
|
startup reports its exit code and the last lines of its output immediately instead
|
||||||
|
of after the full 180-second health timeout. It also clears the handle when the
|
||||||
|
process exits — `serviceStatus()` reports `running` from the handle's existence, so
|
||||||
|
a dead service used to keep showing "Running" in Settings.
|
||||||
|
|
||||||
|
## Requirements and limits
|
||||||
|
|
||||||
|
- **NVIDIA GPU required.** macOS is refused outright (no CUDA) — point Settings →
|
||||||
|
ComfyUI at an instance on another machine instead.
|
||||||
|
- The driver must support the CUDA version of at least one build in the manifest.
|
||||||
|
- Health probe is `/system_stats` (ComfyUI has no `/health`), wired through the
|
||||||
|
registry's per-service `healthPath`.
|
||||||
|
- Override CUDA detection for testing with `GENSTUDIO_COMFY_CUDA=12.8`.
|
||||||
664
electron/comfysetup.cjs
Normal file
664
electron/comfysetup.cjs
Normal file
|
|
@ -0,0 +1,664 @@
|
||||||
|
// Provision and launch a MANAGED ComfyUI install for the desktop app.
|
||||||
|
//
|
||||||
|
// ComfyUI becomes a third Python service alongside Mesh Tools and Rigging: its
|
||||||
|
// own uv-provisioned venv in the per-user data dir, started on demand, stoppable
|
||||||
|
// from Settings. Users who already run their own ComfyUI are untouched — this
|
||||||
|
// only fills in apis.comfyui.* when they opt into the managed install.
|
||||||
|
//
|
||||||
|
// Two things make this reliable rather than a coin flip:
|
||||||
|
//
|
||||||
|
// 1. A LOCK, not per-pack resolution. A working ComfyUI is a specific ~355
|
||||||
|
// package resolution plus hand-built CUDA wheels; re-resolving each node
|
||||||
|
// pack's requirements.txt on the user's machine drifts (numpy 2 vs 1.26,
|
||||||
|
// transformers majors, torch ABI) and is the usual way an install breaks.
|
||||||
|
// setup/comfyui-lock-*.txt is generated from a known-good env by
|
||||||
|
// tools/gen-comfy-lock.mjs and installed as one atomic resolution.
|
||||||
|
// 2. No git, no compiler. Node packs come down as pinned GitHub tarballs, and
|
||||||
|
// every binary dependency is a prebuilt wheel — either one shipped inside a
|
||||||
|
// node repo (ComfyUI-Trellis2/wheels/**) or one served from the manifest's
|
||||||
|
// wheelHost. Reachability of the hosted set is checked BEFORE the multi-GB
|
||||||
|
// torch download, so a missing wheel fails in seconds, not 20 minutes.
|
||||||
|
//
|
||||||
|
// Models are NOT installed here. They live under the data dir (ComfyUI runs with
|
||||||
|
// --base-directory) and are downloaded by the existing in-app Setup Wizard, which
|
||||||
|
// is pointed at this install automatically.
|
||||||
|
|
||||||
|
const path = require('node:path');
|
||||||
|
const fs = require('node:fs');
|
||||||
|
const https = require('node:https');
|
||||||
|
const zlib = require('node:zlib');
|
||||||
|
const { spawn, spawnSync } = require('node:child_process');
|
||||||
|
|
||||||
|
const { runStream, ensureVenv, venvPython, depsMarker, killTree } = require('./pysetup.cjs');
|
||||||
|
|
||||||
|
const IS_WIN = process.platform === 'win32';
|
||||||
|
const IS_MAC = process.platform === 'darwin';
|
||||||
|
|
||||||
|
// Bump when the provisioning STEPS change in a way that needs a re-run. The lock
|
||||||
|
// filename already changes when dependencies change, and the marker records it,
|
||||||
|
// so a regenerated lock re-triggers setup on its own.
|
||||||
|
const COMFY_SETUP_TAG = 'comfyui-1';
|
||||||
|
|
||||||
|
// ---- manifest ---------------------------------------------------------------
|
||||||
|
function loadManifest(appRoot) {
|
||||||
|
const p = path.join(appRoot, 'setup', 'comfyui.json');
|
||||||
|
const raw = fs.readFileSync(p, 'utf8');
|
||||||
|
const manifest = JSON.parse(raw);
|
||||||
|
if (!manifest?.comfyui?.repo || !manifest?.comfyui?.ref) {
|
||||||
|
throw new Error('setup/comfyui.json is missing comfyui.repo / comfyui.ref.');
|
||||||
|
}
|
||||||
|
return manifest;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Max CUDA the installed NVIDIA driver can run, as a major.minor float. Same
|
||||||
|
// source of truth as the rigging setup's select_flash_attn.py, done in Node here
|
||||||
|
// because the pick has to happen before a Python exists.
|
||||||
|
function driverCuda() {
|
||||||
|
const override = process.env.GENSTUDIO_COMFY_CUDA;
|
||||||
|
if (override) {
|
||||||
|
const forced = cudaKey(override);
|
||||||
|
if (forced != null) return forced;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const r = spawnSync('nvidia-smi', [], { encoding: 'utf8', timeout: 20000 });
|
||||||
|
if (r.status !== 0 || !r.stdout) return null;
|
||||||
|
const m = r.stdout.match(/CUDA(?:\s+\w+)?\s+Version:\s*(\d+)\.(\d+)/);
|
||||||
|
return m ? Number(`${m[1]}.${m[2]}`) : null;
|
||||||
|
} catch {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Normalise a CUDA string ("13", "13.0", "13.0.0") to a comparable float.
|
||||||
|
function cudaKey(text) {
|
||||||
|
const m = String(text).match(/\s*(\d+)(?:\.(\d+))?/);
|
||||||
|
return m ? Number(`${m[1]}.${m[2] || 0}`) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function platformKey() {
|
||||||
|
return IS_WIN ? 'windows' : IS_MAC ? 'macos' : 'linux';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is a managed install even possible on THIS platform? The dependency lock is a
|
||||||
|
// resolution captured from a real machine — wheels are platform-tagged, and the
|
||||||
|
// torch version differs per platform — so a build has to be generated on each
|
||||||
|
// platform we ship (see docs/COMFYUI_MANAGED.md). The UI uses this to hide the
|
||||||
|
// install option rather than offering one that cannot succeed.
|
||||||
|
function isAvailableHere(manifest) {
|
||||||
|
if (IS_MAC) return false;
|
||||||
|
try {
|
||||||
|
const m = manifest || {};
|
||||||
|
return (m.builds || []).some((b) => b.platform === platformKey());
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pick the newest CUDA build this driver can actually run, mirroring the rigging
|
||||||
|
// wheel-table logic: a build targeting CUDA newer than the driver will not run,
|
||||||
|
// an older one will.
|
||||||
|
function pickBuild(manifest) {
|
||||||
|
if (IS_MAC) {
|
||||||
|
throw new Error('The managed ComfyUI install needs an NVIDIA GPU (CUDA), which macOS does not provide. Point Settings → ComfyUI at a ComfyUI instance on another machine instead.');
|
||||||
|
}
|
||||||
|
const plat = platformKey();
|
||||||
|
const builds = (manifest.builds || []).filter((b) => b.platform === plat);
|
||||||
|
if (!builds.length) {
|
||||||
|
const have = [...new Set((manifest.builds || []).map((b) => b.platform))].join(', ') || 'none';
|
||||||
|
throw new Error(`The managed ComfyUI install is not available on ${plat} yet — this build of the app only ships a dependency set for: ${have}. Install ComfyUI yourself and point Settings → ComfyUI at it.`);
|
||||||
|
}
|
||||||
|
const cuda = driverCuda();
|
||||||
|
if (cuda == null) {
|
||||||
|
throw new Error('No NVIDIA GPU / CUDA driver detected. The managed ComfyUI install requires one.');
|
||||||
|
}
|
||||||
|
const usable = builds.filter((b) => {
|
||||||
|
const k = cudaKey(b.cuda);
|
||||||
|
return k != null && k <= cuda + 1e-6;
|
||||||
|
});
|
||||||
|
if (!usable.length) {
|
||||||
|
const avail = builds.map((b) => b.cuda).join(', ');
|
||||||
|
throw new Error(`Your NVIDIA driver supports CUDA ${cuda}, which is older than every available build (${avail}). Update your GPU driver and try again.`);
|
||||||
|
}
|
||||||
|
return usable.reduce((best, b) => (cudaKey(b.cuda) > cudaKey(best.cuda) ? b : best));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- HTTP -------------------------------------------------------------------
|
||||||
|
// Follow redirects (GitHub's /archive/ URLs bounce to codeload) and hand back the
|
||||||
|
// response stream. Rejects on a non-2xx so callers get a real error instead of an
|
||||||
|
// HTML error page written to disk as a "tarball".
|
||||||
|
function httpGet(url, redirectsLeft = 6) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const req = https.get(url, { headers: { 'User-Agent': '3DGenStudio-desktop' } }, (res) => {
|
||||||
|
const { statusCode, headers } = res;
|
||||||
|
if (statusCode >= 300 && statusCode < 400 && headers.location) {
|
||||||
|
res.resume();
|
||||||
|
if (redirectsLeft <= 0) return reject(new Error(`Too many redirects for ${url}`));
|
||||||
|
const next = new URL(headers.location, url).toString();
|
||||||
|
return resolve(httpGet(next, redirectsLeft - 1));
|
||||||
|
}
|
||||||
|
if (statusCode !== 200) {
|
||||||
|
res.resume();
|
||||||
|
return reject(new Error(`HTTP ${statusCode} for ${url}`));
|
||||||
|
}
|
||||||
|
resolve(res);
|
||||||
|
});
|
||||||
|
req.on('error', reject);
|
||||||
|
req.setTimeout(120000, () => req.destroy(new Error(`Timed out fetching ${url}`)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Cheap reachability probe. A HEAD is enough to prove a wheel URL resolves; some
|
||||||
|
// hosts (HF, GitHub release assets) answer HEAD with a redirect chain, which
|
||||||
|
// httpGet-style following handles.
|
||||||
|
function urlExists(url, redirectsLeft = 6) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
let settled = false;
|
||||||
|
const done = (v) => { if (!settled) { settled = true; resolve(v); } };
|
||||||
|
let req;
|
||||||
|
try {
|
||||||
|
req = https.request(url, { method: 'HEAD', headers: { 'User-Agent': '3DGenStudio-desktop' } }, (res) => {
|
||||||
|
res.resume();
|
||||||
|
const { statusCode, headers } = res;
|
||||||
|
if (statusCode >= 300 && statusCode < 400 && headers.location && redirectsLeft > 0) {
|
||||||
|
const next = new URL(headers.location, url).toString();
|
||||||
|
return urlExists(next, redirectsLeft - 1).then(done);
|
||||||
|
}
|
||||||
|
done(statusCode === 200);
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
return done(false);
|
||||||
|
}
|
||||||
|
req.on('error', () => done(false));
|
||||||
|
req.setTimeout(30000, () => { req.destroy(); done(false); });
|
||||||
|
req.end();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- tar.gz extraction ------------------------------------------------------
|
||||||
|
// GitHub serves every ref as a .tar.gz, so a pinned node pack needs no git binary
|
||||||
|
// and no zip library — just gunzip plus a ustar walk. Implemented here rather
|
||||||
|
// than shelling out because neither `tar` (GNU tar can't do zip, bsdtar isn't
|
||||||
|
// everywhere) nor an npm dependency is reliable across all three platforms.
|
||||||
|
//
|
||||||
|
// `strip` drops leading path components: GitHub wraps everything in a
|
||||||
|
// "<repo>-<sha>/" directory we don't want on disk.
|
||||||
|
async function extractTarGz(url, destDir, { strip = 1, onLine } = {}) {
|
||||||
|
const emit = (s) => { if (onLine) try { onLine(s); } catch { /* ignore */ } };
|
||||||
|
emit(`fetching ${url}\n`);
|
||||||
|
const res = await httpGet(url);
|
||||||
|
const gz = await new Promise((resolve, reject) => {
|
||||||
|
const chunks = [];
|
||||||
|
res.on('data', (c) => chunks.push(c));
|
||||||
|
res.on('end', () => resolve(Buffer.concat(chunks)));
|
||||||
|
res.on('error', reject);
|
||||||
|
});
|
||||||
|
const buf = zlib.gunzipSync(gz);
|
||||||
|
fs.mkdirSync(destDir, { recursive: true });
|
||||||
|
|
||||||
|
let offset = 0;
|
||||||
|
let files = 0;
|
||||||
|
// Set by a preceding GNU 'L' entry or a pax 'x' header; overrides the (100
|
||||||
|
// byte) name field for the NEXT entry only.
|
||||||
|
let pendingName = null;
|
||||||
|
|
||||||
|
while (offset + 512 <= buf.length) {
|
||||||
|
const header = buf.subarray(offset, offset + 512);
|
||||||
|
// Two consecutive zero blocks mark the end of the archive.
|
||||||
|
if (header.every((b) => b === 0)) break;
|
||||||
|
offset += 512;
|
||||||
|
|
||||||
|
const readStr = (start, len) => {
|
||||||
|
const slice = header.subarray(start, start + len);
|
||||||
|
const end = slice.indexOf(0);
|
||||||
|
return slice.subarray(0, end === -1 ? slice.length : end).toString('utf8');
|
||||||
|
};
|
||||||
|
const readOctal = (start, len) => {
|
||||||
|
const s = readStr(start, len).trim();
|
||||||
|
return s ? parseInt(s, 8) || 0 : 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
const rawName = readStr(0, 100);
|
||||||
|
const size = readOctal(124, 12);
|
||||||
|
const type = String.fromCharCode(header[156] || 48);
|
||||||
|
const prefix = readStr(345, 155);
|
||||||
|
const padded = Math.ceil(size / 512) * 512;
|
||||||
|
const body = buf.subarray(offset, offset + size);
|
||||||
|
offset += padded;
|
||||||
|
|
||||||
|
// GNU long name: the entry body IS the next entry's path.
|
||||||
|
if (type === 'L') {
|
||||||
|
pendingName = body.toString('utf8').replace(/\0+$/, '');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// pax extended header: "<len> path=<value>\n" records.
|
||||||
|
if (type === 'x' || type === 'X') {
|
||||||
|
const text = body.toString('utf8');
|
||||||
|
const m = text.match(/\d+ path=([^\n]+)\n/);
|
||||||
|
if (m) pendingName = m[1];
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (type === 'g') continue; // pax_global_header — GitHub emits one first
|
||||||
|
|
||||||
|
let name = pendingName || (prefix ? `${prefix}/${rawName}` : rawName);
|
||||||
|
pendingName = null;
|
||||||
|
name = name.replace(/\\/g, '/');
|
||||||
|
|
||||||
|
const parts = name.split('/').filter(Boolean).slice(strip);
|
||||||
|
if (!parts.length) continue;
|
||||||
|
// Refuse anything that escapes destDir — a tarball is untrusted input.
|
||||||
|
if (parts.some((p) => p === '..')) {
|
||||||
|
throw new Error(`Refusing to extract path traversal entry: ${name}`);
|
||||||
|
}
|
||||||
|
const target = path.join(destDir, ...parts);
|
||||||
|
|
||||||
|
if (type === '5') {
|
||||||
|
fs.mkdirSync(target, { recursive: true });
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (type !== '0' && type !== '\0' && String.fromCharCode(header[156]) !== '\0') {
|
||||||
|
// Skip links/devices/fifos — node packs contain none, and silently not
|
||||||
|
// creating them beats failing the whole install.
|
||||||
|
if (type !== '0') continue;
|
||||||
|
}
|
||||||
|
fs.mkdirSync(path.dirname(target), { recursive: true });
|
||||||
|
fs.writeFileSync(target, body);
|
||||||
|
files += 1;
|
||||||
|
}
|
||||||
|
emit(`extracted ${files} file(s) to ${destDir}\n`);
|
||||||
|
if (!files) throw new Error(`Archive at ${url} contained no files.`);
|
||||||
|
return files;
|
||||||
|
}
|
||||||
|
|
||||||
|
function archiveUrl(repo, ref) {
|
||||||
|
return `https://github.com/${repo}/archive/${ref}.tar.gz`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Stream a URL to disk. Used for the flash-attn wheel: pip/uv cannot resolve
|
||||||
|
// Hugging Face Xet URLs directly (they 403), but a plain redirect-following GET
|
||||||
|
// downloads them fine — so fetch first, then install the local file.
|
||||||
|
async function downloadFile(url, destPath, onLine) {
|
||||||
|
const emit = (s) => { if (onLine) try { onLine(s); } catch { /* ignore */ } };
|
||||||
|
emit(`downloading ${url}\n`);
|
||||||
|
const res = await httpGet(url);
|
||||||
|
fs.mkdirSync(path.dirname(destPath), { recursive: true });
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
const out = fs.createWriteStream(destPath);
|
||||||
|
res.pipe(out);
|
||||||
|
out.on('finish', resolve);
|
||||||
|
out.on('error', reject);
|
||||||
|
res.on('error', reject);
|
||||||
|
});
|
||||||
|
const size = fs.statSync(destPath).size;
|
||||||
|
emit(`saved ${path.basename(destPath)} (${(size / 1048576).toFixed(1)} MB)\n`);
|
||||||
|
if (size < 1024) throw new Error(`Download of ${url} produced a ${size}-byte file.`);
|
||||||
|
return destPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- flash-attn -------------------------------------------------------------
|
||||||
|
// flash-attn has no installable upstream build, so it comes from the SAME curated
|
||||||
|
// per-platform wheel table the rigging service uses
|
||||||
|
// (thirdparty/skintokens/flash_attention_{windows,linux}.txt). Reusing that table
|
||||||
|
// means one place to maintain, and its wheels are already hosted.
|
||||||
|
//
|
||||||
|
// The match is on BOTH torch version and CUDA, not CUDA alone: the wheel is
|
||||||
|
// ABI-bound to a specific torch, and this build's torch version is fixed by the
|
||||||
|
// prebuilt CUDA wheels the lock installs. Picking by CUDA alone could hand back a
|
||||||
|
// wheel for a different torch that installs cleanly and dies at import.
|
||||||
|
function flashAttnTablePath(appRoot) {
|
||||||
|
const file = IS_WIN ? 'flash_attention_windows.txt' : 'flash_attention_linux.txt';
|
||||||
|
return path.join(appRoot, 'thirdparty', 'skintokens', file);
|
||||||
|
}
|
||||||
|
|
||||||
|
// "torch==2.10.0 torchvision==... --index-url ..." -> "2.10.0"
|
||||||
|
function torchVersionOf(build) {
|
||||||
|
const m = String(build.torchArgs || '').match(/torch[=~]=([0-9][^\s]*)/);
|
||||||
|
return m ? m[1].replace(/\+.*$/, '') : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
function selectFlashAttn({ appRoot, build, onLine }) {
|
||||||
|
const tablePath = flashAttnTablePath(appRoot);
|
||||||
|
if (!fs.existsSync(tablePath)) {
|
||||||
|
throw new Error(`Missing flash-attn wheel table: ${path.basename(tablePath)}`);
|
||||||
|
}
|
||||||
|
const wantTorch = torchVersionOf(build);
|
||||||
|
if (!wantTorch) {
|
||||||
|
throw new Error('Could not read the torch version from this build\'s torchArgs.');
|
||||||
|
}
|
||||||
|
const driver = driverCuda();
|
||||||
|
if (driver == null) throw new Error('No NVIDIA GPU / CUDA driver detected.');
|
||||||
|
|
||||||
|
const rows = [];
|
||||||
|
for (const line of fs.readFileSync(tablePath, 'utf8').split(/\r?\n/)) {
|
||||||
|
const t = line.trim();
|
||||||
|
if (!t || t.toLowerCase().startsWith('torch;')) continue;
|
||||||
|
const parts = t.split(';').map((s) => s.trim());
|
||||||
|
if (parts.length < 3) continue;
|
||||||
|
const cuda = cudaKey(parts[1]);
|
||||||
|
if (cuda == null) continue;
|
||||||
|
rows.push({ torch: parts[0].replace(/^~=/, ''), cuda, url: parts[2] });
|
||||||
|
}
|
||||||
|
|
||||||
|
const sameTorch = rows.filter((r) => r.torch === wantTorch);
|
||||||
|
if (!sameTorch.length) {
|
||||||
|
const have = [...new Set(rows.map((r) => r.torch))].join(', ') || 'none';
|
||||||
|
throw new Error(`${path.basename(tablePath)} has no flash-attn wheel for torch ${wantTorch} (it lists: ${have}). Add a matching row for this ComfyUI build, or change the build's torch version.`);
|
||||||
|
}
|
||||||
|
const usable = sameTorch.filter((r) => r.cuda <= driver + 1e-6);
|
||||||
|
if (!usable.length) {
|
||||||
|
const avail = sameTorch.map((r) => r.cuda).join(', ');
|
||||||
|
throw new Error(`Your NVIDIA driver supports CUDA ${driver}, older than every flash-attn wheel for torch ${wantTorch} (CUDA builds: ${avail}). Update your GPU driver.`);
|
||||||
|
}
|
||||||
|
const pick = usable.reduce((best, r) => (r.cuda > best.cuda ? r : best));
|
||||||
|
if (onLine) onLine(`flash-attn: torch ${pick.torch} / CUDA ${pick.cuda} (driver supports ${driver})\n`);
|
||||||
|
return pick.url;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- lock file --------------------------------------------------------------
|
||||||
|
// The lock ships with placeholders because neither path is known until install
|
||||||
|
// time. ${NODE_DIR} resolves to this install's custom_nodes (wheels that ride
|
||||||
|
// along inside a node repo) and ${WHEEL_HOST} to the manifest's wheel base URL.
|
||||||
|
function materializeLock({ appRoot, build, manifest, installDir, venvDir }) {
|
||||||
|
const src = path.join(appRoot, 'setup', build.lock);
|
||||||
|
if (!fs.existsSync(src)) {
|
||||||
|
throw new Error(`Missing dependency lock file: setup/${build.lock}`);
|
||||||
|
}
|
||||||
|
const wheelHost = String(manifest.wheelHost || '').replace(/\/+$/, '');
|
||||||
|
const text = fs.readFileSync(src, 'utf8');
|
||||||
|
|
||||||
|
if (text.includes('${WHEEL_HOST}') && !wheelHost) {
|
||||||
|
throw new Error('setup/comfyui.json has no "wheelHost", but the dependency lock needs prebuilt wheels from it. See tools/gen-comfy-lock.mjs for the list to publish.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// A local path becomes a file:// URL for pip; encode it so spaces and the "#"
|
||||||
|
// in a folder name like "CUDA 13.1" survive (an unencoded "#" would truncate
|
||||||
|
// the URL at the fragment).
|
||||||
|
const nodeDirUrl = pathToFileUrl(path.join(installDir, 'custom_nodes'));
|
||||||
|
const out = text
|
||||||
|
.replace(/\$\{NODE_DIR\}/g, nodeDirUrl)
|
||||||
|
.replace(/\$\{WHEEL_HOST\}/g, wheelHost);
|
||||||
|
|
||||||
|
const dest = path.join(venvDir, 'comfyui-lock.txt');
|
||||||
|
fs.mkdirSync(venvDir, { recursive: true });
|
||||||
|
fs.writeFileSync(dest, out);
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
|
||||||
|
function pathToFileUrl(p) {
|
||||||
|
const abs = path.resolve(p).replace(/\\/g, '/');
|
||||||
|
const withSlash = abs.startsWith('/') ? abs : `/${abs}`;
|
||||||
|
// encodeURI leaves '/' and ':' alone but escapes spaces; '#' needs doing by hand.
|
||||||
|
return `file://${encodeURI(withSlash).replace(/#/g, '%23')}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prove every ${WHEEL_HOST} wheel is actually downloadable before committing to
|
||||||
|
// a multi-GB torch install. A 404 here is a packaging mistake on our side and the
|
||||||
|
// message should say exactly which file is missing.
|
||||||
|
async function verifyHostedWheels({ build, manifest, onLine }) {
|
||||||
|
const files = build.hostedWheels || [];
|
||||||
|
if (!files.length) return;
|
||||||
|
const wheelHost = String(manifest.wheelHost || '').replace(/\/+$/, '');
|
||||||
|
const missing = [];
|
||||||
|
for (const file of files) {
|
||||||
|
const url = `${wheelHost}/${encodeURIComponent(file)}`;
|
||||||
|
const ok = await urlExists(url);
|
||||||
|
if (onLine) onLine(`${ok ? 'ok ' : 'MISSING '} ${file}\n`);
|
||||||
|
if (!ok) missing.push(file);
|
||||||
|
}
|
||||||
|
if (missing.length) {
|
||||||
|
throw new Error(`${missing.length} prebuilt wheel(s) are not available at ${wheelHost}: ${missing.join(', ')}. The managed ComfyUI install cannot complete without them.`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- provisioning -----------------------------------------------------------
|
||||||
|
// `onProgress` receives { kind:'phase'|'log'|'done'|'error', phase, pct, text },
|
||||||
|
// the same contract the other services use, so the setup window renders it with
|
||||||
|
// no special-casing.
|
||||||
|
async function setupComfyUI({ uv, appRoot, installDir, dataDir, venvDir, onProgress }) {
|
||||||
|
const emit = (e) => onProgress(e);
|
||||||
|
const log = (text) => emit({ kind: 'log', text });
|
||||||
|
const phase = (label, pct) => emit({ kind: 'phase', phase: label, pct });
|
||||||
|
|
||||||
|
const manifest = loadManifest(appRoot);
|
||||||
|
const build = pickBuild(manifest);
|
||||||
|
const pyVer = manifest.pythonVersion || '3.13';
|
||||||
|
const vp = venvPython(venvDir);
|
||||||
|
log(`Target: ComfyUI ${manifest.comfyui.tag || manifest.comfyui.ref.slice(0, 8)} · Python ${pyVer} · CUDA ${build.cuda}\n`);
|
||||||
|
|
||||||
|
phase('Checking prebuilt wheels', 0.01);
|
||||||
|
await verifyHostedWheels({ build, manifest, onLine: log });
|
||||||
|
|
||||||
|
phase('Provisioning Python', 0.04);
|
||||||
|
{
|
||||||
|
const r = await runStream(uv, ['python', 'install', pyVer], { onLine: log });
|
||||||
|
if (r.code !== 0) throw new Error(`Could not provision Python ${pyVer} (exit ${r.code}).`);
|
||||||
|
}
|
||||||
|
|
||||||
|
phase('Creating virtual environment', 0.08);
|
||||||
|
{
|
||||||
|
const code = await ensureVenv({ uv, serviceDir: appRoot, venvDir, onLine: log, pythonVersion: pyVer });
|
||||||
|
if (code !== 0) throw new Error(`Could not create the ComfyUI virtual environment (exit ${code}).`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ComfyUI itself, then the node packs, BEFORE the lock install — the lock
|
||||||
|
// references wheels that live inside ComfyUI-Trellis2/wheels/**, so those files
|
||||||
|
// have to be on disk first.
|
||||||
|
phase('Downloading ComfyUI', 0.12);
|
||||||
|
fs.mkdirSync(installDir, { recursive: true });
|
||||||
|
await extractTarGz(archiveUrl(manifest.comfyui.repo, manifest.comfyui.ref), installDir, { onLine: log });
|
||||||
|
|
||||||
|
const nodes = manifest.customNodes || [];
|
||||||
|
const nodesDir = path.join(installDir, 'custom_nodes');
|
||||||
|
fs.mkdirSync(nodesDir, { recursive: true });
|
||||||
|
for (let i = 0; i < nodes.length; i += 1) {
|
||||||
|
const node = nodes[i];
|
||||||
|
phase(`Downloading custom nodes (${i + 1}/${nodes.length}: ${node.name})`, 0.16 + 0.24 * (i / nodes.length));
|
||||||
|
const dest = path.join(nodesDir, node.name);
|
||||||
|
// Replace rather than merge: a half-extracted pack from an interrupted run
|
||||||
|
// would otherwise mix two refs.
|
||||||
|
try { fs.rmSync(dest, { recursive: true, force: true }); } catch { /* ignore */ }
|
||||||
|
await extractTarGz(archiveUrl(node.repo, node.ref), dest, { onLine: log });
|
||||||
|
}
|
||||||
|
|
||||||
|
// torch first, from its own CUDA index. The lock deliberately excludes torch:
|
||||||
|
// it carries no index-url context, and every prebuilt wheel in it is ABI-matched
|
||||||
|
// to exactly this torch version.
|
||||||
|
phase('Installing PyTorch', 0.42);
|
||||||
|
{
|
||||||
|
const torchArgs = String(build.torchArgs || '').trim().split(/\s+/).filter(Boolean);
|
||||||
|
if (!torchArgs.length) throw new Error('The selected build has no torchArgs in setup/comfyui.json.');
|
||||||
|
const r = await runStream(uv, ['pip', 'install', '--python', vp, ...torchArgs], { onLine: log });
|
||||||
|
if (r.code !== 0) throw new Error(`PyTorch install failed (exit ${r.code}).`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// flash-attn from the shared wheel table, ABI-matched to the torch just
|
||||||
|
// installed. Downloaded first because pip/uv can't resolve HF Xet URLs.
|
||||||
|
phase('Installing flash-attn', 0.5);
|
||||||
|
{
|
||||||
|
const url = selectFlashAttn({ appRoot, build, onLine: log });
|
||||||
|
const local = path.join(venvDir, 'wheels', decodeURIComponent(url.split('/').pop().split('?')[0]));
|
||||||
|
await downloadFile(url, local, log);
|
||||||
|
const r = await runStream(uv, ['pip', 'install', '--python', vp, local], { onLine: log });
|
||||||
|
if (r.code !== 0) throw new Error(`flash-attn install failed (exit ${r.code}).`);
|
||||||
|
}
|
||||||
|
|
||||||
|
phase('Installing ComfyUI dependencies', 0.6);
|
||||||
|
{
|
||||||
|
const lockPath = materializeLock({ appRoot, build, manifest, installDir, venvDir });
|
||||||
|
const r = await runStream(uv, ['pip', 'install', '--python', vp, '-r', lockPath], { onLine: log });
|
||||||
|
if (r.code !== 0) throw new Error(`Dependency install failed (exit ${r.code}). See details.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Prove the CUDA extensions actually LOAD. A wheel built against a different
|
||||||
|
// torch ABI installs cleanly and only dies at import with "undefined symbol",
|
||||||
|
// which would otherwise surface as a mystery node-import failure much later.
|
||||||
|
phase('Verifying install', 0.92);
|
||||||
|
{
|
||||||
|
const required = manifest.verifyImports || ['torch'];
|
||||||
|
// Optional modules are probed too, but only reported: these are guarded or
|
||||||
|
// in-function imports whose absence costs a specific feature rather than
|
||||||
|
// breaking the install (e.g. natten -> the Pixal3D-T model only).
|
||||||
|
const optional = manifest.optionalImports || [];
|
||||||
|
const probe = [
|
||||||
|
'import importlib, sys',
|
||||||
|
`required = ${JSON.stringify(required)}`,
|
||||||
|
`optional = ${JSON.stringify(optional)}`,
|
||||||
|
'bad = []',
|
||||||
|
'def probe(m):',
|
||||||
|
' try:',
|
||||||
|
' importlib.import_module(m)',
|
||||||
|
' return True',
|
||||||
|
' except Exception as e:',
|
||||||
|
' print(" ", type(e).__name__, e)',
|
||||||
|
' return False',
|
||||||
|
'for m in required:',
|
||||||
|
' if probe(m):',
|
||||||
|
' print("ok ", m)',
|
||||||
|
' else:',
|
||||||
|
' print("FAIL ", m)',
|
||||||
|
' bad.append(m)',
|
||||||
|
'for m in optional:',
|
||||||
|
' print(("ok " if probe(m) else "optional "), m)',
|
||||||
|
'sys.exit(1 if bad else 0)',
|
||||||
|
].join('\n');
|
||||||
|
const r = await runStream(vp, ['-c', probe], { cwd: installDir, onLine: log });
|
||||||
|
if (r.code !== 0) {
|
||||||
|
throw new Error('ComfyUI installed but some GPU modules will not import — most likely a torch ABI mismatch with a prebuilt wheel (see details).');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// The data dir is ComfyUI's --base-directory: models/, input/, output/, user/
|
||||||
|
// all live here. Kept separate from installDir so re-running setup never risks
|
||||||
|
// the multi-GB model downloads.
|
||||||
|
phase('Preparing data folders', 0.97);
|
||||||
|
for (const sub of ['models', 'input', 'output', 'user']) {
|
||||||
|
fs.mkdirSync(path.join(dataDir, sub), { recursive: true });
|
||||||
|
}
|
||||||
|
|
||||||
|
fs.writeFileSync(depsMarker(venvDir), `${COMFY_SETUP_TAG} ${build.lock} ${new Date().toISOString()}`);
|
||||||
|
phase('ComfyUI ready', 1);
|
||||||
|
emit({ kind: 'done' });
|
||||||
|
|
||||||
|
return { installDir, dataDir, modelsPath: path.join(dataDir, 'models') };
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- launcher ---------------------------------------------------------------
|
||||||
|
function startComfyUI({ appRoot, installDir, dataDir, venvDir, port, logStream, log }) {
|
||||||
|
const write = (s) => { try { logStream && logStream.write(s); } catch { /* ignore */ } };
|
||||||
|
const vp = venvPython(venvDir);
|
||||||
|
if (!fs.existsSync(vp) || !fs.existsSync(path.join(installDir, 'main.py'))) {
|
||||||
|
log && log('ComfyUI is not installed yet — skipping launch.');
|
||||||
|
return { stop() {} };
|
||||||
|
}
|
||||||
|
|
||||||
|
let extraArgs = [];
|
||||||
|
try {
|
||||||
|
extraArgs = loadManifest(appRoot).launchArgs || [];
|
||||||
|
} catch { /* manifest problems already surfaced during setup */ }
|
||||||
|
|
||||||
|
// Keep models/input/output/user/temp in the writable data dir so reinstalling
|
||||||
|
// ComfyUI never touches the user's models.
|
||||||
|
//
|
||||||
|
// Deliberately NOT --base-directory: that also relocates custom_nodes, and
|
||||||
|
// main.py's execute_prestartup_script() then does os.listdir(<base>/custom_nodes)
|
||||||
|
// and dies with FileNotFoundError before the server ever binds — the node packs
|
||||||
|
// live next to the code, in <installDir>/custom_nodes. These per-directory flags
|
||||||
|
// each document "Overrides --base-directory", so they move exactly what we want
|
||||||
|
// and leave custom_nodes resolving to the install dir.
|
||||||
|
const dirs = {
|
||||||
|
models: path.join(dataDir, 'models'),
|
||||||
|
input: path.join(dataDir, 'input'),
|
||||||
|
output: path.join(dataDir, 'output'),
|
||||||
|
user: path.join(dataDir, 'user'),
|
||||||
|
temp: path.join(dataDir, 'temp'),
|
||||||
|
};
|
||||||
|
// --user-directory and --models-directory are validated with is_valid_directory,
|
||||||
|
// which REJECTS a path that doesn't exist — so create them before launching
|
||||||
|
// (setup makes them too, but a user can delete them between runs).
|
||||||
|
for (const dir of Object.values(dirs)) {
|
||||||
|
try { fs.mkdirSync(dir, { recursive: true }); } catch { /* surfaced by the launch failing */ }
|
||||||
|
}
|
||||||
|
|
||||||
|
const args = [
|
||||||
|
'main.py',
|
||||||
|
'--listen', '127.0.0.1',
|
||||||
|
'--port', String(port),
|
||||||
|
'--models-directory', dirs.models,
|
||||||
|
'--input-directory', dirs.input,
|
||||||
|
'--output-directory', dirs.output,
|
||||||
|
'--user-directory', dirs.user,
|
||||||
|
'--temp-directory', dirs.temp,
|
||||||
|
...extraArgs,
|
||||||
|
];
|
||||||
|
|
||||||
|
let proc = null;
|
||||||
|
// Last chunk of output, so a launch failure can be reported with its actual
|
||||||
|
// cause instead of making the caller poll /system_stats until it times out.
|
||||||
|
let tail = '';
|
||||||
|
const keepTail = (s) => { tail = (tail + s).slice(-4000); };
|
||||||
|
|
||||||
|
let settleExit;
|
||||||
|
const exited = new Promise((resolve) => { settleExit = resolve; });
|
||||||
|
|
||||||
|
try {
|
||||||
|
log && log(`Starting ComfyUI on port ${port}…`);
|
||||||
|
proc = spawn(vp, args, {
|
||||||
|
cwd: installDir,
|
||||||
|
env: {
|
||||||
|
...process.env,
|
||||||
|
PYTHONUNBUFFERED: '1',
|
||||||
|
// MANDATORY on Windows. We capture stdout/stderr through pipes, and for a
|
||||||
|
// pipe Python defaults to the ANSI codepage (cp1252) rather than utf-8.
|
||||||
|
// Several node packs log emoji at import time (rgthree's "Loaded 48
|
||||||
|
// fantastic nodes. 🎉"), which then raises UnicodeEncodeError inside
|
||||||
|
// logging and KILLS ComfyUI with exit code 1 partway through loading —
|
||||||
|
// looking exactly like a mystery startup crash.
|
||||||
|
PYTHONIOENCODING: 'utf-8',
|
||||||
|
PYTHONUTF8: '1',
|
||||||
|
},
|
||||||
|
stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
|
// Own process group so killTree can take down worker children too.
|
||||||
|
detached: !IS_WIN,
|
||||||
|
});
|
||||||
|
proc.stdout.on('data', (d) => { const s = d.toString(); write(s); keepTail(s); });
|
||||||
|
proc.stderr.on('data', (d) => { const s = d.toString(); write(s); keepTail(s); });
|
||||||
|
proc.on('exit', (code, signal) => {
|
||||||
|
log && log(`ComfyUI exited (code=${code} signal=${signal})`);
|
||||||
|
settleExit({ code, signal, tail });
|
||||||
|
});
|
||||||
|
proc.on('error', (err) => {
|
||||||
|
log && log(`ComfyUI failed to start: ${err.message}`);
|
||||||
|
settleExit({ code: -1, signal: null, tail: err.message });
|
||||||
|
});
|
||||||
|
} catch (err) {
|
||||||
|
log && log(`ComfyUI failed to start: ${err.message}`);
|
||||||
|
settleExit({ code: -1, signal: null, tail: err.message });
|
||||||
|
}
|
||||||
|
|
||||||
|
let stopped = false;
|
||||||
|
return {
|
||||||
|
// Resolves when the process dies. ensureService races this against the health
|
||||||
|
// poll so a crash surfaces at once rather than after the full timeout.
|
||||||
|
exited,
|
||||||
|
stop() {
|
||||||
|
if (stopped) return;
|
||||||
|
stopped = true;
|
||||||
|
// ComfyUI spawns worker/subprocess children for some nodes; kill the tree.
|
||||||
|
if (proc && proc.pid) killTree(proc.pid);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
COMFY_SETUP_TAG,
|
||||||
|
loadManifest,
|
||||||
|
isAvailableHere,
|
||||||
|
pickBuild,
|
||||||
|
driverCuda,
|
||||||
|
extractTarGz,
|
||||||
|
selectFlashAttn,
|
||||||
|
setupComfyUI,
|
||||||
|
startComfyUI,
|
||||||
|
// Exported for offline validation of a regenerated lock (see docs/COMFYUI_MANAGED.md).
|
||||||
|
materializeLock,
|
||||||
|
verifyHostedWheels,
|
||||||
|
};
|
||||||
|
|
@ -5,15 +5,16 @@
|
||||||
// 2. Spawn the Node/Express backend (server.js) using Electron's own Node
|
// 2. Spawn the Node/Express backend (server.js) using Electron's own Node
|
||||||
// runtime (ELECTRON_RUN_AS_NODE) so users don't need Node installed.
|
// runtime (ELECTRON_RUN_AS_NODE) so users don't need Node installed.
|
||||||
// 3. FIRST RUN: show a setup window that provisions the Python services with
|
// 3. FIRST RUN: show a setup window that provisions the Python services with
|
||||||
// uv (Mesh Tools always; Rigging opt-in) and streams live progress. Later
|
// uv (Mesh Tools always; Rigging and a managed ComfyUI opt-in) and streams
|
||||||
// runs skip straight to the splash — the venvs already exist.
|
// live progress. Later runs skip straight to the splash — the venvs exist.
|
||||||
// 4. Launch the Python services (Mesh Tools always; Rigging if it was set up).
|
// 4. Launch the Python services on demand (Mesh Tools, Rigging, ComfyUI).
|
||||||
// 5. Wait for the backend to answer, then open the app window.
|
// 5. Wait for the backend to answer, then open the app window.
|
||||||
// 6. Kill child processes on quit.
|
// 6. Kill child processes on quit.
|
||||||
|
|
||||||
const { app, BrowserWindow, shell, dialog, ipcMain } = require('electron');
|
const { app, BrowserWindow, shell, dialog, ipcMain } = require('electron');
|
||||||
const path = require('node:path');
|
const path = require('node:path');
|
||||||
const http = require('node:http');
|
const http = require('node:http');
|
||||||
|
const net = require('node:net');
|
||||||
const fs = require('node:fs');
|
const fs = require('node:fs');
|
||||||
const { spawn } = require('node:child_process');
|
const { spawn } = require('node:child_process');
|
||||||
const {
|
const {
|
||||||
|
|
@ -25,6 +26,13 @@ const {
|
||||||
startPythonServer,
|
startPythonServer,
|
||||||
startSkintokens,
|
startSkintokens,
|
||||||
} = require('./pysetup.cjs');
|
} = require('./pysetup.cjs');
|
||||||
|
const {
|
||||||
|
COMFY_SETUP_TAG,
|
||||||
|
loadManifest: loadComfyManifest,
|
||||||
|
isAvailableHere: comfyAvailableHere,
|
||||||
|
setupComfyUI,
|
||||||
|
startComfyUI,
|
||||||
|
} = require('./comfysetup.cjs');
|
||||||
|
|
||||||
// Force a stable, brandable name BEFORE any getPath('userData') call.
|
// Force a stable, brandable name BEFORE any getPath('userData') call.
|
||||||
app.setName('3DGenStudio');
|
app.setName('3DGenStudio');
|
||||||
|
|
@ -33,6 +41,10 @@ const BACKEND_PORT = Number(process.env.PORT) || 3001;
|
||||||
const BACKEND_ORIGIN = `http://localhost:${BACKEND_PORT}`;
|
const BACKEND_ORIGIN = `http://localhost:${BACKEND_PORT}`;
|
||||||
const PYTHON_PORT = Number(process.env.MESHTOOLS_PORT) || 8200;
|
const PYTHON_PORT = Number(process.env.MESHTOOLS_PORT) || 8200;
|
||||||
const RIG_PORT = Number(process.env.RIGTOOLS_PORT) || 8300;
|
const RIG_PORT = Number(process.env.RIGTOOLS_PORT) || 8300;
|
||||||
|
// ComfyUI's conventional port. The managed install must NOT assume it's free —
|
||||||
|
// plenty of users already run their own ComfyUI there — so this is only the first
|
||||||
|
// candidate; the actual port is picked at install time and stored in settings.
|
||||||
|
const COMFY_PORT_DEFAULT = Number(process.env.COMFYUI_PORT) || 8188;
|
||||||
|
|
||||||
const APP_ROOT = app.getAppPath();
|
const APP_ROOT = app.getAppPath();
|
||||||
const SERVER_JS = path.join(APP_ROOT, 'server.js');
|
const SERVER_JS = path.join(APP_ROOT, 'server.js');
|
||||||
|
|
@ -48,6 +60,13 @@ const RIG_VENV = path.join(DATA_ROOT, 'rig-venv');
|
||||||
// Rigging model weights (experiments/, models/) — the installed app dir is
|
// Rigging model weights (experiments/, models/) — the installed app dir is
|
||||||
// read-only, so download them here and point rig_server.py at it.
|
// read-only, so download them here and point rig_server.py at it.
|
||||||
const RIG_DATA = path.join(DATA_ROOT, 'rig-data');
|
const RIG_DATA = path.join(DATA_ROOT, 'rig-data');
|
||||||
|
// Managed ComfyUI: code, venv, and a separate data root (models/input/output/
|
||||||
|
// user/temp, each passed as its own --*-directory flag — see startComfyUI for why
|
||||||
|
// NOT --base-directory). Keeping data out of the code dir means reinstalling or
|
||||||
|
// upgrading ComfyUI never risks the multi-GB model downloads.
|
||||||
|
const COMFY_VENV = path.join(DATA_ROOT, 'comfy-venv');
|
||||||
|
const COMFY_DIR = path.join(DATA_ROOT, 'comfyui');
|
||||||
|
const COMFY_DATA = path.join(DATA_ROOT, 'comfy-data');
|
||||||
|
|
||||||
let backendProc = null;
|
let backendProc = null;
|
||||||
let mainWindow = null;
|
let mainWindow = null;
|
||||||
|
|
@ -59,8 +78,8 @@ let shuttingDown = false;
|
||||||
// memory (the CUDA context an in-process unload can't free). `handles[name]`
|
// memory (the CUDA context an in-process unload can't free). `handles[name]`
|
||||||
// holds a running service's { stop() }; `starting[name]` dedupes concurrent
|
// holds a running service's { stop() }; `starting[name]` dedupes concurrent
|
||||||
// ensure() calls. The registry is populated after the launchers are defined.
|
// ensure() calls. The registry is populated after the launchers are defined.
|
||||||
const handles = { meshtools: null, rigging: null };
|
const handles = { meshtools: null, rigging: null, comfyui: null };
|
||||||
const starting = { meshtools: null, rigging: null };
|
const starting = { meshtools: null, rigging: null, comfyui: null };
|
||||||
let SERVICES = null;
|
let SERVICES = null;
|
||||||
|
|
||||||
function log(line) {
|
function log(line) {
|
||||||
|
|
@ -156,15 +175,62 @@ function fetchSettings(timeoutMs = 4000) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Deep-merge a settings patch through the backend (POST /api/settings merges).
|
||||||
|
// Used to point apis.comfyui.* at the managed install once it's provisioned.
|
||||||
|
// Resolves false on any error — the caller treats that as "tell the user".
|
||||||
|
function patchSettings(patch, timeoutMs = 8000) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const body = Buffer.from(JSON.stringify(patch), 'utf8');
|
||||||
|
const req = http.request({
|
||||||
|
host: 'localhost', port: BACKEND_PORT, path: '/api/settings', method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json', 'Content-Length': body.length },
|
||||||
|
}, (res) => {
|
||||||
|
res.resume();
|
||||||
|
resolve(res.statusCode >= 200 && res.statusCode < 300);
|
||||||
|
});
|
||||||
|
req.on('error', () => resolve(false));
|
||||||
|
req.setTimeout(timeoutMs, () => { req.destroy(); resolve(false); });
|
||||||
|
req.end(body);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Is a TCP port free to bind on loopback? Used to pick a ComfyUI port that does
|
||||||
|
// not collide with a ComfyUI the user already runs themselves.
|
||||||
|
function portFree(port) {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const srv = net.createServer();
|
||||||
|
srv.once('error', () => resolve(false));
|
||||||
|
srv.once('listening', () => srv.close(() => resolve(true)));
|
||||||
|
srv.listen(port, '127.0.0.1');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function pickFreePort(start, tries = 20) {
|
||||||
|
for (let p = start; p < start + tries; p += 1) {
|
||||||
|
if (await portFree(p)) return p;
|
||||||
|
}
|
||||||
|
return start;
|
||||||
|
}
|
||||||
|
|
||||||
// Start the services the user opted into auto-starting (Settings → Mesh Tools /
|
// Start the services the user opted into auto-starting (Settings → Mesh Tools /
|
||||||
// Auto Rig). Non-blocking and best-effort: failures are logged, never fatal, and
|
// Auto Rig / ComfyUI). Non-blocking and best-effort: failures are logged, never
|
||||||
// never delay the window. Setting key `rigtools` maps to service `rigging`.
|
// fatal, and never delay the window. Setting key `rigtools` maps to service
|
||||||
|
// `rigging`; ComfyUI only auto-starts when it is the MANAGED install (a user's
|
||||||
|
// own external ComfyUI is not ours to launch).
|
||||||
async function autoStartServices() {
|
async function autoStartServices() {
|
||||||
const settings = await fetchSettings();
|
const settings = await fetchSettings();
|
||||||
const apis = settings?.apis || {};
|
const apis = settings?.apis || {};
|
||||||
|
// ComfyUI only auto-starts when it is OUR install — an external one isn't ours
|
||||||
|
// to launch. Say so out loud, because the checkbox otherwise looks broken.
|
||||||
|
if (apis.comfyui?.autoStart && !apis.comfyui?.managed) {
|
||||||
|
log('ComfyUI auto-start is enabled but Settings point at an external ComfyUI ' +
|
||||||
|
'(managed=false), so it will not be started. Use Settings → ComfyUI → ' +
|
||||||
|
'"Use the managed ComfyUI" to switch back.');
|
||||||
|
}
|
||||||
const wanted = [
|
const wanted = [
|
||||||
apis.meshtools?.autoStart ? 'meshtools' : null,
|
apis.meshtools?.autoStart ? 'meshtools' : null,
|
||||||
apis.rigtools?.autoStart ? 'rigging' : null,
|
apis.rigtools?.autoStart ? 'rigging' : null,
|
||||||
|
apis.comfyui?.managed && apis.comfyui?.autoStart ? 'comfyui' : null,
|
||||||
].filter(Boolean);
|
].filter(Boolean);
|
||||||
for (const name of wanted) {
|
for (const name of wanted) {
|
||||||
log(`Auto-starting ${name} service (enabled in Settings)`);
|
log(`Auto-starting ${name} service (enabled in Settings)`);
|
||||||
|
|
@ -178,26 +244,46 @@ function serviceRegistry() {
|
||||||
meshtools: {
|
meshtools: {
|
||||||
// reqsTag: a requirements.txt bump flips this service back to
|
// reqsTag: a requirements.txt bump flips this service back to
|
||||||
// "not installed" until setup re-runs (incrementally) and re-tags it.
|
// "not installed" until setup re-runs (incrementally) and re-tags it.
|
||||||
label: 'Mesh Tools', venv: PY_VENV, port: PYTHON_PORT, reqsTag: MESHTOOLS_REQS_TAG,
|
label: 'Mesh Tools', venv: PY_VENV, port: PYTHON_PORT, reqsTag: MESHTOOLS_REQS_TAG, logFile: 'python.log',
|
||||||
start: () => startPythonServer({
|
start: () => startPythonServer({
|
||||||
serviceDir: PYTHON_DIR, venvDir: PY_VENV, port: PYTHON_PORT,
|
serviceDir: PYTHON_DIR, venvDir: PY_VENV, port: PYTHON_PORT,
|
||||||
logStream: openLogStream('python.log'), log,
|
logStream: openLogStream('python.log'), log,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
rigging: {
|
rigging: {
|
||||||
label: 'Rigging', venv: RIG_VENV, port: RIG_PORT,
|
label: 'Rigging', venv: RIG_VENV, port: RIG_PORT, logFile: 'rig.log',
|
||||||
start: () => startSkintokens({
|
start: () => startSkintokens({
|
||||||
serviceDir: SKINTOKENS_DIR, venvDir: RIG_VENV, dataDir: RIG_DATA, port: RIG_PORT,
|
serviceDir: SKINTOKENS_DIR, venvDir: RIG_VENV, dataDir: RIG_DATA, port: RIG_PORT,
|
||||||
logStream: openLogStream('rig.log'), log,
|
logStream: openLogStream('rig.log'), log,
|
||||||
}),
|
}),
|
||||||
},
|
},
|
||||||
|
comfyui: {
|
||||||
|
// ComfyUI has no /health endpoint; /system_stats is its readiness probe and
|
||||||
|
// only answers once the server is actually accepting API calls.
|
||||||
|
label: 'ComfyUI', venv: COMFY_VENV, port: COMFY_PORT_DEFAULT, logFile: 'comfyui.log',
|
||||||
|
healthPath: '/system_stats', reqsTag: COMFY_SETUP_TAG,
|
||||||
|
// Venv AND code dir must both be present — see comfyReady().
|
||||||
|
isInstalled: () => comfyReady(),
|
||||||
|
// The port is chosen at install time (to dodge a user's own ComfyUI) and
|
||||||
|
// stored in settings, so it must be read at start time, not at boot.
|
||||||
|
resolvePort: async () => {
|
||||||
|
const settings = await fetchSettings();
|
||||||
|
const p = Number(settings?.apis?.comfyui?.port);
|
||||||
|
return Number.isFinite(p) && p > 0 ? p : COMFY_PORT_DEFAULT;
|
||||||
|
},
|
||||||
|
start: (port) => startComfyUI({
|
||||||
|
appRoot: APP_ROOT, installDir: COMFY_DIR, dataDir: COMFY_DATA, venvDir: COMFY_VENV,
|
||||||
|
port, logStream: openLogStream('comfyui.log'), log,
|
||||||
|
}),
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// One /health probe → boolean.
|
// One readiness probe → boolean. `healthPath` defaults to the /health endpoint
|
||||||
function isHealthy(port) {
|
// both Python services expose; ComfyUI overrides it.
|
||||||
|
function isHealthy(port, healthPath = '/health') {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
const req = http.get({ host: '127.0.0.1', port, path: '/health', timeout: 2000 }, (res) => {
|
const req = http.get({ host: '127.0.0.1', port, path: healthPath, timeout: 2000 }, (res) => {
|
||||||
res.resume();
|
res.resume();
|
||||||
resolve(res.statusCode === 200);
|
resolve(res.statusCode === 200);
|
||||||
});
|
});
|
||||||
|
|
@ -206,13 +292,13 @@ function isHealthy(port) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Poll /health until healthy or timeout. Rigging can take a while (heavy imports
|
// Poll until healthy or timeout. Rigging can take a while (heavy imports + model)
|
||||||
// + model), hence the generous default.
|
// and so can ComfyUI (torch import + node scan), hence the generous default.
|
||||||
function waitForHealth(port, timeoutMs = 180000, intervalMs = 600) {
|
function waitForHealth(port, healthPath, timeoutMs = 180000, intervalMs = 600) {
|
||||||
const deadline = Date.now() + timeoutMs;
|
const deadline = Date.now() + timeoutMs;
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const tick = async () => {
|
const tick = async () => {
|
||||||
if (await isHealthy(port)) return resolve();
|
if (await isHealthy(port, healthPath)) return resolve();
|
||||||
if (Date.now() > deadline) return reject(new Error('service did not become ready in time'));
|
if (Date.now() > deadline) return reject(new Error('service did not become ready in time'));
|
||||||
setTimeout(tick, intervalMs);
|
setTimeout(tick, intervalMs);
|
||||||
};
|
};
|
||||||
|
|
@ -236,31 +322,68 @@ function stopService(name) {
|
||||||
function ensureService(name) {
|
function ensureService(name) {
|
||||||
const svc = SERVICES[name];
|
const svc = SERVICES[name];
|
||||||
if (!svc) return Promise.reject(new Error(`Unknown service: ${name}`));
|
if (!svc) return Promise.reject(new Error(`Unknown service: ${name}`));
|
||||||
if (!isReady(svc.venv, svc.reqsTag)) {
|
if (!serviceInstalled(svc)) {
|
||||||
return Promise.reject(new Error(`${svc.label} is not installed yet. Install it in Settings.`));
|
return Promise.reject(new Error(`${svc.label} is not installed yet. Install it in Settings.`));
|
||||||
}
|
}
|
||||||
if (starting[name]) return starting[name];
|
if (starting[name]) return starting[name];
|
||||||
|
|
||||||
const p = (async () => {
|
const p = (async () => {
|
||||||
|
// Services with a configurable port resolve it now and cache it on the
|
||||||
|
// registry entry, so status/health checks elsewhere see the real port.
|
||||||
|
if (svc.resolvePort) {
|
||||||
|
try { svc.port = await svc.resolvePort(); } catch { /* keep the default */ }
|
||||||
|
}
|
||||||
if (handles[name]) {
|
if (handles[name]) {
|
||||||
if (await isHealthy(svc.port)) return;
|
if (await isHealthy(svc.port, svc.healthPath)) return;
|
||||||
stopService(name); // crashed → restart
|
stopService(name); // crashed → restart
|
||||||
}
|
}
|
||||||
log(`Starting ${name} service on demand`);
|
log(`Starting ${name} service on demand (port ${svc.port})`);
|
||||||
handles[name] = svc.start();
|
const handle = svc.start(svc.port);
|
||||||
await waitForHealth(svc.port);
|
handles[name] = handle;
|
||||||
|
|
||||||
|
// Race readiness against the process dying. Without this, a service that
|
||||||
|
// crashes on startup (a bad flag, a missing directory) looks like a 3-minute
|
||||||
|
// hang and then a generic timeout; here the real error and the tail of its
|
||||||
|
// output surface immediately.
|
||||||
|
let died = null;
|
||||||
|
if (handle && handle.exited && typeof handle.exited.then === 'function') {
|
||||||
|
// Forget a handle whose process is gone, so serviceStatus() stops reporting
|
||||||
|
// "Running" for a service that already died (which made a crash look like a
|
||||||
|
// healthy service that simply wasn't answering) and the next ensure() starts
|
||||||
|
// a fresh one instead of trusting the corpse.
|
||||||
|
handle.exited.then(() => {
|
||||||
|
if (handles[name] === handle) handles[name] = null;
|
||||||
|
}).catch(() => {});
|
||||||
|
|
||||||
|
died = handle.exited.then(({ code, tail }) => {
|
||||||
|
const last = String(tail || '').trim().split(/\r?\n/).slice(-8).join('\n');
|
||||||
|
throw new Error(
|
||||||
|
`${svc.label} stopped right after starting (exit code ${code}).` +
|
||||||
|
(last ? `\n\n${last}` : '') +
|
||||||
|
(svc.logFile ? `\n\nFull log: ${path.join(LOG_DIR, svc.logFile)}` : '')
|
||||||
|
);
|
||||||
|
});
|
||||||
|
died.catch(() => {}); // a crash after we're healthy must not go unhandled
|
||||||
|
}
|
||||||
|
await Promise.race([waitForHealth(svc.port, svc.healthPath), died].filter(Boolean));
|
||||||
})();
|
})();
|
||||||
starting[name] = p;
|
starting[name] = p;
|
||||||
p.catch(() => {}).finally(() => { if (starting[name] === p) starting[name] = null; });
|
p.catch(() => {}).finally(() => { if (starting[name] === p) starting[name] = null; });
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// "Installed" defaults to the venv marker check; a service with extra artifacts
|
||||||
|
// outside the venv (ComfyUI's code dir) supplies its own predicate.
|
||||||
|
function serviceInstalled(svc) {
|
||||||
|
return svc.isInstalled ? svc.isInstalled() : isReady(svc.venv, svc.reqsTag);
|
||||||
|
}
|
||||||
|
|
||||||
function serviceStatus() {
|
function serviceStatus() {
|
||||||
const out = {};
|
const out = {};
|
||||||
for (const [name, svc] of Object.entries(SERVICES)) {
|
for (const [name, svc] of Object.entries(SERVICES)) {
|
||||||
out[name] = {
|
out[name] = {
|
||||||
label: svc.label,
|
label: svc.label,
|
||||||
installed: isReady(svc.venv, svc.reqsTag),
|
installed: serviceInstalled(svc),
|
||||||
running: !!handles[name],
|
running: !!handles[name],
|
||||||
starting: !!starting[name],
|
starting: !!starting[name],
|
||||||
};
|
};
|
||||||
|
|
@ -282,12 +405,39 @@ function registerServicesIpc() {
|
||||||
stopService(name);
|
stopService(name);
|
||||||
return { ok: true, status: serviceStatus() };
|
return { ok: true, status: serviceStatus() };
|
||||||
});
|
});
|
||||||
|
// Re-point the app at the managed ComfyUI (Settings action). Needed when the
|
||||||
|
// settings drifted to an external instance after the install.
|
||||||
|
ipcMain.handle('comfyui:use-managed', async () => {
|
||||||
|
if (!comfyReady()) return { ok: false, error: 'The managed ComfyUI is not installed yet.' };
|
||||||
|
const applied = await applyManagedComfySettings();
|
||||||
|
if (!applied) return { ok: false, error: 'Could not save the settings.' };
|
||||||
|
log(`Re-pointed settings at the managed ComfyUI on port ${applied.port}.`);
|
||||||
|
return { ok: true, port: applied.port, path: COMFY_DIR, modelsPath: path.join(COMFY_DATA, 'models') };
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// A managed ComfyUI counts as installed only if BOTH its venv is tagged/usable
|
||||||
|
// and the code is on disk — the two live in separate folders, so either can go
|
||||||
|
// missing on its own (a cleared data dir, an interrupted download).
|
||||||
|
function comfyReady() {
|
||||||
|
return isReady(COMFY_VENV, COMFY_SETUP_TAG) && fs.existsSync(path.join(COMFY_DIR, 'main.py'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Whether this platform has a shipped dependency set at all. Reported to the UI
|
||||||
|
// so the install option is hidden rather than offered and then failed.
|
||||||
|
function comfyAvailable() {
|
||||||
|
try {
|
||||||
|
return comfyAvailableHere(loadComfyManifest(APP_ROOT));
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Provision the Python services with uv, forwarding progress to `send`. Skips a
|
// Provision the Python services with uv, forwarding progress to `send`. Skips a
|
||||||
// service that is already set up (so the in-app "install rigging" path doesn't
|
// service that is already set up (so the in-app "install rigging" path doesn't
|
||||||
// needlessly reinstall Mesh Tools).
|
// needlessly reinstall Mesh Tools).
|
||||||
async function doSetup(rigging, send) {
|
async function doSetup(opts, send) {
|
||||||
|
const { rigging = false, comfyui = false } = opts || {};
|
||||||
const uv = await ensureUv({ appRoot: APP_ROOT, onLine: (t) => send({ service: 'meshtools', kind: 'log', text: t }) });
|
const uv = await ensureUv({ appRoot: APP_ROOT, onLine: (t) => send({ service: 'meshtools', kind: 'log', text: t }) });
|
||||||
if (!uv) throw new Error('Could not find or install uv (the Python toolchain manager).');
|
if (!uv) throw new Error('Could not find or install uv (the Python toolchain manager).');
|
||||||
|
|
||||||
|
|
@ -306,6 +456,50 @@ async function doSetup(rigging, send) {
|
||||||
onProgress: (e) => send({ service: 'rigging', ...e }),
|
onProgress: (e) => send({ service: 'rigging', ...e }),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (comfyui && !comfyReady()) {
|
||||||
|
const result = await setupComfyUI({
|
||||||
|
uv, appRoot: APP_ROOT, installDir: COMFY_DIR, dataDir: COMFY_DATA, venvDir: COMFY_VENV,
|
||||||
|
onProgress: (e) => send({ service: 'comfyui', ...e }),
|
||||||
|
});
|
||||||
|
|
||||||
|
const applied = await applyManagedComfySettings();
|
||||||
|
if (applied) {
|
||||||
|
log(`ComfyUI installed at ${COMFY_DIR}; set as the default on port ${applied.port}.`);
|
||||||
|
} else {
|
||||||
|
// The install itself succeeded — don't fail the whole setup over the
|
||||||
|
// settings write, but say so, because nothing will point at it yet.
|
||||||
|
log('ComfyUI installed, but writing the app settings failed.');
|
||||||
|
send({
|
||||||
|
service: 'comfyui', kind: 'log',
|
||||||
|
text: `\nWARNING: could not save settings automatically. Set Settings -> ComfyUI path to ${COMFY_DIR}.\n`,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Point apis.comfyui.* at the managed install and flag it `managed`. Called after
|
||||||
|
// a successful install, and again from Settings ("Use the managed ComfyUI") for
|
||||||
|
// anyone whose settings drifted to an external instance — without this second
|
||||||
|
// path there is no way back, because the installer short-circuits once the
|
||||||
|
// install exists and so never re-writes these fields.
|
||||||
|
// Returns { port } on success, null if the settings write failed.
|
||||||
|
async function applyManagedComfySettings() {
|
||||||
|
const port = await pickFreePort(COMFY_PORT_DEFAULT);
|
||||||
|
const ok = await patchSettings({
|
||||||
|
apis: {
|
||||||
|
comfyui: {
|
||||||
|
managed: true,
|
||||||
|
path: COMFY_DIR,
|
||||||
|
modelsPath: path.join(COMFY_DATA, 'models'),
|
||||||
|
url: 'http://127.0.0.1',
|
||||||
|
port: String(port),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!ok) return null;
|
||||||
|
if (SERVICES?.comfyui) SERVICES.comfyui.port = port;
|
||||||
|
return { port };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Global setup IPC — used by BOTH the first-run window and the running app
|
// Global setup IPC — used by BOTH the first-run window and the running app
|
||||||
|
|
@ -316,16 +510,25 @@ function registerSetupIpc() {
|
||||||
desktop: true,
|
desktop: true,
|
||||||
meshtools: isReady(PY_VENV, MESHTOOLS_REQS_TAG),
|
meshtools: isReady(PY_VENV, MESHTOOLS_REQS_TAG),
|
||||||
rigging: isReady(RIG_VENV),
|
rigging: isReady(RIG_VENV),
|
||||||
|
comfyui: comfyReady(),
|
||||||
|
comfyuiAvailable: comfyAvailable(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
ipcMain.handle('setup:run', async (event, opts = {}) => {
|
ipcMain.handle('setup:run', async (event, opts = {}) => {
|
||||||
const send = (evt) => { try { event.sender.send('setup:progress', evt); } catch { /* window gone */ } };
|
const send = (evt) => { try { event.sender.send('setup:progress', evt); } catch { /* window gone */ } };
|
||||||
try {
|
try {
|
||||||
await doSetup(!!opts.rigging, send);
|
await doSetup({ rigging: !!opts.rigging, comfyui: !!opts.comfyui }, send);
|
||||||
// Provisioned only — services are started on demand (or from Settings),
|
// Provisioned only — services are started on demand (or from Settings),
|
||||||
// not here, so installing doesn't spin up a process the user isn't using.
|
// not here, so installing doesn't spin up a process the user isn't using.
|
||||||
log('Setup run complete.');
|
log('Setup run complete.');
|
||||||
return { ok: true, status: { meshtools: isReady(PY_VENV, MESHTOOLS_REQS_TAG), rigging: isReady(RIG_VENV) } };
|
return {
|
||||||
|
ok: true,
|
||||||
|
status: {
|
||||||
|
meshtools: isReady(PY_VENV, MESHTOOLS_REQS_TAG),
|
||||||
|
rigging: isReady(RIG_VENV),
|
||||||
|
comfyui: comfyReady(),
|
||||||
|
},
|
||||||
|
};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log(`Setup run failed: ${err.message}`);
|
log(`Setup run failed: ${err.message}`);
|
||||||
send({ kind: 'error', text: err.message });
|
send({ kind: 'error', text: err.message });
|
||||||
|
|
|
||||||
|
|
@ -22,6 +22,9 @@ contextBridge.exposeInMainWorld('genStudioServices', {
|
||||||
start: (name) => ipcRenderer.invoke('services:start', { name }),
|
start: (name) => ipcRenderer.invoke('services:start', { name }),
|
||||||
stop: (name) => ipcRenderer.invoke('services:stop', { name }),
|
stop: (name) => ipcRenderer.invoke('services:stop', { name }),
|
||||||
status: () => ipcRenderer.invoke('services:status'),
|
status: () => ipcRenderer.invoke('services:status'),
|
||||||
|
// Re-point apis.comfyui.* at the managed install. Resolves { ok, port, path,
|
||||||
|
// modelsPath } or { ok: false, error }.
|
||||||
|
useManagedComfy: () => ipcRenderer.invoke('comfyui:use-managed'),
|
||||||
});
|
});
|
||||||
|
|
||||||
contextBridge.exposeInMainWorld('genStudioSetup', {
|
contextBridge.exposeInMainWorld('genStudioSetup', {
|
||||||
|
|
|
||||||
|
|
@ -80,13 +80,17 @@ function isReady(venvDir, requiredTag) {
|
||||||
// Create the venv with uv, rebuilding from scratch if the existing one is broken
|
// Create the venv with uv, rebuilding from scratch if the existing one is broken
|
||||||
// (e.g. a legacy python -m venv whose base interpreter is gone). A healthy venv
|
// (e.g. a legacy python -m venv whose base interpreter is gone). A healthy venv
|
||||||
// is left untouched. Returns an exit code (0 = ok).
|
// is left untouched. Returns an exit code (0 = ok).
|
||||||
async function ensureVenv({ uv, serviceDir, venvDir, onLine }) {
|
//
|
||||||
|
// `pythonVersion` defaults to PYVER; the managed ComfyUI install passes its own
|
||||||
|
// (its prebuilt CUDA wheels are tagged for a specific interpreter, which need not
|
||||||
|
// be the one the other services use).
|
||||||
|
async function ensureVenv({ uv, serviceDir, venvDir, onLine, pythonVersion }) {
|
||||||
if (venvUsable(venvDir)) return 0;
|
if (venvUsable(venvDir)) return 0;
|
||||||
if (fs.existsSync(venvDir)) {
|
if (fs.existsSync(venvDir)) {
|
||||||
if (onLine) onLine(`Existing virtual environment is unusable — rebuilding it.\n`);
|
if (onLine) onLine(`Existing virtual environment is unusable — rebuilding it.\n`);
|
||||||
try { fs.rmSync(venvDir, { recursive: true, force: true }); } catch { /* ignore */ }
|
try { fs.rmSync(venvDir, { recursive: true, force: true }); } catch { /* ignore */ }
|
||||||
}
|
}
|
||||||
const r = await runStream(uv, ['venv', venvDir, '--python', PYVER], { cwd: serviceDir, env: process.env, onLine });
|
const r = await runStream(uv, ['venv', venvDir, '--python', pythonVersion || PYVER], { cwd: serviceDir, env: process.env, onLine });
|
||||||
return r.code;
|
return r.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -329,21 +333,41 @@ function startService({ name, serviceDir, venvDir, script, env, logStream, log }
|
||||||
return { stop() {} };
|
return { stop() {} };
|
||||||
}
|
}
|
||||||
let proc = null;
|
let proc = null;
|
||||||
|
// Keep the last chunk of output so a launch failure can be reported with its
|
||||||
|
// real cause rather than as a health-check timeout.
|
||||||
|
let tail = '';
|
||||||
|
const keepTail = (s) => { tail = (tail + s).slice(-4000); };
|
||||||
|
let settleExit;
|
||||||
|
const exited = new Promise((resolve) => { settleExit = resolve; });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
log && log(`Starting ${name} service…`);
|
log && log(`Starting ${name} service…`);
|
||||||
proc = spawn(vp, [script], {
|
proc = spawn(vp, [script], {
|
||||||
cwd: serviceDir,
|
cwd: serviceDir,
|
||||||
env: { ...process.env, ...env },
|
// PYTHONIOENCODING/PYTHONUTF8: output goes through a pipe, and for pipes
|
||||||
|
// Python defaults to the ANSI codepage on Windows (cp1252) — any non-ASCII
|
||||||
|
// log line then raises UnicodeEncodeError inside logging and can kill the
|
||||||
|
// service mid-startup. Caller env still wins.
|
||||||
|
env: { ...process.env, PYTHONIOENCODING: 'utf-8', PYTHONUTF8: '1', ...env },
|
||||||
stdio: ['ignore', 'pipe', 'pipe'],
|
stdio: ['ignore', 'pipe', 'pipe'],
|
||||||
});
|
});
|
||||||
proc.stdout.on('data', (d) => write(d.toString()));
|
proc.stdout.on('data', (d) => { const s = d.toString(); write(s); keepTail(s); });
|
||||||
proc.stderr.on('data', (d) => write(d.toString()));
|
proc.stderr.on('data', (d) => { const s = d.toString(); write(s); keepTail(s); });
|
||||||
proc.on('exit', (code, signal) => { log && log(`${name} service exited (code=${code} signal=${signal})`); });
|
proc.on('exit', (code, signal) => {
|
||||||
|
log && log(`${name} service exited (code=${code} signal=${signal})`);
|
||||||
|
settleExit({ code, signal, tail });
|
||||||
|
});
|
||||||
|
proc.on('error', (err) => {
|
||||||
|
log && log(`${name} service failed to start: ${err.message}`);
|
||||||
|
settleExit({ code: -1, signal: null, tail: err.message });
|
||||||
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log && log(`${name} service failed to start: ${err.message}`);
|
log && log(`${name} service failed to start: ${err.message}`);
|
||||||
|
settleExit({ code: -1, signal: null, tail: err.message });
|
||||||
}
|
}
|
||||||
let stopped = false;
|
let stopped = false;
|
||||||
return {
|
return {
|
||||||
|
exited,
|
||||||
stop() {
|
stop() {
|
||||||
if (stopped) return;
|
if (stopped) return;
|
||||||
stopped = true;
|
stopped = true;
|
||||||
|
|
@ -363,4 +387,9 @@ module.exports = {
|
||||||
startPythonServer,
|
startPythonServer,
|
||||||
startSkintokens,
|
startSkintokens,
|
||||||
killTree,
|
killTree,
|
||||||
|
// Shared with comfysetup.cjs, which provisions a third service the same way.
|
||||||
|
runStream,
|
||||||
|
ensureVenv,
|
||||||
|
depsMarker,
|
||||||
|
venvUsable,
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,17 @@
|
||||||
<div class="bar"><i></i></div>
|
<div class="bar"><i></i></div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="svc" id="svc-comfyui">
|
||||||
|
<div class="svc__head">
|
||||||
|
<span class="dot"></span>
|
||||||
|
<span class="svc__name">ComfyUI</span>
|
||||||
|
<span class="svc__tag">optional · powers image & mesh generation</span>
|
||||||
|
</div>
|
||||||
|
<label class="opt"><input type="checkbox" id="opt-comfyui" /> Install and manage ComfyUI for me (needs an NVIDIA GPU; downloads several GB). Leave unchecked if you already run your own ComfyUI — point the app at it in Settings.</label>
|
||||||
|
<div class="svc__phase" style="display:none"></div>
|
||||||
|
<div class="bar" style="display:none"><i></i></div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="svc" id="svc-rigging">
|
<div class="svc" id="svc-rigging">
|
||||||
<div class="svc__head">
|
<div class="svc__head">
|
||||||
<span class="dot"></span>
|
<span class="dot"></span>
|
||||||
|
|
@ -104,25 +115,34 @@
|
||||||
const rows = {
|
const rows = {
|
||||||
meshtools: $('#svc-meshtools'),
|
meshtools: $('#svc-meshtools'),
|
||||||
rigging: $('#svc-rigging'),
|
rigging: $('#svc-rigging'),
|
||||||
|
comfyui: $('#svc-comfyui'),
|
||||||
uv: $('#svc-meshtools'), // uv provisioning shows under the first row
|
uv: $('#svc-meshtools'), // uv provisioning shows under the first row
|
||||||
};
|
};
|
||||||
const logEl = $('#log');
|
const logEl = $('#log');
|
||||||
const errEl = $('#err');
|
const errEl = $('#err');
|
||||||
|
|
||||||
// Rigging needs CUDA, so it exists on Windows and Linux only. Hide the option on
|
// Rigging needs CUDA, so it exists on Windows and Linux only. Hide the option
|
||||||
// macOS rather than offering an install that cannot succeed. (An unchecked box
|
// on macOS rather than offering an install that cannot succeed. (An unchecked
|
||||||
// reads as false in runInstall, so nothing else needs to know.)
|
// box reads as false in runInstall, so nothing else needs to know.)
|
||||||
if ((window.genStudioDesktop && window.genStudioDesktop.platform) === 'darwin') {
|
if ((window.genStudioDesktop && window.genStudioDesktop.platform) === 'darwin') {
|
||||||
$('#svc-rigging').style.display = 'none';
|
$('#svc-rigging').style.display = 'none';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The managed ComfyUI additionally needs a dependency set generated for THIS
|
||||||
|
// platform (the lock is a platform-specific resolution). The main process knows
|
||||||
|
// which platforms this build ships, so ask rather than guess.
|
||||||
|
$('#svc-comfyui').style.display = 'none';
|
||||||
|
window.genStudioSetup.status()
|
||||||
|
.then((s) => { if (s && s.comfyuiAvailable) $('#svc-comfyui').style.display = ''; })
|
||||||
|
.catch(() => {});
|
||||||
|
|
||||||
function setRow(service, { state, phase, pct }) {
|
function setRow(service, { state, phase, pct }) {
|
||||||
const row = rows[service];
|
const row = rows[service];
|
||||||
if (!row) return;
|
if (!row) return;
|
||||||
const dot = row.querySelector('.dot');
|
const dot = row.querySelector('.dot');
|
||||||
const phaseEl = row.querySelector('.svc__phase');
|
const phaseEl = row.querySelector('.svc__phase');
|
||||||
const bar = row.querySelector('.bar > i');
|
const bar = row.querySelector('.bar > i');
|
||||||
if (service === 'rigging') { // reveal rigging progress once it starts
|
if (service === 'rigging' || service === 'comfyui') { // reveal progress once it starts
|
||||||
row.querySelector('.svc__phase').style.display = '';
|
row.querySelector('.svc__phase').style.display = '';
|
||||||
row.querySelector('.bar').style.display = '';
|
row.querySelector('.bar').style.display = '';
|
||||||
}
|
}
|
||||||
|
|
@ -156,10 +176,12 @@
|
||||||
async function runInstall() {
|
async function runInstall() {
|
||||||
errEl.textContent = '';
|
errEl.textContent = '';
|
||||||
const rigging = $('#opt-rigging').checked;
|
const rigging = $('#opt-rigging').checked;
|
||||||
|
const comfyui = $('#opt-comfyui').checked;
|
||||||
$('#btn-install').disabled = true;
|
$('#btn-install').disabled = true;
|
||||||
$('#opt-rigging').disabled = true;
|
$('#opt-rigging').disabled = true;
|
||||||
|
$('#opt-comfyui').disabled = true;
|
||||||
setRow('meshtools', { state: 'running', phase: 'Starting…', pct: 0 });
|
setRow('meshtools', { state: 'running', phase: 'Starting…', pct: 0 });
|
||||||
const res = await window.genStudioSetup.run({ rigging });
|
const res = await window.genStudioSetup.run({ rigging, comfyui });
|
||||||
if (res && res.ok) {
|
if (res && res.ok) {
|
||||||
$('#btn-install').style.display = 'none';
|
$('#btn-install').style.display = 'none';
|
||||||
$('#btn-launch').style.display = '';
|
$('#btn-launch').style.display = '';
|
||||||
|
|
@ -167,6 +189,7 @@
|
||||||
errEl.textContent = (res && res.error) || 'Setup failed. See details.';
|
errEl.textContent = (res && res.error) || 'Setup failed. See details.';
|
||||||
$('#btn-install').disabled = false;
|
$('#btn-install').disabled = false;
|
||||||
$('#opt-rigging').disabled = false;
|
$('#opt-rigging').disabled = false;
|
||||||
|
$('#opt-comfyui').disabled = false;
|
||||||
$('#btn-install').textContent = 'Retry';
|
$('#btn-install').textContent = 'Retry';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,13 @@
|
||||||
},
|
},
|
||||||
"5": {
|
"5": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"guidance_scale": 7.500000000000002,
|
"guidance_scale": 7.5,
|
||||||
"steps": 30,
|
"steps": 30,
|
||||||
"seed": 12345,
|
"seed": 12345,
|
||||||
"scheduler": "ConsistencyFlowMatchEulerDiscreteScheduler",
|
"scheduler": "ConsistencyFlowMatchEulerDiscreteScheduler",
|
||||||
"force_offload": false,
|
"force_offload": false,
|
||||||
"pipeline": [
|
"pipeline": [
|
||||||
"78",
|
"86",
|
||||||
0
|
0
|
||||||
],
|
],
|
||||||
"image": [
|
"image": [
|
||||||
|
|
@ -35,16 +35,16 @@
|
||||||
},
|
},
|
||||||
"6": {
|
"6": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"box_v": 1.0100000000000002,
|
"box_v": 1.01,
|
||||||
"octree_resolution": 384,
|
"octree_resolution": 384,
|
||||||
"num_chunks": 128000,
|
"num_chunks": 128000,
|
||||||
"mc_level": 0,
|
"mc_level": 0,
|
||||||
"mc_algo": "dmc",
|
"mc_algo": "mc",
|
||||||
"enable_flash_vdm": true,
|
"enable_flash_vdm": true,
|
||||||
"force_offload": false,
|
"force_offload": false,
|
||||||
"vae": [
|
"vae": [
|
||||||
"85",
|
"86",
|
||||||
0
|
1
|
||||||
],
|
],
|
||||||
"latents": [
|
"latents": [
|
||||||
"5",
|
"5",
|
||||||
|
|
@ -136,25 +136,11 @@
|
||||||
"title": "Invert Mask"
|
"title": "Invert Mask"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"78": {
|
"86": {
|
||||||
"inputs": {
|
"inputs": {},
|
||||||
"model": "hunyuan3d-dit-v2-mini-turbo-fp16.safetensors",
|
"class_type": "Hy3DMiniTurboModelLoader",
|
||||||
"is_mini_turbo": true,
|
|
||||||
"attention_mode": "sdpa",
|
|
||||||
"cublas_ops": false
|
|
||||||
},
|
|
||||||
"class_type": "Hy3DModelLoader",
|
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"title": "Hy3DModelLoader"
|
"title": "Hy3D - Mini Turbo Model Loader"
|
||||||
}
|
|
||||||
},
|
|
||||||
"85": {
|
|
||||||
"inputs": {
|
|
||||||
"model_name": "hunyuan3d-vae-v2-mini-fp16.safetensors"
|
|
||||||
},
|
|
||||||
"class_type": "Hy3DVAELoader",
|
|
||||||
"_meta": {
|
|
||||||
"title": "Hy3DVAELoader"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,28 +1,19 @@
|
||||||
{
|
{
|
||||||
"4": {
|
|
||||||
"inputs": {
|
|
||||||
"model_name": "Hunyuan3D-vae-v2-1-fp16.ckpt"
|
|
||||||
},
|
|
||||||
"class_type": "Hy3D21VAELoader",
|
|
||||||
"_meta": {
|
|
||||||
"title": "Hunyuan 3D 2.1 VAE Loader"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"9": {
|
"9": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"box_v": 1.01,
|
"box_v": 1.01,
|
||||||
"octree_resolution": 384,
|
"octree_resolution": 384,
|
||||||
"num_chunks": 128000,
|
"num_chunks": 128000,
|
||||||
"mc_level": 0,
|
"mc_level": 0,
|
||||||
"mc_algo": "dmc",
|
"mc_algo": "mc",
|
||||||
"enable_flash_vdm": true,
|
"enable_flash_vdm": true,
|
||||||
"force_offload": false,
|
"force_offload": false,
|
||||||
"vae": [
|
"vae": [
|
||||||
"4",
|
"42",
|
||||||
0
|
1
|
||||||
],
|
],
|
||||||
"latents": [
|
"latents": [
|
||||||
"38",
|
"43",
|
||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -49,7 +40,7 @@
|
||||||
"remove_floaters": true,
|
"remove_floaters": true,
|
||||||
"remove_degenerate_faces": true,
|
"remove_degenerate_faces": true,
|
||||||
"reduce_faces": true,
|
"reduce_faces": true,
|
||||||
"max_facenum": 2000000,
|
"max_facenum": 500000,
|
||||||
"smooth_normals": false,
|
"smooth_normals": false,
|
||||||
"trimesh": [
|
"trimesh": [
|
||||||
"9",
|
"9",
|
||||||
|
|
@ -76,23 +67,6 @@
|
||||||
"title": "Hunyuan 3D 2.1 Export Mesh"
|
"title": "Hunyuan 3D 2.1 Export Mesh"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"38": {
|
|
||||||
"inputs": {
|
|
||||||
"model": "hunyuan3d-dit-v2-1-fp16.ckpt",
|
|
||||||
"steps": 25,
|
|
||||||
"guidance_scale": 7.5,
|
|
||||||
"seed": 12345,
|
|
||||||
"attention_mode": "sdpa",
|
|
||||||
"image": [
|
|
||||||
"40",
|
|
||||||
0
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"class_type": "Hy3D21MeshGenerator",
|
|
||||||
"_meta": {
|
|
||||||
"title": "Hunyuan 3D 2.1 Mesh Generator"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"40": {
|
"40": {
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"image": ""
|
"image": ""
|
||||||
|
|
@ -101,5 +75,108 @@
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"title": "Load Image"
|
"title": "Load Image"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"42": {
|
||||||
|
"inputs": {},
|
||||||
|
"class_type": "Hy3D21ModelLoader",
|
||||||
|
"_meta": {
|
||||||
|
"title": "Hunyuan 3D 2.1 - Model Loader"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"43": {
|
||||||
|
"inputs": {
|
||||||
|
"model_path": [
|
||||||
|
"42",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"steps": 25,
|
||||||
|
"guidance_scale": 7.5,
|
||||||
|
"seed": 12345,
|
||||||
|
"attention_mode": "sdpa",
|
||||||
|
"image": [
|
||||||
|
"48",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "Hy3D21MeshGenerator2",
|
||||||
|
"_meta": {
|
||||||
|
"title": "Hunyuan 3D 2.1 Mesh Generator2"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"44": {
|
||||||
|
"inputs": {
|
||||||
|
"value": 0,
|
||||||
|
"width": [
|
||||||
|
"47",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"height": [
|
||||||
|
"47",
|
||||||
|
1
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "SolidMask",
|
||||||
|
"_meta": {
|
||||||
|
"title": "SolidMask"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"45": {
|
||||||
|
"inputs": {
|
||||||
|
"mask": [
|
||||||
|
"40",
|
||||||
|
1
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "InvertMask",
|
||||||
|
"_meta": {
|
||||||
|
"title": "InvertMask"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"46": {
|
||||||
|
"inputs": {
|
||||||
|
"mask": [
|
||||||
|
"44",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "MaskToImage",
|
||||||
|
"_meta": {
|
||||||
|
"title": "Convert Mask to Image"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"47": {
|
||||||
|
"inputs": {
|
||||||
|
"image": [
|
||||||
|
"40",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "GetImageSize",
|
||||||
|
"_meta": {
|
||||||
|
"title": "Get Image Size"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"48": {
|
||||||
|
"inputs": {
|
||||||
|
"x": 0,
|
||||||
|
"y": 0,
|
||||||
|
"resize_source": false,
|
||||||
|
"destination": [
|
||||||
|
"46",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"40",
|
||||||
|
0
|
||||||
|
],
|
||||||
|
"mask": [
|
||||||
|
"45",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "ImageCompositeMasked",
|
||||||
|
"_meta": {
|
||||||
|
"title": "ImageCompositeMasked"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"padding": 0,
|
"padding": 0,
|
||||||
"remove_background": true,
|
"remove_background": true,
|
||||||
"max_size": 2048,
|
"max_size": 4096,
|
||||||
"image": [
|
"image": [
|
||||||
"3",
|
"3",
|
||||||
0
|
0
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"filename_prefix": "3DGenStudioCentered",
|
"filename_prefix": "3DGenStudioCentered",
|
||||||
"images": [
|
"images": [
|
||||||
"2",
|
"6",
|
||||||
0
|
0
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
@ -56,5 +56,26 @@
|
||||||
"_meta": {
|
"_meta": {
|
||||||
"title": "Load Image"
|
"title": "Load Image"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"6": {
|
||||||
|
"inputs": {
|
||||||
|
"model": "RMBG-2.0",
|
||||||
|
"sensitivity": 1,
|
||||||
|
"process_res": 1024,
|
||||||
|
"mask_blur": 0,
|
||||||
|
"mask_offset": 0,
|
||||||
|
"invert_output": false,
|
||||||
|
"refine_foreground": false,
|
||||||
|
"background": "Alpha",
|
||||||
|
"background_color": "#222222",
|
||||||
|
"image": [
|
||||||
|
"2",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "RMBG",
|
||||||
|
"_meta": {
|
||||||
|
"title": "Remove Background (RMBG)"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
44
setup/Remove Background with BiRefNet.json
Normal file
44
setup/Remove Background with BiRefNet.json
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
{
|
||||||
|
"1": {
|
||||||
|
"inputs": {
|
||||||
|
"image": ""
|
||||||
|
},
|
||||||
|
"class_type": "LoadImage",
|
||||||
|
"_meta": {
|
||||||
|
"title": "Load Image"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"23": {
|
||||||
|
"inputs": {
|
||||||
|
"model": "BiRefNet-general",
|
||||||
|
"sensitivity": 1,
|
||||||
|
"mask_blur": 0,
|
||||||
|
"mask_offset": 0,
|
||||||
|
"invert_output": false,
|
||||||
|
"refine_foreground": false,
|
||||||
|
"background": "Alpha",
|
||||||
|
"background_color": "#222222",
|
||||||
|
"image": [
|
||||||
|
"1",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "BiRefNetRMBG",
|
||||||
|
"_meta": {
|
||||||
|
"title": "BiRefNet Remove Background (RMBG)"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"24": {
|
||||||
|
"inputs": {
|
||||||
|
"filename_prefix": "3DGenStudioRMBG",
|
||||||
|
"images": [
|
||||||
|
"23",
|
||||||
|
0
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"class_type": "SaveImage",
|
||||||
|
"_meta": {
|
||||||
|
"title": "Save Image"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
230
setup/comfyui-lock-windows-py313-cu130.txt
Normal file
230
setup/comfyui-lock-windows-py313-cu130.txt
Normal file
|
|
@ -0,0 +1,230 @@
|
||||||
|
# GENERATED by tools/gen-comfy-lock.mjs — do not hand-edit.
|
||||||
|
# Reference env: C:\Git\3DGenStudio\comfyui
|
||||||
|
# Python 3.13 · torch 2.10.0+cu130 · CUDA 13.0 · windows
|
||||||
|
# Placeholders: NODE_DIR = <install>/custom_nodes, WHEEL_HOST = manifest wheelHost
|
||||||
|
absl-py==2.5.0
|
||||||
|
accelerate==1.14.0
|
||||||
|
addict==2.4.0
|
||||||
|
aiohappyeyeballs==2.7.1
|
||||||
|
aiohttp==3.14.3
|
||||||
|
aiosignal==1.4.0
|
||||||
|
albucore==0.0.24
|
||||||
|
albumentations==2.0.8
|
||||||
|
alembic==1.18.5
|
||||||
|
annotated-doc==0.0.5
|
||||||
|
annotated-types==0.8.0
|
||||||
|
antlr4-python3-runtime==4.9.3
|
||||||
|
anyio==4.14.2
|
||||||
|
asttokens==3.0.2
|
||||||
|
attrs==26.1.0
|
||||||
|
av==18.0.0
|
||||||
|
beautifulsoup4==4.15.0
|
||||||
|
bitsandbytes==0.50.0
|
||||||
|
blake3==1.0.9
|
||||||
|
blinker==1.9.0
|
||||||
|
certifi==2026.7.22
|
||||||
|
cffi==2.1.0
|
||||||
|
charset-normalizer==3.4.9
|
||||||
|
click==8.4.2
|
||||||
|
color-matcher==0.6.0
|
||||||
|
colorama==0.4.6
|
||||||
|
colorlog==6.12.0
|
||||||
|
colour-science==0.4.7
|
||||||
|
comfy-aimdo==0.4.10
|
||||||
|
comfy-angle==0.1.0
|
||||||
|
comfy-kitchen==0.2.23
|
||||||
|
comfyui-embedded-docs==0.5.9
|
||||||
|
comfyui-workflow-templates-core==0.3.284
|
||||||
|
comfyui-workflow-templates-json==0.1.18
|
||||||
|
comfyui-workflow-templates-media-api==0.3.84
|
||||||
|
comfyui-workflow-templates-media-assets-01==0.1.12
|
||||||
|
comfyui-workflow-templates-media-image==0.3.160
|
||||||
|
comfyui-workflow-templates-media-other==0.3.229
|
||||||
|
comfyui-workflow-templates-media-video==0.3.101
|
||||||
|
comfyui_frontend_package==1.47.10
|
||||||
|
comfyui_workflow_templates==0.11.19
|
||||||
|
comm==0.2.3
|
||||||
|
ConfigArgParse==1.7.5
|
||||||
|
contourpy==1.3.3
|
||||||
|
cumesh @ ${NODE_DIR}/ComfyUI-Trellis2/wheels/Windows/Torch2100/CUDA%2013.1/cumesh-0.0.1-cp313-cp313-win_amd64.whl
|
||||||
|
cycler==0.12.1
|
||||||
|
dash==4.4.1
|
||||||
|
dataclasses-json==0.6.7
|
||||||
|
ddt==1.7.2
|
||||||
|
decorator==5.3.1
|
||||||
|
decord==0.6.0
|
||||||
|
Deprecated==1.3.1
|
||||||
|
diffusers==0.39.0
|
||||||
|
docutils==0.23
|
||||||
|
easydict==1.13
|
||||||
|
einops==0.8.2
|
||||||
|
embreex==4.4.0
|
||||||
|
executing==2.2.1
|
||||||
|
fastjsonschema==2.22.1
|
||||||
|
filelock==3.32.0
|
||||||
|
Flask==3.1.3
|
||||||
|
flatbuffers==25.12.19
|
||||||
|
flex_gemm @ ${NODE_DIR}/ComfyUI-Trellis2/wheels/Windows/Torch2100/CUDA%2013.1/flex_gemm-1.0.0-cp313-cp313-win_amd64.whl
|
||||||
|
fonttools==4.63.0
|
||||||
|
frozenlist==1.8.0
|
||||||
|
fsspec==2026.7.0
|
||||||
|
ftfy==6.3.1
|
||||||
|
fvcore==0.1.5.post20221221
|
||||||
|
gdown==6.1.0
|
||||||
|
gguf==0.19.0
|
||||||
|
glcontext==3.0.0
|
||||||
|
greenlet==3.5.4
|
||||||
|
groundingdino-py==0.4.0
|
||||||
|
h11==0.16.0
|
||||||
|
hf-xet==1.5.2
|
||||||
|
httpcore==1.0.9
|
||||||
|
httpx==0.28.1
|
||||||
|
huggingface_hub==1.25.1
|
||||||
|
hydra-core==1.3.4
|
||||||
|
idna==3.18
|
||||||
|
ImageIO==2.37.4
|
||||||
|
importlib_metadata==9.0.0
|
||||||
|
iopath==0.1.10
|
||||||
|
ipython==9.15.0
|
||||||
|
ipython_pygments_lexers==1.1.1
|
||||||
|
ipywidgets==8.1.8
|
||||||
|
itsdangerous==2.2.0
|
||||||
|
janus==2.0.0
|
||||||
|
jedi==0.20.0
|
||||||
|
Jinja2==3.1.6
|
||||||
|
joblib==1.5.3
|
||||||
|
jsonschema==4.26.0
|
||||||
|
jsonschema-specifications==2025.9.1
|
||||||
|
jupyter_core==5.9.1
|
||||||
|
jupyterlab_widgets==3.0.16
|
||||||
|
kiwisolver==1.5.0
|
||||||
|
kornia==0.8.3
|
||||||
|
kornia_rs==0.1.14
|
||||||
|
lazy-loader==0.5
|
||||||
|
lightning-utilities==0.15.3
|
||||||
|
llvmlite==0.48.0
|
||||||
|
lxml==6.1.1
|
||||||
|
Mako==1.3.12
|
||||||
|
manifold3d==3.5.2
|
||||||
|
mapbox_earcut==2.0.0
|
||||||
|
markdown-it-py==4.2.0
|
||||||
|
MarkupSafe==3.0.3
|
||||||
|
marshmallow==3.26.2
|
||||||
|
matplotlib==3.11.1
|
||||||
|
matplotlib-inline==0.2.2
|
||||||
|
mdurl==0.1.2
|
||||||
|
mediapipe==1.0.0
|
||||||
|
meshlib==3.1.3.297
|
||||||
|
moderngl==5.12.0
|
||||||
|
mpmath==1.3.0
|
||||||
|
mss==10.2.0
|
||||||
|
msvc_runtime==14.44.35112
|
||||||
|
multidict==6.7.1
|
||||||
|
mypy_extensions==1.1.0
|
||||||
|
narwhals==2.24.0
|
||||||
|
nbformat==5.10.4
|
||||||
|
nest-asyncio==1.6.0
|
||||||
|
networkx==3.6.1
|
||||||
|
numba==0.66.0
|
||||||
|
numpy==2.4.6
|
||||||
|
nvdiffrast @ ${NODE_DIR}/ComfyUI-Trellis2/wheels/Windows/Torch2100/CUDA%2013.1/nvdiffrast-0.4.0-cp313-cp313-win_amd64.whl
|
||||||
|
o_voxel @ ${NODE_DIR}/ComfyUI-Trellis2/wheels/Windows/Torch2100/CUDA%2013.1/o_voxel-0.0.1-cp313-cp313-win_amd64.whl
|
||||||
|
omegaconf==2.3.1
|
||||||
|
onnxruntime==1.28.0
|
||||||
|
onnxruntime-gpu==1.28.0
|
||||||
|
opencv-contrib-python==5.0.0.93
|
||||||
|
packaging==26.2
|
||||||
|
parso==0.8.7
|
||||||
|
pillow==12.3.0
|
||||||
|
pixeloe==0.1.4
|
||||||
|
platformdirs==4.11.0
|
||||||
|
plotly==6.9.0
|
||||||
|
plyfile==1.1.5
|
||||||
|
pooch==1.9.0
|
||||||
|
portalocker==3.2.0
|
||||||
|
prompt_toolkit==3.0.53
|
||||||
|
propcache==0.5.2
|
||||||
|
protobuf==5.29.6
|
||||||
|
psutil==7.2.2
|
||||||
|
pure_eval==0.2.3
|
||||||
|
pybind11==3.0.4
|
||||||
|
pycocotools==2.0.11
|
||||||
|
pycollada==0.9.3
|
||||||
|
pycparser==3.0
|
||||||
|
pydantic==2.13.4
|
||||||
|
pydantic-settings==2.14.2
|
||||||
|
pydantic_core==2.46.4
|
||||||
|
pygltflib==1.16.5
|
||||||
|
Pygments==2.20.0
|
||||||
|
PyMatting==1.1.15
|
||||||
|
pymeshlab==2025.7.post1
|
||||||
|
PyOpenGL==3.1.10
|
||||||
|
pyparsing==3.3.2
|
||||||
|
PySocks==1.7.1
|
||||||
|
python-dateutil==2.9.0.post0
|
||||||
|
python-dotenv==1.2.2
|
||||||
|
pytorch-lightning==2.6.5
|
||||||
|
pywin32==312
|
||||||
|
PyYAML==6.0.3
|
||||||
|
referencing==0.37.0
|
||||||
|
regex==2026.7.19
|
||||||
|
rembg==2.0.77
|
||||||
|
requests==2.34.2
|
||||||
|
retrying==1.4.2
|
||||||
|
rich==15.0.0
|
||||||
|
rpds-py==2026.6.3
|
||||||
|
rtree==1.4.1
|
||||||
|
safetensors==0.8.0
|
||||||
|
scikit-image==0.26.0
|
||||||
|
scikit-learn==1.9.0
|
||||||
|
scipy==1.18.0
|
||||||
|
segment-anything==1.0
|
||||||
|
sentencepiece==0.2.2
|
||||||
|
shapely==2.1.2
|
||||||
|
shellingham==1.5.4
|
||||||
|
simpleeval==1.0.7
|
||||||
|
simsimd==6.5.16
|
||||||
|
six==1.17.0
|
||||||
|
sounddevice==0.5.5
|
||||||
|
soupsieve==2.9.1
|
||||||
|
spandrel==0.4.2
|
||||||
|
SQLAlchemy==2.0.51
|
||||||
|
stack-data==0.6.3
|
||||||
|
stringzilla==5.0.4
|
||||||
|
supervision==0.6.0
|
||||||
|
svg.path==7.1
|
||||||
|
sympy==1.14.0
|
||||||
|
tabulate==0.10.0
|
||||||
|
termcolor==3.3.0
|
||||||
|
threadpoolctl==3.6.0
|
||||||
|
tifffile==2026.7.14
|
||||||
|
timm==1.0.28
|
||||||
|
tokenizers==0.22.2
|
||||||
|
torchmetrics==1.9.0
|
||||||
|
torchsde==0.2.6
|
||||||
|
tqdm==4.70.0
|
||||||
|
traitlets==5.15.1
|
||||||
|
trampoline==0.1.2
|
||||||
|
transformers==5.14.1
|
||||||
|
transparent-background==1.3.4
|
||||||
|
trimesh==4.12.2
|
||||||
|
triton-windows==3.7.1.post27
|
||||||
|
typer==0.27.0
|
||||||
|
typing-inspect==0.9.0
|
||||||
|
typing-inspection==0.4.2
|
||||||
|
typing_extensions==4.16.0
|
||||||
|
urllib3==2.7.0
|
||||||
|
utils3d @ https://github.com/EasternJournalist/utils3d/archive/94d1037aabbce32dea9c07a7c4849525817a1615.tar.gz
|
||||||
|
vhacdx==0.0.10
|
||||||
|
wcwidth==0.8.2
|
||||||
|
Werkzeug==3.1.8
|
||||||
|
wget==3.2
|
||||||
|
widgetsnbextension==4.0.15
|
||||||
|
wrapt==2.3.0
|
||||||
|
xatlas==0.0.11
|
||||||
|
xxhash==3.8.1
|
||||||
|
yacs==0.1.8
|
||||||
|
yapf==0.43.0
|
||||||
|
yarl==1.24.5
|
||||||
|
zipp==4.1.0
|
||||||
|
zstandard==0.25.0
|
||||||
134
setup/comfyui.json
Normal file
134
setup/comfyui.json
Normal file
|
|
@ -0,0 +1,134 @@
|
||||||
|
{
|
||||||
|
"$comment": "GENERATED by tools/gen-comfy-lock.mjs. wheelHost, launchArgs, verifyImports, optionalImports and excludePackages are hand-maintained and preserved across regenerations.",
|
||||||
|
"comfyui": {
|
||||||
|
"repo": "Comfy-Org/ComfyUI",
|
||||||
|
"ref": "e651b7bef55a5376343dcb1c0edb79f0142c985e",
|
||||||
|
"tag": "v0.29.0"
|
||||||
|
},
|
||||||
|
"pythonVersion": "3.13",
|
||||||
|
"wheelHost": "",
|
||||||
|
"launchArgs": [
|
||||||
|
"--use-flash-attention"
|
||||||
|
],
|
||||||
|
"verifyImports": [
|
||||||
|
"torch",
|
||||||
|
"nvdiffrast.torch",
|
||||||
|
"flash_attn",
|
||||||
|
"cumesh",
|
||||||
|
"o_voxel",
|
||||||
|
"flex_gemm",
|
||||||
|
"utils3d"
|
||||||
|
],
|
||||||
|
"optionalImports": [
|
||||||
|
"natten",
|
||||||
|
"custom_rasterizer",
|
||||||
|
"mesh_inpaint_processor",
|
||||||
|
"udf_ext",
|
||||||
|
"open3d",
|
||||||
|
"torch_cluster",
|
||||||
|
"torch_scatter",
|
||||||
|
"diso"
|
||||||
|
],
|
||||||
|
"excludePackages": [
|
||||||
|
"autoretopo",
|
||||||
|
"custom_rasterizer",
|
||||||
|
"diso",
|
||||||
|
"drtk",
|
||||||
|
"flash_attn",
|
||||||
|
"mesh_inpaint_processor",
|
||||||
|
"open3d",
|
||||||
|
"opencv-contrib-python-headless",
|
||||||
|
"opencv-python",
|
||||||
|
"opencv-python-headless",
|
||||||
|
"torch_cluster",
|
||||||
|
"torch_scatter",
|
||||||
|
"udf_ext"
|
||||||
|
],
|
||||||
|
"excludeNodes": [
|
||||||
|
"COMFYUI-PBRFusion4",
|
||||||
|
"ComfyUI-HY-Motion",
|
||||||
|
"ComfyUI-HunyuanVideo-Foley",
|
||||||
|
"ComfyUI-Image-Filters",
|
||||||
|
"ComfyUI-LATO.2",
|
||||||
|
"ComfyUI-LogicUtils",
|
||||||
|
"ComfyUI-Manager",
|
||||||
|
"ComfyUI-Meshflow",
|
||||||
|
"ComfyUI-QRemeshify",
|
||||||
|
"ComfyUI-SAM3",
|
||||||
|
"ComfyUI-ShadowR",
|
||||||
|
"ComfyUI-SkinToken",
|
||||||
|
"ComfyUI-Tools",
|
||||||
|
"ComfyUI-Unload-Model",
|
||||||
|
"ComfyUI-VideoHelperSuite",
|
||||||
|
"ComfyUI_InvSR",
|
||||||
|
"comfyui_sam3"
|
||||||
|
],
|
||||||
|
"builds": [
|
||||||
|
{
|
||||||
|
"platform": "windows",
|
||||||
|
"cuda": "13.0",
|
||||||
|
"torchArgs": "torch==2.10.0 torchvision==0.25.0 torchaudio==2.10.0 --index-url https://download.pytorch.org/whl/cu130",
|
||||||
|
"lock": "comfyui-lock-windows-py313-cu130.txt",
|
||||||
|
"hostedWheels": []
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"customNodes": [
|
||||||
|
{
|
||||||
|
"name": "comfyui_controlnet_aux",
|
||||||
|
"repo": "Fannovel16/comfyui_controlnet_aux",
|
||||||
|
"ref": "e8b689a513c3e6b63edc44066560ca5919c0576e"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ComfyUI_essentials",
|
||||||
|
"repo": "cubiq/ComfyUI_essentials",
|
||||||
|
"ref": "9d9f4bedfc9f0321c19faf71855e228c93bd0dc9"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "comfyui-flux2fun-controlnet",
|
||||||
|
"repo": "visualbruno/comfyui-flux2fun-controlnet",
|
||||||
|
"ref": "aca3a74de5723f13d77d54734ffaba2321ec5fe8"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ComfyUI-GGUF",
|
||||||
|
"repo": "city96/ComfyUI-GGUF",
|
||||||
|
"ref": "6ea2651e7df66d7585f6ffee804b20e92fb38b8a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ComfyUI-Hunyuan3d-2-1",
|
||||||
|
"repo": "visualbruno/ComfyUI-Hunyuan3d-2-1",
|
||||||
|
"ref": "6c1632580744dfd5f9c02f1e3eb8b06d6a3b9bc0"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ComfyUI-Hunyuan3DWrapper",
|
||||||
|
"repo": "visualbruno/ComfyUI-Hunyuan3DWrapper",
|
||||||
|
"ref": "203bc4a7b14868a248d340d8a52522bd86ac360e",
|
||||||
|
"hasWheels": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ComfyUI-KJNodes",
|
||||||
|
"repo": "kijai/ComfyUI-KJNodes",
|
||||||
|
"ref": "827fe6ee0ed7348d8daa988ed852bedf1272380c"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ComfyUI-QwenVL",
|
||||||
|
"repo": "1038lab/ComfyUI-QwenVL",
|
||||||
|
"ref": "c522c43b15618a4d5c92b2500105ee2a65527f95"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ComfyUI-RMBG",
|
||||||
|
"repo": "1038lab/ComfyUI-RMBG",
|
||||||
|
"ref": "9edb2bec390091fb9b7fb3d68a64a7af713ea2fc"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ComfyUI-Trellis2",
|
||||||
|
"repo": "visualbruno/ComfyUI-Trellis2",
|
||||||
|
"ref": "11c5e1353ea202dccd3c51590bc77516c87c5bf0",
|
||||||
|
"hasWheels": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "rgthree-comfy",
|
||||||
|
"repo": "rgthree/rgthree-comfy",
|
||||||
|
"ref": "6b76ee6f2c5a007710b5a16f97c94330d6ecc871"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
@ -611,7 +611,8 @@
|
||||||
{ "Node": "2", "Input": "image", "Name": "Source Image", "Type": "Image" },
|
{ "Node": "2", "Input": "image", "Name": "Source Image", "Type": "Image" },
|
||||||
{ "Node": "1", "Input": "max_tokens", "Name": "Max Tokens", "Type": "Number" },
|
{ "Node": "1", "Input": "max_tokens", "Name": "Max Tokens", "Type": "Number" },
|
||||||
{ "Node": "1", "Input": "custom_prompt", "Name": "Custom Prompt", "Type": "String" },
|
{ "Node": "1", "Input": "custom_prompt", "Name": "Custom Prompt", "Type": "String" },
|
||||||
{ "Node": "1", "Input": "keep_model_loaded", "Name": "Keep Model Loaded", "Type": "Boolean" }
|
{ "Node": "1", "Input": "keep_model_loaded", "Name": "Keep Model Loaded", "Type": "Boolean" },
|
||||||
|
{ "Node": "1", "Input": "model_name", "Name": "Model", "Type": "String", "Enums":["Qwen3-VL-2B-Instruct","Qwen3-VL-4B-Instruct","Qwen3-VL-8B-Instruct"] }
|
||||||
],
|
],
|
||||||
"Outputs": [
|
"Outputs": [
|
||||||
{ "Node": "3", "Name": "Output Text", "Type": "String" }
|
{ "Node": "3", "Name": "Output Text", "Type": "String" }
|
||||||
|
|
@ -661,7 +662,7 @@
|
||||||
"Inputs": [
|
"Inputs": [
|
||||||
{ "Node": "40", "Input": "image", "Name": "Source Image", "Type": "Image" },
|
{ "Node": "40", "Input": "image", "Name": "Source Image", "Type": "Image" },
|
||||||
{ "Node": "19", "Input": "max_facenum", "Name": "Target Face Number", "Type": "Number" },
|
{ "Node": "19", "Input": "max_facenum", "Name": "Target Face Number", "Type": "Number" },
|
||||||
{ "Node": "38", "Input": "seed", "Name": "Seed", "Type": "Number" }
|
{ "Node": "43", "Input": "seed", "Name": "Seed", "Type": "Number" }
|
||||||
],
|
],
|
||||||
"Outputs": [
|
"Outputs": [
|
||||||
{ "Node": "11", "Name": "Save Mesh", "Type": "Mesh" }
|
{ "Node": "11", "Name": "Save Mesh", "Type": "Mesh" }
|
||||||
|
|
@ -697,11 +698,25 @@
|
||||||
{ "Node": "1", "Input": "prompt_text", "Name": "Source Prompt", "Type": "String" },
|
{ "Node": "1", "Input": "prompt_text", "Name": "Source Prompt", "Type": "String" },
|
||||||
{ "Node": "1", "Input": "max_tokens", "Name": "Max Tokens", "Type": "Number" },
|
{ "Node": "1", "Input": "max_tokens", "Name": "Max Tokens", "Type": "Number" },
|
||||||
{ "Node": "1", "Input": "keep_model_loaded", "Name": "Keep Model Loaded", "Type": "Boolean" },
|
{ "Node": "1", "Input": "keep_model_loaded", "Name": "Keep Model Loaded", "Type": "Boolean" },
|
||||||
{ "Node": "1", "Input": "seed", "Name": "Seed", "Type": "Number" }
|
{ "Node": "1", "Input": "seed", "Name": "Seed", "Type": "Number" },
|
||||||
|
{ "Node": "1", "Input": "model_name", "Name": "Mode", "Type": "String", "Enums":["Qwen3-VL-2B-Instruct","Qwen3-VL-4B-Instruct","Qwen3-VL-8B-Instruct"] }
|
||||||
],
|
],
|
||||||
"Outputs": [
|
"Outputs": [
|
||||||
{ "Node": "2", "Name": "Enhanced Prompt", "Type": "String" }
|
{ "Node": "2", "Name": "Enhanced Prompt", "Type": "String" }
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "Remove Background with BiRefNet",
|
||||||
|
"File": "setup/Remove Background with BiRefNet.json",
|
||||||
|
"Inputs": [
|
||||||
|
{ "Node": "1", "Input": "image", "Name": "Source Image", "Type": "Image" },
|
||||||
|
{ "Node": "23", "Input": "model", "Name": "Model", "Type": "String", "Enums":["BiRefNet-general","BiRefNet_512x512","BiRefNet-HR","BiRefNet-portrait","BiRefNet-matting","BiRefNet-HR-matting","BiRefNet_lite","BiRefNet_lite-2K","BiRefNet_dynamic","BiRefNet_lite-matting","BiRefNet_toonout","Lucida"] },
|
||||||
|
{ "Node": "23", "Input": "mask_offset", "Name": "Mask Offset", "Type": "Number" },
|
||||||
|
{ "Node": "23", "Input": "mask_blur", "Name": "Mask Blur", "Type": "Number" }
|
||||||
|
],
|
||||||
|
"Outputs": [
|
||||||
|
{ "Node": "24", "Name": "Save Image", "Type": "Image" }
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,67 @@ function getCustomApiTypeLabel(type) {
|
||||||
return CUSTOM_API_TYPE_OPTIONS.find(option => option.value === type)?.label || 'Image Generation'
|
return CUSTOM_API_TYPE_OPTIONS.find(option => option.value === type)?.label || 'Image Generation'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const MANAGED_FIELD_HINT = 'Set automatically for the ComfyUI that 3D Gen Studio manages. Switch to your own ComfyUI to edit it.'
|
||||||
|
|
||||||
|
// Desktop-only: the managed ComfyUI owns apis.comfyui.path/modelsPath/port, and the
|
||||||
|
// installer only writes them when it actually installs. If those settings later
|
||||||
|
// drift to an external instance there is no way back — the installer short-circuits
|
||||||
|
// because the install already exists — so offer an explicit re-point action, plus
|
||||||
|
// the reverse (hand control back to a user-supplied ComfyUI).
|
||||||
|
function ManagedComfyControls({ managed, onChanged }) {
|
||||||
|
const bridge = typeof window !== 'undefined' ? window.genStudioServices : null
|
||||||
|
const isDesktop = !!bridge?.isDesktop
|
||||||
|
const [installed, setInstalled] = useState(null)
|
||||||
|
const [busy, setBusy] = useState(false)
|
||||||
|
const [error, setError] = useState('')
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!isDesktop) return undefined
|
||||||
|
let alive = true
|
||||||
|
bridge.status().then(s => { if (alive) setInstalled(!!s?.comfyui?.installed) }).catch(() => {})
|
||||||
|
return () => { alive = false }
|
||||||
|
}, [isDesktop, bridge])
|
||||||
|
|
||||||
|
if (!isDesktop || !installed || managed) return null
|
||||||
|
|
||||||
|
const handleUseManaged = async () => {
|
||||||
|
setError(''); setBusy(true)
|
||||||
|
try {
|
||||||
|
const res = await bridge.useManagedComfy()
|
||||||
|
if (res?.ok) await onChanged()
|
||||||
|
else setError(res?.error || 'Could not switch to the managed ComfyUI.')
|
||||||
|
} catch (e) {
|
||||||
|
setError(e?.message || 'Could not switch to the managed ComfyUI.')
|
||||||
|
} finally {
|
||||||
|
setBusy(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div style={{ marginTop: '8px' }}>
|
||||||
|
<p className="settings-helper-text" style={{ display: 'flex', alignItems: 'center', gap: '0.4em', color: '#e0a030' }}>
|
||||||
|
<span className="material-symbols-outlined" style={{ fontSize: '1.1em' }}>warning</span>
|
||||||
|
A managed ComfyUI is installed, but these settings point at a different one — so
|
||||||
|
3D Gen Studio can't start or stop it, and "start automatically" is ignored.
|
||||||
|
</p>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={handleUseManaged}
|
||||||
|
disabled={busy}
|
||||||
|
style={{
|
||||||
|
fontFamily: 'inherit', fontSize: '13px', fontWeight: 600,
|
||||||
|
cursor: busy ? 'default' : 'pointer', opacity: busy ? 0.6 : 1,
|
||||||
|
border: 'none', borderRadius: '8px', padding: '9px 16px', color: '#0b0e14',
|
||||||
|
background: 'linear-gradient(90deg, #7c5cff, #22d3ee)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{busy ? 'Switching…' : 'Use the managed ComfyUI'}
|
||||||
|
</button>
|
||||||
|
{error && <p className="settings-helper-text" style={{ color: '#f87171' }}>{error}</p>}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
// Desktop-only: start/stop a Python service on demand and show its status. The
|
// Desktop-only: start/stop a Python service on demand and show its status. The
|
||||||
// services aren't started at app launch — they spin up when a tool needs them,
|
// services aren't started at app launch — they spin up when a tool needs them,
|
||||||
// and can be stopped here (stopping Rigging frees its GPU memory). Renders
|
// and can be stopped here (stopping Rigging frees its GPU memory). Renders
|
||||||
|
|
@ -105,11 +166,19 @@ function AutoStartToggle({ checked, onChange, warning }) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Desktop-only: install the (opt-in) rigging service after first run — for users
|
// Desktop-only: install one of the opt-in services after first run — for users
|
||||||
// who upgraded, skipped it on the setup screen, or later added a GPU. Drives the
|
// who upgraded, skipped it on the setup screen, or later added a GPU. Drives the
|
||||||
// same uv provisioning as the first-run window via the genStudioSetup bridge and
|
// same uv provisioning as the first-run window via the genStudioSetup bridge and
|
||||||
// shows live progress. Renders nothing outside the desktop app.
|
// shows live progress. Renders nothing outside the desktop app.
|
||||||
function RiggingInstaller() {
|
//
|
||||||
|
// `service` is the key both setup:run and setup:status use ('rigging' | 'comfyui').
|
||||||
|
// `availableKey` (optional) names a setup:status flag that must be true for the
|
||||||
|
// install to be possible at all on this platform — when it's false we say so
|
||||||
|
// instead of offering a button that is guaranteed to fail.
|
||||||
|
// `onInstalled` lets the parent re-read the settings the main process wrote during
|
||||||
|
// the install (the managed ComfyUI sets path/modelsPath/port/managed), so the open
|
||||||
|
// form doesn't keep — and later save — its pre-install copy.
|
||||||
|
function ServiceInstaller({ service, buttonLabel, readyText, note, availableKey, unavailableText, onInstalled }) {
|
||||||
const bridge = typeof window !== 'undefined' ? window.genStudioSetup : null
|
const bridge = typeof window !== 'undefined' ? window.genStudioSetup : null
|
||||||
const isDesktop = typeof window !== 'undefined' && window.genStudioDesktop?.isDesktop && bridge
|
const isDesktop = typeof window !== 'undefined' && window.genStudioDesktop?.isDesktop && bridge
|
||||||
const [status, setStatus] = useState(null)
|
const [status, setStatus] = useState(null)
|
||||||
|
|
@ -124,20 +193,25 @@ function RiggingInstaller() {
|
||||||
bridge.status().then(s => { if (alive) setStatus(s) }).catch(() => {})
|
bridge.status().then(s => { if (alive) setStatus(s) }).catch(() => {})
|
||||||
const off = bridge.onProgress(evt => {
|
const off = bridge.onProgress(evt => {
|
||||||
if (!alive) return
|
if (!alive) return
|
||||||
|
// Progress events carry a `service` tag; ignore another service's install
|
||||||
|
// so two installer cards on screen don't cross-report each other.
|
||||||
|
if (evt.service && evt.service !== service) return
|
||||||
if (evt.kind === 'phase') { setPhase(evt.phase || ''); if (typeof evt.pct === 'number') setPct(evt.pct) }
|
if (evt.kind === 'phase') { setPhase(evt.phase || ''); if (typeof evt.pct === 'number') setPct(evt.pct) }
|
||||||
else if (evt.kind === 'error') setError(evt.text || 'Setup failed.')
|
else if (evt.kind === 'error') setError(evt.text || 'Setup failed.')
|
||||||
})
|
})
|
||||||
return () => { alive = false; if (typeof off === 'function') off() }
|
return () => { alive = false; if (typeof off === 'function') off() }
|
||||||
}, [isDesktop, bridge])
|
}, [isDesktop, bridge, service])
|
||||||
|
|
||||||
if (!isDesktop) return null
|
if (!isDesktop) return null
|
||||||
|
|
||||||
const handleInstall = async () => {
|
const handleInstall = async () => {
|
||||||
setError(''); setRunning(true); setPhase('Starting…'); setPct(0)
|
setError(''); setRunning(true); setPhase('Starting…'); setPct(0)
|
||||||
try {
|
try {
|
||||||
const res = await bridge.run({ rigging: true })
|
const res = await bridge.run({ [service]: true })
|
||||||
if (res?.ok) setStatus(await bridge.status())
|
if (res?.ok) {
|
||||||
else setError(res?.error || 'Installation failed. See details in the setup logs.')
|
setStatus(await bridge.status())
|
||||||
|
if (typeof onInstalled === 'function') await onInstalled()
|
||||||
|
} else setError(res?.error || 'Installation failed. See details in the setup logs.')
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
setError(e?.message || 'Installation failed.')
|
setError(e?.message || 'Installation failed.')
|
||||||
} finally {
|
} finally {
|
||||||
|
|
@ -145,11 +219,23 @@ function RiggingInstaller() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status?.rigging) {
|
if (status?.[service]) {
|
||||||
return (
|
return (
|
||||||
<p className="settings-helper-text" style={{ display: 'flex', alignItems: 'center', gap: '0.4em', color: '#4caf50' }}>
|
<p className="settings-helper-text" style={{ display: 'flex', alignItems: 'center', gap: '0.4em', color: '#4caf50' }}>
|
||||||
<span className="material-symbols-outlined" style={{ fontSize: '1.1em' }}>check_circle</span>
|
<span className="material-symbols-outlined" style={{ fontSize: '1.1em' }}>check_circle</span>
|
||||||
Rigging service is installed and ready.
|
{readyText}
|
||||||
|
</p>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wait for status before deciding: rendering the button and then swapping it for
|
||||||
|
// "unavailable" reads as a bug.
|
||||||
|
if (availableKey && !status) return null
|
||||||
|
if (availableKey && !status[availableKey]) {
|
||||||
|
return (
|
||||||
|
<p className="settings-helper-text" style={{ display: 'flex', alignItems: 'center', gap: '0.4em' }}>
|
||||||
|
<span className="material-symbols-outlined" style={{ fontSize: '1.1em' }}>info</span>
|
||||||
|
{unavailableText}
|
||||||
</p>
|
</p>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -167,7 +253,7 @@ function RiggingInstaller() {
|
||||||
background: 'linear-gradient(90deg, #7c5cff, #22d3ee)',
|
background: 'linear-gradient(90deg, #7c5cff, #22d3ee)',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{running ? `Installing… ${Math.round(pct * 100)}%` : 'Install rigging service'}
|
{running ? `Installing… ${Math.round(pct * 100)}%` : buttonLabel}
|
||||||
</button>
|
</button>
|
||||||
{running && (
|
{running && (
|
||||||
<>
|
<>
|
||||||
|
|
@ -178,7 +264,7 @@ function RiggingInstaller() {
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
{error && <p className="settings-helper-text" style={{ color: '#f87171' }}>{error}</p>}
|
{error && <p className="settings-helper-text" style={{ color: '#f87171' }}>{error}</p>}
|
||||||
<p className="settings-helper-text">One-time install; downloads several GB and needs an NVIDIA GPU (≥14 GB).</p>
|
<p className="settings-helper-text">{note}</p>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -226,7 +312,7 @@ function BrowseFolderButton({ description, initialPath, onPick }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function SettingsModal({ onClose }) {
|
export default function SettingsModal({ onClose }) {
|
||||||
const { settings, updateSettings, addCustomApi } = useSettings()
|
const { settings, updateSettings, addCustomApi, refreshSettings } = useSettings()
|
||||||
const [localSettings, setLocalSettings] = useState(settings)
|
const [localSettings, setLocalSettings] = useState(settings)
|
||||||
const [activeTab, setActiveTab] = useState('apis')
|
const [activeTab, setActiveTab] = useState('apis')
|
||||||
const [showAddCustom, setShowAddCustom] = useState(false)
|
const [showAddCustom, setShowAddCustom] = useState(false)
|
||||||
|
|
@ -237,8 +323,25 @@ export default function SettingsModal({ onClose }) {
|
||||||
setLocalSettings(settings)
|
setLocalSettings(settings)
|
||||||
}, [settings])
|
}, [settings])
|
||||||
|
|
||||||
|
// Server-side truth, not the form copy: the managed flag is written by the main
|
||||||
|
// process, and gating the inputs on the local copy would let a stale form make
|
||||||
|
// them editable again.
|
||||||
|
const comfyManaged = !!settings?.apis?.comfyui?.managed
|
||||||
|
|
||||||
const handleSave = async () => {
|
const handleSave = async () => {
|
||||||
await updateSettings(localSettings)
|
// `apis.comfyui.managed` and the paths/port that go with it are owned by the
|
||||||
|
// main process, not this form: it writes them when the managed ComfyUI is
|
||||||
|
// installed. The modal loads its copy of the settings once, so saving a
|
||||||
|
// form that was opened BEFORE an install would write the stale values back
|
||||||
|
// and silently un-manage the install (which is exactly what stops
|
||||||
|
// "start automatically" from working). The backend merges what we POST, so
|
||||||
|
// simply omitting these keys preserves whatever the main process set.
|
||||||
|
let payload = localSettings
|
||||||
|
if (settings?.apis?.comfyui?.managed) {
|
||||||
|
const { managed: _mg, path: _p, modelsPath: _m, port: _pt, ...userOwned } = localSettings?.apis?.comfyui || {}
|
||||||
|
payload = { ...localSettings, apis: { ...localSettings.apis, comfyui: userOwned } }
|
||||||
|
}
|
||||||
|
await updateSettings(payload)
|
||||||
onClose()
|
onClose()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -583,6 +686,8 @@ export default function SettingsModal({ onClose }) {
|
||||||
<input
|
<input
|
||||||
className="settings-input"
|
className="settings-input"
|
||||||
style={{ flex: 1 }}
|
style={{ flex: 1 }}
|
||||||
|
disabled={comfyManaged}
|
||||||
|
title={comfyManaged ? MANAGED_FIELD_HINT : undefined}
|
||||||
placeholder="C:\\ComfyUI"
|
placeholder="C:\\ComfyUI"
|
||||||
value={localSettings?.apis?.comfyui?.path || ''}
|
value={localSettings?.apis?.comfyui?.path || ''}
|
||||||
onChange={e => setLocalSettings(prev => ({
|
onChange={e => setLocalSettings(prev => ({
|
||||||
|
|
@ -596,14 +701,16 @@ export default function SettingsModal({ onClose }) {
|
||||||
}
|
}
|
||||||
}))}
|
}))}
|
||||||
/>
|
/>
|
||||||
<BrowseFolderButton
|
{!comfyManaged && (
|
||||||
description="Select your ComfyUI folder"
|
<BrowseFolderButton
|
||||||
initialPath={localSettings?.apis?.comfyui?.path || ''}
|
description="Select your ComfyUI folder"
|
||||||
onPick={picked => setLocalSettings(prev => ({
|
initialPath={localSettings?.apis?.comfyui?.path || ''}
|
||||||
...prev,
|
onPick={picked => setLocalSettings(prev => ({
|
||||||
apis: { ...prev?.apis, comfyui: { ...prev?.apis?.comfyui, path: picked } }
|
...prev,
|
||||||
}))}
|
apis: { ...prev?.apis, comfyui: { ...prev?.apis?.comfyui, path: picked } }
|
||||||
/>
|
}))}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -613,6 +720,8 @@ export default function SettingsModal({ onClose }) {
|
||||||
<input
|
<input
|
||||||
className="settings-input"
|
className="settings-input"
|
||||||
style={{ flex: 1 }}
|
style={{ flex: 1 }}
|
||||||
|
disabled={comfyManaged}
|
||||||
|
title={comfyManaged ? MANAGED_FIELD_HINT : undefined}
|
||||||
placeholder="Defaults to {ComfyUI path}\models"
|
placeholder="Defaults to {ComfyUI path}\models"
|
||||||
value={localSettings?.apis?.comfyui?.modelsPath || ''}
|
value={localSettings?.apis?.comfyui?.modelsPath || ''}
|
||||||
onChange={e => setLocalSettings(prev => ({
|
onChange={e => setLocalSettings(prev => ({
|
||||||
|
|
@ -626,17 +735,21 @@ export default function SettingsModal({ onClose }) {
|
||||||
}
|
}
|
||||||
}))}
|
}))}
|
||||||
/>
|
/>
|
||||||
<BrowseFolderButton
|
{!comfyManaged && (
|
||||||
description="Select your ComfyUI models folder"
|
<BrowseFolderButton
|
||||||
initialPath={localSettings?.apis?.comfyui?.modelsPath || localSettings?.apis?.comfyui?.path || ''}
|
description="Select your ComfyUI models folder"
|
||||||
onPick={picked => setLocalSettings(prev => ({
|
initialPath={localSettings?.apis?.comfyui?.modelsPath || localSettings?.apis?.comfyui?.path || ''}
|
||||||
...prev,
|
onPick={picked => setLocalSettings(prev => ({
|
||||||
apis: { ...prev?.apis, comfyui: { ...prev?.apis?.comfyui, modelsPath: picked } }
|
...prev,
|
||||||
}))}
|
apis: { ...prev?.apis, comfyui: { ...prev?.apis?.comfyui, modelsPath: picked } }
|
||||||
/>
|
}))}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
<p className="settings-helper-text">
|
<p className="settings-helper-text">
|
||||||
Set this only if your models live somewhere other than <code>{'{ComfyUI path}'}\models</code> (e.g. shared across multiple ComfyUI installs).
|
{comfyManaged
|
||||||
|
? 'Managed by 3D Gen Studio. The Setup Wizard downloads models here, and this folder survives a ComfyUI reinstall.'
|
||||||
|
: <>Set this only if your models live somewhere other than <code>{'{ComfyUI path}'}\models</code> (e.g. shared across multiple ComfyUI installs).</>}
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
@ -664,6 +777,8 @@ export default function SettingsModal({ onClose }) {
|
||||||
<label className="settings-label">Port</label>
|
<label className="settings-label">Port</label>
|
||||||
<input
|
<input
|
||||||
className="settings-input"
|
className="settings-input"
|
||||||
|
disabled={comfyManaged}
|
||||||
|
title={comfyManaged ? MANAGED_FIELD_HINT : undefined}
|
||||||
placeholder="8188"
|
placeholder="8188"
|
||||||
value={localSettings?.apis?.comfyui?.port || ''}
|
value={localSettings?.apis?.comfyui?.port || ''}
|
||||||
onChange={e => setLocalSettings(prev => ({
|
onChange={e => setLocalSettings(prev => ({
|
||||||
|
|
@ -683,6 +798,36 @@ export default function SettingsModal({ onClose }) {
|
||||||
<p className="settings-helper-text">
|
<p className="settings-helper-text">
|
||||||
The Kanban page will use this connection to queue workflows, poll every second, and download generated images.
|
The Kanban page will use this connection to queue workflows, poll every second, and download generated images.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
{comfyManaged && (
|
||||||
|
<p className="settings-helper-text" style={{ display: 'flex', alignItems: 'center', gap: '0.4em', color: '#22d3ee' }}>
|
||||||
|
<span className="material-symbols-outlined" style={{ fontSize: '1.1em' }}>verified</span>
|
||||||
|
This ComfyUI is managed by 3D Gen Studio, so the path, models path and port
|
||||||
|
above are set for you and can't be edited. It starts and stops below.
|
||||||
|
</p>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<ManagedComfyControls managed={comfyManaged} onChanged={refreshSettings} />
|
||||||
|
|
||||||
|
{/* Desktop only: install a ComfyUI the app manages itself, for users
|
||||||
|
who don't already run one. Skipped silently in the browser. */}
|
||||||
|
<ServiceInstaller
|
||||||
|
service="comfyui"
|
||||||
|
onInstalled={refreshSettings}
|
||||||
|
availableKey="comfyuiAvailable"
|
||||||
|
unavailableText="Installing ComfyUI automatically isn't supported on this platform yet — install it yourself and set the path and port above."
|
||||||
|
buttonLabel="Install ComfyUI for me"
|
||||||
|
readyText="A managed ComfyUI is installed and ready."
|
||||||
|
note="One-time install; downloads several GB (ComfyUI, the custom nodes the bundled workflows need, and PyTorch) and needs an NVIDIA GPU. Models are downloaded separately from the Setup Wizard."
|
||||||
|
/>
|
||||||
|
<ServiceControl name="comfyui" />
|
||||||
|
<AutoStartToggle
|
||||||
|
checked={localSettings?.apis?.comfyui?.autoStart}
|
||||||
|
onChange={v => setLocalSettings(prev => ({
|
||||||
|
...prev,
|
||||||
|
apis: { ...prev?.apis, comfyui: { ...prev?.apis?.comfyui, autoStart: v } }
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
)}
|
)}
|
||||||
|
|
@ -807,7 +952,12 @@ export default function SettingsModal({ onClose }) {
|
||||||
In the desktop app it starts on demand; Stop it here to free GPU memory.
|
In the desktop app it starts on demand; Stop it here to free GPU memory.
|
||||||
Outside the desktop app, start it from thirdparty/skintokens/run_server.
|
Outside the desktop app, start it from thirdparty/skintokens/run_server.
|
||||||
</p>
|
</p>
|
||||||
<RiggingInstaller />
|
<ServiceInstaller
|
||||||
|
service="rigging"
|
||||||
|
buttonLabel="Install rigging service"
|
||||||
|
readyText="Rigging service is installed and ready."
|
||||||
|
note="One-time install; downloads several GB and needs an NVIDIA GPU (≥14 GB)."
|
||||||
|
/>
|
||||||
<ServiceControl name="rigging" />
|
<ServiceControl name="rigging" />
|
||||||
<AutoStartToggle
|
<AutoStartToggle
|
||||||
warning
|
warning
|
||||||
|
|
|
||||||
|
|
@ -180,7 +180,14 @@ export const DEFAULT_SETTINGS = {
|
||||||
// (e.g. models are shared across ComfyUI installs via extra_model_paths.yaml).
|
// (e.g. models are shared across ComfyUI installs via extra_model_paths.yaml).
|
||||||
modelsPath: '',
|
modelsPath: '',
|
||||||
url: 'http://127.0.0.1',
|
url: 'http://127.0.0.1',
|
||||||
port: '8188'
|
port: '8188',
|
||||||
|
// Desktop app: true when this ComfyUI was installed BY the app (into the
|
||||||
|
// per-user data dir) and is therefore ours to start, stop and upgrade.
|
||||||
|
// False/absent means the user runs their own — the app only talks to it.
|
||||||
|
managed: false,
|
||||||
|
// Desktop app: start the managed ComfyUI at launch. Default off — it is a
|
||||||
|
// heavy process and most sessions start on demand instead.
|
||||||
|
autoStart: false
|
||||||
},
|
},
|
||||||
meshtools: {
|
meshtools: {
|
||||||
url: 'http://127.0.0.1',
|
url: 'http://127.0.0.1',
|
||||||
|
|
|
||||||
549
tools/gen-comfy-lock.mjs
Normal file
549
tools/gen-comfy-lock.mjs
Normal file
|
|
@ -0,0 +1,549 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
// Generate the desktop app's ComfyUI provisioning artifacts from a WORKING
|
||||||
|
// ComfyUI install. Run this on a machine where ComfyUI + all the node packs the
|
||||||
|
// shipped workflows need actually run, and it emits:
|
||||||
|
//
|
||||||
|
// setup/comfyui.json -- node-pack manifest (repo + pinned SHA)
|
||||||
|
// setup/comfyui-lock-<os>-py<ver>-cu<cuda>.txt -- the full resolved dependency set
|
||||||
|
//
|
||||||
|
// Why a LOCK rather than resolving each pack's requirements.txt at install time:
|
||||||
|
// a working ComfyUI is a specific ~360-package resolution plus a handful of
|
||||||
|
// hand-built CUDA wheels. Re-resolving per pack on the user's machine drifts
|
||||||
|
// (numpy 2 vs 1.26, transformers majors, torch ABI) and is the single most common
|
||||||
|
// way a ComfyUI install ends up broken. Installing a frozen set that is KNOWN to
|
||||||
|
// work is deterministic and much faster.
|
||||||
|
//
|
||||||
|
// Local-wheel entries in the freeze are rewritten to one of two placeholders,
|
||||||
|
// substituted at install time by electron/comfysetup.cjs:
|
||||||
|
//
|
||||||
|
// ${NODE_DIR} wheels that ship INSIDE a node repo (ComfyUI-Trellis2/wheels/**)
|
||||||
|
// -> no hosting needed, the repo download brings them along
|
||||||
|
// ${WHEEL_HOST} hand-built wheels with no upstream home (diso, drtk, custom
|
||||||
|
// open3d, torch_cluster/scatter, custom_rasterizer, autoretopo)
|
||||||
|
// -> these MUST be published somewhere reachable; the script
|
||||||
|
// prints the exact list at the end
|
||||||
|
//
|
||||||
|
// `git+https://...@<sha>` deps are rewritten to the equivalent GitHub tarball URL
|
||||||
|
// so installs never need a git binary.
|
||||||
|
//
|
||||||
|
// Usage:
|
||||||
|
// node tools/gen-comfy-lock.mjs --comfy C:/Git/ComfyUI --venv C:/Git/ComfyUI/venv_313 \
|
||||||
|
// --cuda 13.0 --wheel-host https://github.com/visualbruno/3DGenStudio-wheels/releases/download/v1
|
||||||
|
//
|
||||||
|
// Only --comfy is required; --venv is guessed, --cuda read from nvidia-smi.
|
||||||
|
|
||||||
|
import { spawnSync } from 'node:child_process';
|
||||||
|
import fs from 'node:fs';
|
||||||
|
import path from 'node:path';
|
||||||
|
import os from 'node:os';
|
||||||
|
|
||||||
|
const REPO_ROOT = path.resolve(import.meta.dirname, '..');
|
||||||
|
const IS_WIN = process.platform === 'win32';
|
||||||
|
|
||||||
|
// ---- args -------------------------------------------------------------------
|
||||||
|
function parseArgs(argv) {
|
||||||
|
const out = {};
|
||||||
|
for (let i = 0; i < argv.length; i += 1) {
|
||||||
|
const a = argv[i];
|
||||||
|
if (!a.startsWith('--')) continue;
|
||||||
|
const key = a.slice(2);
|
||||||
|
const next = argv[i + 1];
|
||||||
|
if (next && !next.startsWith('--')) { out[key] = next; i += 1; } else { out[key] = true; }
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
const args = parseArgs(process.argv.slice(2));
|
||||||
|
const COMFY = path.resolve(args.comfy || 'C:/Git/ComfyUI');
|
||||||
|
const OUT_DIR = path.resolve(args.out || path.join(REPO_ROOT, 'setup'));
|
||||||
|
const WHEEL_HOST = typeof args['wheel-host'] === 'string' ? args['wheel-host'].replace(/\/+$/, '') : '';
|
||||||
|
|
||||||
|
if (!fs.existsSync(COMFY)) die(`ComfyUI folder not found: ${COMFY}`);
|
||||||
|
if (!fs.existsSync(path.join(COMFY, 'main.py'))) die(`Not a ComfyUI folder (no main.py): ${COMFY}`);
|
||||||
|
|
||||||
|
function die(msg) {
|
||||||
|
console.error(`error: ${msg}`);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Read the existing manifest up front: several hand-maintained fields
|
||||||
|
// (excludePackages, wheelHost, launchArgs, verifyImports) steer generation and
|
||||||
|
// must survive a regeneration.
|
||||||
|
const MANIFEST_PATH = path.join(OUT_DIR, 'comfyui.json');
|
||||||
|
let prevManifestEarly = {};
|
||||||
|
try {
|
||||||
|
prevManifestEarly = JSON.parse(fs.readFileSync(MANIFEST_PATH, 'utf8'));
|
||||||
|
} catch { /* first run */ }
|
||||||
|
|
||||||
|
// ---- locate the venv --------------------------------------------------------
|
||||||
|
// Prefer an explicit --venv; otherwise look for the conventional layouts. The
|
||||||
|
// version-suffixed names (venv_313) are how the reference install is set up.
|
||||||
|
function findVenvPython() {
|
||||||
|
if (typeof args.venv === 'string') {
|
||||||
|
const p = venvPython(path.resolve(args.venv));
|
||||||
|
if (!fs.existsSync(p)) die(`No python in --venv: ${p}`);
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
const candidates = ['venv_313', '.venv_313', 'venv', '.venv', 'python_embeded'];
|
||||||
|
for (const c of candidates) {
|
||||||
|
const dir = path.join(COMFY, c);
|
||||||
|
const p = c === 'python_embeded' ? path.join(dir, 'python.exe') : venvPython(dir);
|
||||||
|
if (fs.existsSync(p)) return p;
|
||||||
|
}
|
||||||
|
die(`Could not find a ComfyUI venv under ${COMFY}. Pass --venv <path>.`);
|
||||||
|
}
|
||||||
|
|
||||||
|
function venvPython(dir) {
|
||||||
|
return IS_WIN ? path.join(dir, 'Scripts', 'python.exe') : path.join(dir, 'bin', 'python');
|
||||||
|
}
|
||||||
|
|
||||||
|
const PY = findVenvPython();
|
||||||
|
|
||||||
|
function run(cmd, cmdArgs, cwd) {
|
||||||
|
const r = spawnSync(cmd, cmdArgs, { cwd, encoding: 'utf8', maxBuffer: 64 * 1024 * 1024 });
|
||||||
|
if (r.error) return { code: -1, stdout: '', stderr: String(r.error.message) };
|
||||||
|
return { code: r.status ?? -1, stdout: r.stdout || '', stderr: r.stderr || '' };
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- environment facts ------------------------------------------------------
|
||||||
|
const pyVer = (() => {
|
||||||
|
const r = run(PY, ['-c', 'import sys;print(f"{sys.version_info.major}.{sys.version_info.minor}")']);
|
||||||
|
if (r.code !== 0) die(`Could not run ${PY}: ${r.stderr.trim()}`);
|
||||||
|
return r.stdout.trim();
|
||||||
|
})();
|
||||||
|
|
||||||
|
const torchInfo = (() => {
|
||||||
|
const r = run(PY, ['-c', 'import torch;print(torch.__version__);print(torch.version.cuda or "")']);
|
||||||
|
if (r.code !== 0) return { version: '', cuda: '' };
|
||||||
|
const [version = '', cuda = ''] = r.stdout.trim().split(/\r?\n/);
|
||||||
|
return { version: version.trim(), cuda: cuda.trim() };
|
||||||
|
})();
|
||||||
|
|
||||||
|
// The CUDA key names the lock file and is matched against the user's driver at
|
||||||
|
// install time. Prefer --cuda, then the CUDA torch was built against.
|
||||||
|
const cudaKey = (typeof args.cuda === 'string' ? args.cuda : torchInfo.cuda) || '';
|
||||||
|
if (!cudaKey) die('Could not determine the CUDA version. Pass --cuda 13.0.');
|
||||||
|
|
||||||
|
const osKey = IS_WIN ? 'windows' : process.platform === 'darwin' ? 'macos' : 'linux';
|
||||||
|
const cudaTag = `cu${cudaKey.replace(/\./g, '')}`;
|
||||||
|
const lockName = `comfyui-lock-${osKey}-py${pyVer.replace('.', '')}-${cudaTag}.txt`;
|
||||||
|
|
||||||
|
// ---- freeze -----------------------------------------------------------------
|
||||||
|
const freeze = (() => {
|
||||||
|
const r = run(PY, ['-m', 'pip', 'freeze'], COMFY);
|
||||||
|
if (r.code !== 0) die(`pip freeze failed: ${r.stderr.trim()}`);
|
||||||
|
return r.stdout.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
|
||||||
|
})();
|
||||||
|
|
||||||
|
// Packages COMPILED FROM SOURCE in the reference env (`pip install .` against a
|
||||||
|
// local CUDA toolkit) land as a bare `name==version` in the freeze but do not
|
||||||
|
// exist on PyPI under that version — custom_rasterizer is the usual culprit.
|
||||||
|
// Left alone they turn into a confident-looking lock that fails halfway through
|
||||||
|
// on a user's machine, so detect them here and route them through ${WHEEL_HOST}
|
||||||
|
// like any other hand-built wheel. Signature: legacy .egg-info metadata (or a
|
||||||
|
// missing installer record) with no direct_url.json.
|
||||||
|
const PROBE_DISTS = `
|
||||||
|
import json
|
||||||
|
from importlib.metadata import distributions
|
||||||
|
out = []
|
||||||
|
for d in distributions():
|
||||||
|
try:
|
||||||
|
name = d.metadata['Name']
|
||||||
|
except Exception:
|
||||||
|
continue
|
||||||
|
if not name:
|
||||||
|
continue
|
||||||
|
origin = None
|
||||||
|
try:
|
||||||
|
raw = d.read_text('direct_url.json')
|
||||||
|
if raw:
|
||||||
|
origin = json.loads(raw).get('url')
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
installer = (d.read_text('INSTALLER') or '').strip()
|
||||||
|
except Exception:
|
||||||
|
installer = ''
|
||||||
|
out.append({
|
||||||
|
'name': name,
|
||||||
|
'version': d.version,
|
||||||
|
'origin': origin,
|
||||||
|
'installer': installer,
|
||||||
|
'path': str(getattr(d, '_path', '')),
|
||||||
|
})
|
||||||
|
print(json.dumps(out))
|
||||||
|
`;
|
||||||
|
|
||||||
|
const sourceBuilt = new Map(); // normalized name -> { name, version }
|
||||||
|
{
|
||||||
|
const r = run(PY, ['-c', PROBE_DISTS], COMFY);
|
||||||
|
if (r.code !== 0) {
|
||||||
|
console.error(`warning: could not inspect installed distributions (${r.stderr.trim()}); ` +
|
||||||
|
'source-built packages will not be detected.');
|
||||||
|
} else {
|
||||||
|
let dists = [];
|
||||||
|
try { dists = JSON.parse(r.stdout); } catch { dists = []; }
|
||||||
|
for (const d of dists) {
|
||||||
|
if (d.origin) continue; // came from a URL/file we already rewrite
|
||||||
|
if (!/\.egg-info$/i.test(d.path || '')) continue; // modern wheel install
|
||||||
|
sourceBuilt.set(normalizeName(d.name), { name: d.name, version: d.version });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function normalizeName(name) {
|
||||||
|
return String(name).toLowerCase().replace(/[-_.]+/g, '-');
|
||||||
|
}
|
||||||
|
|
||||||
|
// The filename a source-built package's wheel is EXPECTED to have once built and
|
||||||
|
// published. `pip wheel .` in the reference env produces exactly this, so the
|
||||||
|
// name is predictable rather than a guess the user has to reverse-engineer.
|
||||||
|
function expectedWheelName(name, version) {
|
||||||
|
const tag = `cp${pyVer.replace('.', '')}`;
|
||||||
|
const plat = IS_WIN ? 'win_amd64' : osKey === 'macos' ? 'macosx_11_0_arm64' : 'linux_x86_64';
|
||||||
|
return `${String(name).replace(/-/g, '_')}-${version}-${tag}-${tag}-${plat}.whl`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- node packs -------------------------------------------------------------
|
||||||
|
// A pack is shipped only if it is a git checkout (we need a remote + SHA to pin).
|
||||||
|
// Anything else (a hand-copied folder, __pycache__, a loose .py) is reported and
|
||||||
|
// skipped — it cannot be reproduced on a user's machine.
|
||||||
|
function gitInfo(dir) {
|
||||||
|
if (!fs.existsSync(path.join(dir, '.git'))) return null;
|
||||||
|
const url = run('git', ['-C', dir, 'config', '--get', 'remote.origin.url']).stdout.trim();
|
||||||
|
const sha = run('git', ['-C', dir, 'rev-parse', 'HEAD']).stdout.trim();
|
||||||
|
if (!url || !sha) return null;
|
||||||
|
const m = url.match(/github\.com[/:]([^/]+)\/(.+?)(?:\.git)?$/i);
|
||||||
|
if (!m) return null;
|
||||||
|
|
||||||
|
// Users receive the TARBALL of this exact commit, so two states of the
|
||||||
|
// reference checkout are shipping hazards and neither is visible in the
|
||||||
|
// generated manifest:
|
||||||
|
//
|
||||||
|
// unpushed HEAD isn't on any remote branch -> the archive URL 404s for
|
||||||
|
// every user. Hard error.
|
||||||
|
// dirty tracked files are modified locally -> the reference env behaves
|
||||||
|
// differently from what ships, because uncommitted work is not in
|
||||||
|
// the tarball. Warning.
|
||||||
|
//
|
||||||
|
// (Untracked files are ignored: downloaded checkpoints and IDE folders litter
|
||||||
|
// these checkouts and never affect what ships.)
|
||||||
|
const onRemote = run('git', ['-C', dir, 'branch', '-r', '--contains', sha]).stdout.trim() !== '';
|
||||||
|
const modified = run('git', ['-C', dir, 'status', '--porcelain', '--untracked-files=no']).stdout
|
||||||
|
.split(/\r?\n/).map((s) => s.trim()).filter(Boolean);
|
||||||
|
// Is the checkout behind its own remote branch? Not fatal — pinning an older
|
||||||
|
// commit is legitimate — but worth surfacing so a forgotten pull is obvious.
|
||||||
|
const behind = Number(run('git', ['-C', dir, 'rev-list', '--count', `${sha}..origin/HEAD`]).stdout.trim()) || 0;
|
||||||
|
|
||||||
|
return { repo: `${m[1]}/${m[2]}`, ref: sha, onRemote, modified, behind };
|
||||||
|
}
|
||||||
|
|
||||||
|
const comfyGit = gitInfo(COMFY);
|
||||||
|
if (!comfyGit) die(`${COMFY} is not a GitHub git checkout — cannot pin a ComfyUI version.`);
|
||||||
|
const comfyTag = run('git', ['-C', COMFY, 'describe', '--tags', '--abbrev=0']).stdout.trim();
|
||||||
|
|
||||||
|
const nodesDir = path.join(COMFY, 'custom_nodes');
|
||||||
|
// Packs present on the reference machine that we deliberately DON'T ship: no
|
||||||
|
// bundled workflow uses any of their nodes. Hand-maintained (a heuristic
|
||||||
|
// workflow->pack mapper would eventually drop a pack that IS needed, which is a
|
||||||
|
// much worse failure than shipping one too many), and preserved across
|
||||||
|
// regenerations. See docs/COMFYUI_MANAGED.md for the current rationale per pack.
|
||||||
|
const excludeNodes = new Set(prevManifestEarly.excludeNodes || []);
|
||||||
|
const excludedNodes = [];
|
||||||
|
const skipped = [];
|
||||||
|
const nodes = [];
|
||||||
|
const packAudit = [];
|
||||||
|
for (const entry of fs.readdirSync(nodesDir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
||||||
|
if (!entry.isDirectory() || entry.name === '__pycache__') continue;
|
||||||
|
if (excludeNodes.has(entry.name)) { excludedNodes.push(entry.name); continue; }
|
||||||
|
const dir = path.join(nodesDir, entry.name);
|
||||||
|
const info = gitInfo(dir);
|
||||||
|
if (!info) { skipped.push(entry.name); continue; }
|
||||||
|
// Record whether the pack carries its own prebuilt wheels, so the installer
|
||||||
|
// knows to look inside it after unpacking (ComfyUI-Trellis2 does).
|
||||||
|
// The audit fields are for this script's report only — keep them out of the
|
||||||
|
// manifest, which should carry just what the installer needs.
|
||||||
|
const { onRemote, modified, behind, ...pin } = info;
|
||||||
|
packAudit.push({ name: entry.name, onRemote, modified, behind });
|
||||||
|
const node = { name: entry.name, ...pin };
|
||||||
|
if (fs.existsSync(path.join(dir, 'wheels'))) node.hasWheels = true;
|
||||||
|
nodes.push(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- rewrite the freeze into a portable lock --------------------------------
|
||||||
|
const nodeWheels = []; // wheels found inside a node repo -> ${NODE_DIR}
|
||||||
|
const hostWheels = []; // hand-built wheels with no home -> ${WHEEL_HOST}
|
||||||
|
const tarballs = []; // git+ deps rewritten to archive tarballs
|
||||||
|
|
||||||
|
// A file:// URL in a freeze is percent-encoded; decode before matching paths.
|
||||||
|
function decodeFileUrl(url) {
|
||||||
|
return decodeURIComponent(url.replace(/^file:\/\/\/?/, '')).replace(/\\/g, '/');
|
||||||
|
}
|
||||||
|
|
||||||
|
function rewriteLine(line) {
|
||||||
|
// "name @ file:///C:/..." -> placeholder form
|
||||||
|
const fileMatch = line.match(/^(\S+)\s*@\s*(file:\/\/\S+)$/i);
|
||||||
|
if (fileMatch) {
|
||||||
|
const [, name, url] = fileMatch;
|
||||||
|
const abs = decodeFileUrl(url);
|
||||||
|
const rel = path.relative(nodesDir, abs).replace(/\\/g, '/');
|
||||||
|
if (!rel.startsWith('..')) {
|
||||||
|
nodeWheels.push({ name, rel });
|
||||||
|
// Percent-encode: ComfyUI-Trellis2 ships wheels under "CUDA 13.1", and a
|
||||||
|
// raw space in a requirements URL is at best installer-dependent.
|
||||||
|
return `${name} @ \${NODE_DIR}/${encodeURI(rel).replace(/#/g, '%23')}`;
|
||||||
|
}
|
||||||
|
const base = path.basename(abs);
|
||||||
|
hostWheels.push({ name, file: base });
|
||||||
|
return `${name} @ \${WHEEL_HOST}/${base}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// "name @ git+https://github.com/o/r@sha" -> codeload tarball (no git needed)
|
||||||
|
const gitMatch = line.match(/^(\S+)\s*@\s*git\+https:\/\/github\.com\/([^/]+)\/([^@/]+?)(?:\.git)?@([0-9a-f]{7,40})$/i);
|
||||||
|
if (gitMatch) {
|
||||||
|
const [, name, owner, repo, sha] = gitMatch;
|
||||||
|
const url = `https://github.com/${owner}/${repo}/archive/${sha}.tar.gz`;
|
||||||
|
tarballs.push({ name, url });
|
||||||
|
return `${name} @ ${url}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// "name==version" for something compiled from source here -> hosted wheel.
|
||||||
|
const pinMatch = line.match(/^([A-Za-z0-9._-]+)==(.+)$/);
|
||||||
|
if (pinMatch) {
|
||||||
|
const [, name, version] = pinMatch;
|
||||||
|
const built = sourceBuilt.get(normalizeName(name));
|
||||||
|
if (built) {
|
||||||
|
const file = expectedWheelName(name, version);
|
||||||
|
hostWheels.push({ name, file, built: true });
|
||||||
|
return `${name} @ \${WHEEL_HOST}/${file}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return line;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Drop packages that must never come from the lock: torch is installed FIRST
|
||||||
|
// from its own CUDA index (the lock has no index-url context), and pip/setuptools/
|
||||||
|
// wheel/uv are the installer's own tools.
|
||||||
|
const TORCH_PKGS = new Set(['torch', 'torchvision', 'torchaudio']);
|
||||||
|
const TOOL_PKGS = new Set(['pip', 'setuptools', 'wheel', 'uv']);
|
||||||
|
|
||||||
|
// Packages present in the reference env but deliberately OMITTED from the lock,
|
||||||
|
// because they are optional at runtime (guarded or in-function imports) and have
|
||||||
|
// no publishable wheel. Keeping them in would make every install depend on
|
||||||
|
// hosting a wheel that nothing actually needs. Hand-maintained in the manifest;
|
||||||
|
// see optionalImports for how their absence is reported.
|
||||||
|
const excludePackages = new Set(
|
||||||
|
(prevManifestEarly.excludePackages || []).map((n) => normalizeName(n))
|
||||||
|
);
|
||||||
|
const excluded = [];
|
||||||
|
|
||||||
|
const lockLines = [];
|
||||||
|
const torchPins = {};
|
||||||
|
for (const line of freeze) {
|
||||||
|
const name = (line.match(/^([A-Za-z0-9._-]+)/) || [])[1] || '';
|
||||||
|
const key = name.toLowerCase().replace(/_/g, '-');
|
||||||
|
if (TORCH_PKGS.has(key)) {
|
||||||
|
const ver = (line.split('==')[1] || '').trim();
|
||||||
|
if (ver) torchPins[key] = ver;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (TOOL_PKGS.has(key)) continue;
|
||||||
|
if (excludePackages.has(normalizeName(name))) { excluded.push(name); continue; }
|
||||||
|
lockLines.push(rewriteLine(line));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- torch install command --------------------------------------------------
|
||||||
|
// Reuse the shape the rigging setup already relies on: explicit pins + the CUDA
|
||||||
|
// wheel index. Versions come from the reference env so the ABI matches every
|
||||||
|
// prebuilt wheel in the lock.
|
||||||
|
const torchArgs = [
|
||||||
|
torchPins.torch ? `torch==${torchPins.torch.replace(/\+.*$/, '')}` : null,
|
||||||
|
torchPins.torchvision ? `torchvision==${torchPins.torchvision.replace(/\+.*$/, '')}` : null,
|
||||||
|
torchPins.torchaudio ? `torchaudio==${torchPins.torchaudio.replace(/\+.*$/, '')}` : null,
|
||||||
|
'--index-url', `https://download.pytorch.org/whl/${cudaTag}`,
|
||||||
|
].filter(Boolean).join(' ');
|
||||||
|
|
||||||
|
// ---- write ------------------------------------------------------------------
|
||||||
|
fs.mkdirSync(OUT_DIR, { recursive: true });
|
||||||
|
|
||||||
|
const lockHeader = [
|
||||||
|
`# GENERATED by tools/gen-comfy-lock.mjs — do not hand-edit.`,
|
||||||
|
`# Reference env: ${COMFY}`,
|
||||||
|
`# Python ${pyVer} · torch ${torchInfo.version} · CUDA ${cudaKey} · ${osKey}`,
|
||||||
|
// Written without the ${...} braces so the installer's own placeholder
|
||||||
|
// substitution doesn't rewrite this comment and confuse the setup log.
|
||||||
|
`# Placeholders: NODE_DIR = <install>/custom_nodes, WHEEL_HOST = manifest wheelHost`,
|
||||||
|
'',
|
||||||
|
].join('\n');
|
||||||
|
fs.writeFileSync(path.join(OUT_DIR, lockName), lockHeader + lockLines.join('\n') + '\n');
|
||||||
|
|
||||||
|
const manifestPath = MANIFEST_PATH;
|
||||||
|
// Deployment/runtime config, not facts discoverable from the reference machine,
|
||||||
|
// so a regeneration must not stomp them.
|
||||||
|
const prevManifest = prevManifestEarly;
|
||||||
|
|
||||||
|
const manifest = {
|
||||||
|
$comment: 'GENERATED by tools/gen-comfy-lock.mjs. wheelHost, launchArgs, verifyImports, optionalImports and excludePackages are hand-maintained and preserved across regenerations.',
|
||||||
|
comfyui: { repo: comfyGit.repo, ref: comfyGit.ref, tag: comfyTag || undefined },
|
||||||
|
pythonVersion: pyVer,
|
||||||
|
wheelHost: WHEEL_HOST || prevManifest.wheelHost || '',
|
||||||
|
// Extra flags for `python main.py` on launch.
|
||||||
|
launchArgs: prevManifest.launchArgs || ['--use-flash-attention'],
|
||||||
|
// Modules the installer imports to prove the GPU wheels actually load — a wheel
|
||||||
|
// built against a different torch ABI installs fine and only fails at import.
|
||||||
|
// A failure here FAILS the install.
|
||||||
|
verifyImports: prevManifest.verifyImports || ['torch'],
|
||||||
|
// Same probe, but non-fatal: capabilities that degrade rather than break when
|
||||||
|
// absent (guarded or in-function imports). Reported in the setup log so it's
|
||||||
|
// visible which optional features this machine won't have.
|
||||||
|
optionalImports: prevManifest.optionalImports || [],
|
||||||
|
// Omitted from the generated lock entirely — see the excludePackages comment
|
||||||
|
// in the loop above.
|
||||||
|
excludePackages: prevManifest.excludePackages || [],
|
||||||
|
// custom_nodes folders on the reference machine that we don't ship.
|
||||||
|
excludeNodes: prevManifest.excludeNodes || [],
|
||||||
|
builds: [
|
||||||
|
{
|
||||||
|
platform: osKey,
|
||||||
|
cuda: cudaKey,
|
||||||
|
torchArgs,
|
||||||
|
lock: lockName,
|
||||||
|
// Wheels the lock pulls from ${WHEEL_HOST}; the installer verifies every
|
||||||
|
// one is reachable BEFORE downloading multiple GB of torch.
|
||||||
|
hostedWheels: [...new Set(hostWheels.map((w) => w.file))].sort(),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
customNodes: nodes,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Merge this build into any builds already recorded for other platforms/CUDA
|
||||||
|
// versions instead of clobbering them.
|
||||||
|
try {
|
||||||
|
const prev = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
||||||
|
if (Array.isArray(prev.builds)) {
|
||||||
|
const keep = prev.builds.filter((b) => !(b.platform === osKey && b.cuda === cudaKey));
|
||||||
|
manifest.builds = [...keep, ...manifest.builds];
|
||||||
|
}
|
||||||
|
} catch { /* first run */ }
|
||||||
|
|
||||||
|
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2) + '\n');
|
||||||
|
|
||||||
|
// ---- sanity: can this reference env actually satisfy the install gate? -------
|
||||||
|
// The installer's last step imports manifest.verifyImports and FAILS if any are
|
||||||
|
// missing. If they aren't importable HERE, the lock we just wrote can't satisfy
|
||||||
|
// that gate on a user's machine either — better to say so now than to ship a
|
||||||
|
// manifest whose own install is guaranteed to fail at 92%.
|
||||||
|
const gateMissing = [];
|
||||||
|
{
|
||||||
|
const mods = manifest.verifyImports || [];
|
||||||
|
if (mods.length) {
|
||||||
|
const probe = [
|
||||||
|
'import importlib, sys',
|
||||||
|
`mods = ${JSON.stringify(mods)}`,
|
||||||
|
'for m in mods:',
|
||||||
|
' try:',
|
||||||
|
' importlib.import_module(m)',
|
||||||
|
' except Exception:',
|
||||||
|
' print(m)',
|
||||||
|
].join('\n');
|
||||||
|
const r = run(PY, ['-c', probe], COMFY);
|
||||||
|
if (r.code === 0) {
|
||||||
|
gateMissing.push(...r.stdout.split(/\r?\n/).map((s) => s.trim()).filter(Boolean));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---- report -----------------------------------------------------------------
|
||||||
|
const rel = (p) => path.relative(REPO_ROOT, p).replace(/\\/g, '/');
|
||||||
|
console.log(`Python ${pyVer} · torch ${torchInfo.version} · CUDA ${cudaKey} · ${osKey}`);
|
||||||
|
console.log(`torch install: ${torchArgs}`);
|
||||||
|
console.log(`wrote ${rel(path.join(OUT_DIR, lockName))} (${lockLines.length} packages)`);
|
||||||
|
console.log(`wrote ${rel(manifestPath)} (${nodes.length} node packs)`);
|
||||||
|
if (tarballs.length) {
|
||||||
|
console.log(`\nrewrote ${tarballs.length} git dependency(ies) to tarballs (no git needed at install time):`);
|
||||||
|
for (const t of tarballs) console.log(` ${t.name} -> ${t.url}`);
|
||||||
|
}
|
||||||
|
if (nodeWheels.length) {
|
||||||
|
console.log(`\n${nodeWheels.length} wheel(s) resolve from inside a node repo — nothing to host:`);
|
||||||
|
for (const w of nodeWheels) console.log(` ${w.name} -> \${NODE_DIR}/${w.rel}`);
|
||||||
|
}
|
||||||
|
if (excluded.length) {
|
||||||
|
console.log(`\nexcluded from the lock by manifest.excludePackages (optional at runtime): ${excluded.join(', ')}`);
|
||||||
|
}
|
||||||
|
if (excludedNodes.length) {
|
||||||
|
console.log(`\nnot shipped, per manifest.excludeNodes (${excludedNodes.length} pack(s) no bundled workflow uses):`);
|
||||||
|
console.log(` ${excludedNodes.join(', ')}`);
|
||||||
|
console.log(' NOTE: the lock is still a freeze of THIS machine, so it may carry dependencies');
|
||||||
|
console.log(' only those packs needed. For a minimal lock, generate from an env with just the');
|
||||||
|
console.log(' shipped packs installed.');
|
||||||
|
}
|
||||||
|
if (skipped.length) {
|
||||||
|
console.log(`\nWARNING: ${skipped.length} custom_nodes folder(s) are not GitHub checkouts and were SKIPPED`);
|
||||||
|
console.log(`(they cannot be reproduced on a user's machine): ${skipped.join(', ')}`);
|
||||||
|
}
|
||||||
|
// Pinned commits that aren't on a remote branch would 404 for every user, so this
|
||||||
|
// is fatal. Local modifications only mean the reference env differs from what
|
||||||
|
// ships — worth shouting about, but not fatal.
|
||||||
|
{
|
||||||
|
const unpushed = packAudit.filter((p) => !p.onRemote);
|
||||||
|
const dirty = packAudit.filter((p) => p.modified.length);
|
||||||
|
const behind = packAudit.filter((p) => p.behind > 0);
|
||||||
|
|
||||||
|
if (unpushed.length) {
|
||||||
|
console.log(`\n${'!'.repeat(72)}`);
|
||||||
|
console.log(`UNPUSHED COMMITS: ${unpushed.length} pack(s) are pinned to a commit that is not on`);
|
||||||
|
console.log('any remote branch. The install downloads github.com/<repo>/archive/<ref>.tar.gz,');
|
||||||
|
console.log('so these would 404 for every user. Push them, then re-run:');
|
||||||
|
for (const p of unpushed) console.log(` ${p.name}`);
|
||||||
|
console.log('!'.repeat(72));
|
||||||
|
process.exitCode = 1;
|
||||||
|
}
|
||||||
|
if (dirty.length) {
|
||||||
|
console.log(`\nWARNING: ${dirty.length} pack(s) have locally MODIFIED tracked files. Users get the`);
|
||||||
|
console.log('tarball of the pinned commit, so those edits do NOT ship — the reference env');
|
||||||
|
console.log('can appear to work while the shipped pack behaves differently:');
|
||||||
|
for (const p of dirty) {
|
||||||
|
console.log(` ${p.name} (${p.modified.length} file(s)): ${p.modified.slice(0, 3).map((s) => s.replace(/^\S+\s+/, '')).join(', ')}${p.modified.length > 3 ? ', …' : ''}`);
|
||||||
|
}
|
||||||
|
console.log(' Commit and push anything that needs to reach users, then re-run.');
|
||||||
|
}
|
||||||
|
if (behind.length) {
|
||||||
|
console.log(`\nNOTE: ${behind.length} pack(s) are pinned behind their remote branch` +
|
||||||
|
' (fine if deliberate):');
|
||||||
|
for (const p of behind) console.log(` ${p.name} — ${p.behind} commit(s) behind origin`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (gateMissing.length) {
|
||||||
|
console.log(`\n${'!'.repeat(72)}`);
|
||||||
|
console.log(`INCOMPLETE REFERENCE ENV: ${gateMissing.length} module(s) in manifest.verifyImports`);
|
||||||
|
console.log(`cannot be imported from ${rel(PY)}:`);
|
||||||
|
for (const m of gateMissing) console.log(` ${m}`);
|
||||||
|
console.log('');
|
||||||
|
console.log('The installer fails the install when these are missing, so the lock just');
|
||||||
|
console.log('written CANNOT produce a working install. Either:');
|
||||||
|
console.log(' - install them into the reference env and re-run this script, or');
|
||||||
|
console.log(' - move them to optionalImports if the bundled workflows do not need them.');
|
||||||
|
console.log('!'.repeat(72));
|
||||||
|
process.exitCode = 1;
|
||||||
|
}
|
||||||
|
if (hostWheels.length) {
|
||||||
|
const files = [...new Set(hostWheels.map((w) => w.file))].sort();
|
||||||
|
const builtFiles = new Set(hostWheels.filter((w) => w.built).map((w) => w.file));
|
||||||
|
console.log(`\n${'='.repeat(72)}`);
|
||||||
|
console.log(`ACTION REQUIRED: ${files.length} hand-built wheel(s) have no upstream download.`);
|
||||||
|
console.log(`Publish these (e.g. as GitHub release assets) and set "wheelHost" in`);
|
||||||
|
console.log(`setup/comfyui.json to the base URL that serves them:`);
|
||||||
|
for (const f of files) {
|
||||||
|
// A "build me" entry has no wheel on the reference machine either — it was
|
||||||
|
// `pip install .`d from source, so the wheel has to be produced first.
|
||||||
|
console.log(` ${f}${builtFiles.has(f) ? ' <- BUILD FIRST: pip wheel <source dir> (compiled from source here)' : ''}`);
|
||||||
|
}
|
||||||
|
if (!manifest.wheelHost) console.log(`\n wheelHost is currently EMPTY — the installer will refuse to run.`);
|
||||||
|
else console.log(`\n wheelHost = ${manifest.wheelHost}`);
|
||||||
|
console.log('='.repeat(72));
|
||||||
|
}
|
||||||
|
if (os.platform() !== 'win32') {
|
||||||
|
console.log('\nNote: run this on each platform you ship (the lock is platform-specific).');
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue