Environment management for ComfyUI custom nodes - CUDA wheel resolution and process isolation
Project description
comfy-env
Environment management for ComfyUI custom nodes.
The Problem
ComfyUI custom nodes share a single Python environment. This breaks when:
- Node A needs torch 2.4, Node B needs torch 2.8
- Two packages bundle conflicting native libraries (libomp, CUDA runtimes)
- A node requires a specific Python version (e.g., Blender API needs 3.11)
The Solution
comfy-env provides process isolation — nodes that need conflicting dependencies run in their own Python environments as persistent subprocesses, transparent to ComfyUI.
Two config files, two roles:
comfy-env-root.toml(root level): System packages (apt/brew) and ComfyUI node dependency management. Never touches the Python environment — PyPI deps stay inrequirements.txt.comfy-env.toml(subdirectories): Each subdirectory with this file gets its own isolated Python environment via pixi, with a separate interpreter, conda packages, pip packages, and pre-built CUDA wheels.
Architecture
ComfyUI-MyPack/
├── comfy-env-root.toml # System packages + node deps
├── install.py # from comfy_env import install; install()
├── prestartup_script.py # from comfy_env import setup_env; setup_env()
├── __init__.py # from comfy_env import register_nodes
└── nodes/
├── main/ # No config → imported in main process
│ └── __init__.py
└── cgal/ # Has config → isolated subprocess
├── comfy-env.toml
├── _env_a1b2c3 ─────────► <drive>/ce/_env_a1b2c3/.pixi/envs/default
└── __init__.py
<drive>/ce/ # Central build cache (same drive as ComfyUI)
└── _env_a1b2c3/ # SHA256(config + comfy-env version)[:8]
├── .pixi/envs/default/ # Complete Python environment
│ ├── bin/python
│ └── lib/python3.11/site-packages/
├── pixi.toml # Generated from comfy-env.toml
└── .done # Build complete marker
How It Works
Build time (install.py): For each subdirectory with a comfy-env.toml, comfy-env hashes the config contents + its own package version, checks the central build cache (<drive>/ce on Windows, ~/.ce on Unix; override with COMFY_ENV_BUILD_BASE), and builds a pixi environment if needed. The result is linked into the node directory as _env_<hash> — symlink on Unix, NTFS junction on Windows (no admin required). Identical configs across different node packs share the same cached build.
Runtime (register_nodes()): Discovers all node subdirectories. Those with a built _env_* run in persistent subprocess workers using the isolated Python interpreter. Those without a config are imported normally. Workers communicate via Unix domain sockets (TCP on Windows) and support bidirectional callbacks for VRAM budget negotiation and progress reporting.
CUDA packages: Listed in [cuda], installed from the PyTorch wheel index or cuda-wheels — pre-built wheels for nvdiffrast, pytorch3d, gsplat, etc. No CUDA toolkit or C++ compiler needed.
Usage
# install.py
from comfy_env import install
install()
# prestartup_script.py
from comfy_env import setup_env
setup_env()
# __init__.py
from comfy_env import register_nodes
NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS = register_nodes()
pip install comfy-env
Docs
- Getting Started — setup guide and walkthrough
- Config Reference — all config options for both files
- CLI — command-line tools
- Build Internals — how isolated environments are built
- Worker Architecture — subprocess IPC, serialization, memory, lifecycle
Example
ComfyUI-GeometryPack — multiple isolated environments (CGAL, Blender, GPU) with per-subdirectory configs and different Python versions.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file comfy_env-0.2.61.tar.gz.
File metadata
- Download URL: comfy_env-0.2.61.tar.gz
- Upload date:
- Size: 112.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
015a1406a98e41db02a375f3b94886f48cfc2dcefc39a259761d868567a3aa4b
|
|
| MD5 |
aae3fa444d1016e1c4702f7051e10604
|
|
| BLAKE2b-256 |
1d3963f6f11826eb0f9b980a09c54a0be0a9e8d0261e7a1cc13cb3b889d32cda
|
Provenance
The following attestation bundles were made for comfy_env-0.2.61.tar.gz:
Publisher:
publish.yml on PozzettiAndrea/comfy-env
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
comfy_env-0.2.61.tar.gz -
Subject digest:
015a1406a98e41db02a375f3b94886f48cfc2dcefc39a259761d868567a3aa4b - Sigstore transparency entry: 1201020367
- Sigstore integration time:
-
Permalink:
PozzettiAndrea/comfy-env@26d5ddfdc86ac0bd053d39b573416ec48096315f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/PozzettiAndrea
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@26d5ddfdc86ac0bd053d39b573416ec48096315f -
Trigger Event:
push
-
Statement type:
File details
Details for the file comfy_env-0.2.61-py3-none-any.whl.
File metadata
- Download URL: comfy_env-0.2.61-py3-none-any.whl
- Upload date:
- Size: 113.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5c88360f5d241eb915c2065094ee095f08622b34500d1b548846bde08cb705ff
|
|
| MD5 |
a5bfc991e8af66307de11fec56bc1696
|
|
| BLAKE2b-256 |
bf19ccbabd3c084dd9861376276c484c428148674f35fda0852e6b4f6f6ecd34
|
Provenance
The following attestation bundles were made for comfy_env-0.2.61-py3-none-any.whl:
Publisher:
publish.yml on PozzettiAndrea/comfy-env
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
comfy_env-0.2.61-py3-none-any.whl -
Subject digest:
5c88360f5d241eb915c2065094ee095f08622b34500d1b548846bde08cb705ff - Sigstore transparency entry: 1201020368
- Sigstore integration time:
-
Permalink:
PozzettiAndrea/comfy-env@26d5ddfdc86ac0bd053d39b573416ec48096315f -
Branch / Tag:
refs/heads/main - Owner: https://github.com/PozzettiAndrea
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@26d5ddfdc86ac0bd053d39b573416ec48096315f -
Trigger Event:
push
-
Statement type: