Skip to main content

Environment management for ComfyUI custom nodes - CUDA wheel resolution and process isolation

Project description

comfy-env

Environment management for ComfyUI custom nodes.

Quick Start

pip install comfy-env

1. Create comfy-env-root.toml in your node directory:

[cuda]
packages = ["nvdiffrast", "pytorch3d"]

[apt]
packages = ["libgl1-mesa-glx"]

[node_reqs]
ComfyUI_essentials = "cubiq/ComfyUI_essentials"

PyPI deps go in requirements.txt (standard ComfyUI pattern).

2. In install.py:

from comfy_env import install
install()

3. In prestartup_script.py:

from comfy_env import setup_env
setup_env()

Two Config Files

File Purpose
comfy-env-root.toml Main node config (root level)
comfy-env.toml Isolated subfolder config

comfy-env-root.toml (main node)

[cuda]
packages = ["nvdiffrast", "pytorch3d"]

[apt]
packages = ["libgl1-mesa-glx"]

[dependencies]
cgal = "*"

[env_vars]
KMP_DUPLICATE_LIB_OK = "TRUE"

[node_reqs]
ComfyUI_essentials = "cubiq/ComfyUI_essentials"

PyPI deps → requirements.txt

comfy-env.toml (isolated folder)

python = "3.11"

[dependencies]
cgal = "*"

[pypi-dependencies]
trimesh = { version = "*", extras = ["easy"] }

[env_vars]
SOME_VAR = "value"

What goes where?

Section Root Isolated
[cuda]
[apt]
[dependencies]
[env_vars]
[node_reqs]
python = "X.Y"
[pypi-dependencies]

Process Isolation

For nodes with conflicting dependencies:

# In nodes/__init__.py
from pathlib import Path
from comfy_env import wrap_isolated_nodes

from .cgal import NODE_CLASS_MAPPINGS as cgal_mappings

NODE_CLASS_MAPPINGS = wrap_isolated_nodes(
    cgal_mappings,
    Path(__file__).parent / "cgal"  # Has comfy-env.toml
)

Each wrapped node runs in a subprocess with its own Python environment.


CLI

comfy-env init              # Create comfy-env-root.toml
comfy-env init --isolated   # Create comfy-env.toml (for subfolders)
comfy-env install           # Install dependencies
comfy-env install --dry-run # Preview
comfy-env info              # Show runtime info
comfy-env doctor            # Verify packages
comfy-env apt-install       # Install system packages

API

install()

from comfy_env import install
install()

setup_env()

from comfy_env import setup_env
setup_env()  # Call in prestartup_script.py

wrap_isolated_nodes()

from comfy_env import wrap_isolated_nodes
wrapped = wrap_isolated_nodes(NODE_CLASS_MAPPINGS, node_dir)

Detection

from comfy_env import RuntimeEnv, detect_cuda_version, detect_gpu

env = RuntimeEnv.detect()
print(env)  # Python 3.11, CUDA 12.8, PyTorch 2.8.0, GPU: RTX 4090

Example

See ComfyUI-GeometryPack:

  • Multiple isolated environments (CGAL, Blender, GPU)
  • Per-subdirectory comfy-env.toml
  • Different Python versions

Why?

Why isolation? ComfyUI nodes share one Python. Conflicts happen when:

  • Node A needs torch 2.4, Node B needs torch 2.8
  • Two packages bundle incompatible libomp
  • Blender API requires Python 3.11

Why CUDA wheels? Installing nvdiffrast normally needs CUDA toolkit + C++ compiler + 30 min compilation. cuda-wheels provides pre-built wheels.

How envs work:

  • Central cache: ~/.comfy-env/envs/
  • Marker files link nodes → cached envs
  • Config hash in name → changes create new envs

License

MIT

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

comfy_env-0.1.18.tar.gz (49.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

comfy_env-0.1.18-py3-none-any.whl (62.1 kB view details)

Uploaded Python 3

File details

Details for the file comfy_env-0.1.18.tar.gz.

File metadata

  • Download URL: comfy_env-0.1.18.tar.gz
  • Upload date:
  • Size: 49.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for comfy_env-0.1.18.tar.gz
Algorithm Hash digest
SHA256 3ce23f6a90a8e997f2687ba2df9829bfca1e9dcd3cdca534ceb30a7680cedd7b
MD5 42a542dc36c3ab29309c7f55b804ea7a
BLAKE2b-256 96b1398a94930cc4829085b067821a483f59d95d4afed0822ada37cd48458971

See more details on using hashes here.

Provenance

The following attestation bundles were made for comfy_env-0.1.18.tar.gz:

Publisher: publish.yml on PozzettiAndrea/comfy-env

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file comfy_env-0.1.18-py3-none-any.whl.

File metadata

  • Download URL: comfy_env-0.1.18-py3-none-any.whl
  • Upload date:
  • Size: 62.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for comfy_env-0.1.18-py3-none-any.whl
Algorithm Hash digest
SHA256 243b38f968a5cd0ca83240bf82463000ff7141b6fad6253d628da308b4819bf2
MD5 95540273edc555a6d68b410a149641fa
BLAKE2b-256 9d5af597a4137b95e10126126ae4a136d90fa3ac931093d294b6779e3cea0d34

See more details on using hashes here.

Provenance

The following attestation bundles were made for comfy_env-0.1.18-py3-none-any.whl:

Publisher: publish.yml on PozzettiAndrea/comfy-env

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page