comfy-env 0.1.15__tar.gz → 0.1.17__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- comfy_env-0.1.17/PKG-INFO +225 -0
- comfy_env-0.1.17/README.md +196 -0
- {comfy_env-0.1.15 → comfy_env-0.1.17}/pyproject.toml +1 -1
- comfy_env-0.1.17/src/comfy_env/__init__.py +188 -0
- comfy_env-0.1.17/src/comfy_env/cli.py +241 -0
- comfy_env-0.1.17/src/comfy_env/config/__init__.py +25 -0
- comfy_env-0.1.17/src/comfy_env/config/parser.py +65 -0
- comfy_env-0.1.17/src/comfy_env/config/types.py +37 -0
- comfy_env-0.1.17/src/comfy_env/detection/__init__.py +77 -0
- comfy_env-0.1.17/src/comfy_env/detection/cuda.py +61 -0
- comfy_env-0.1.17/src/comfy_env/detection/gpu.py +230 -0
- comfy_env-0.1.17/src/comfy_env/detection/platform.py +70 -0
- comfy_env-0.1.17/src/comfy_env/detection/runtime.py +103 -0
- comfy_env-0.1.17/src/comfy_env/environment/__init__.py +53 -0
- comfy_env-0.1.17/src/comfy_env/environment/cache.py +141 -0
- comfy_env-0.1.17/src/comfy_env/environment/libomp.py +41 -0
- comfy_env-0.1.17/src/comfy_env/environment/paths.py +38 -0
- comfy_env-0.1.17/src/comfy_env/environment/setup.py +91 -0
- comfy_env-0.1.17/src/comfy_env/install.py +254 -0
- comfy_env-0.1.17/src/comfy_env/isolation/__init__.py +40 -0
- comfy_env-0.1.17/src/comfy_env/isolation/tensor_utils.py +83 -0
- comfy_env-0.1.17/src/comfy_env/isolation/workers/__init__.py +16 -0
- {comfy_env-0.1.15/src/comfy_env → comfy_env-0.1.17/src/comfy_env/isolation}/workers/mp.py +1 -1
- {comfy_env-0.1.15/src/comfy_env → comfy_env-0.1.17/src/comfy_env/isolation}/workers/subprocess.py +1 -1
- comfy_env-0.1.17/src/comfy_env/isolation/wrap.py +235 -0
- comfy_env-0.1.17/src/comfy_env/packages/__init__.py +60 -0
- comfy_env-0.1.17/src/comfy_env/packages/apt.py +36 -0
- comfy_env-0.1.17/src/comfy_env/packages/cuda_wheels.py +97 -0
- comfy_env-0.1.17/src/comfy_env/packages/node_dependencies.py +77 -0
- comfy_env-0.1.17/src/comfy_env/packages/pixi.py +85 -0
- comfy_env-0.1.17/src/comfy_env/packages/toml_generator.py +88 -0
- comfy_env-0.1.15/PKG-INFO +0 -291
- comfy_env-0.1.15/README.md +0 -262
- comfy_env-0.1.15/src/comfy_env/__init__.py +0 -111
- comfy_env-0.1.15/src/comfy_env/cache.py +0 -203
- comfy_env-0.1.15/src/comfy_env/cli.py +0 -430
- comfy_env-0.1.15/src/comfy_env/config/__init__.py +0 -17
- comfy_env-0.1.15/src/comfy_env/config/parser.py +0 -114
- comfy_env-0.1.15/src/comfy_env/install.py +0 -451
- comfy_env-0.1.15/src/comfy_env/isolation/__init__.py +0 -10
- comfy_env-0.1.15/src/comfy_env/isolation/wrap.py +0 -616
- comfy_env-0.1.15/src/comfy_env/nodes.py +0 -187
- comfy_env-0.1.15/src/comfy_env/pixi/__init__.py +0 -48
- comfy_env-0.1.15/src/comfy_env/pixi/core.py +0 -587
- comfy_env-0.1.15/src/comfy_env/pixi/cuda_detection.py +0 -303
- comfy_env-0.1.15/src/comfy_env/pixi/platform/__init__.py +0 -21
- comfy_env-0.1.15/src/comfy_env/pixi/platform/base.py +0 -96
- comfy_env-0.1.15/src/comfy_env/pixi/platform/darwin.py +0 -53
- comfy_env-0.1.15/src/comfy_env/pixi/platform/linux.py +0 -68
- comfy_env-0.1.15/src/comfy_env/pixi/platform/windows.py +0 -284
- comfy_env-0.1.15/src/comfy_env/pixi/resolver.py +0 -198
- comfy_env-0.1.15/src/comfy_env/prestartup.py +0 -208
- comfy_env-0.1.15/src/comfy_env/workers/__init__.py +0 -38
- comfy_env-0.1.15/src/comfy_env/workers/tensor_utils.py +0 -188
- {comfy_env-0.1.15 → comfy_env-0.1.17}/.github/workflows/ci.yml +0 -0
- {comfy_env-0.1.15 → comfy_env-0.1.17}/.github/workflows/publish.yml +0 -0
- {comfy_env-0.1.15 → comfy_env-0.1.17}/.gitignore +0 -0
- {comfy_env-0.1.15 → comfy_env-0.1.17}/LICENSE +0 -0
- {comfy_env-0.1.15/src/comfy_env → comfy_env-0.1.17/src/comfy_env/isolation}/workers/base.py +0 -0
- {comfy_env-0.1.15 → comfy_env-0.1.17}/src/comfy_env/templates/comfy-env-instructions.txt +0 -0
- {comfy_env-0.1.15 → comfy_env-0.1.17}/src/comfy_env/templates/comfy-env.toml +0 -0
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: comfy-env
|
|
3
|
+
Version: 0.1.17
|
|
4
|
+
Summary: Environment management for ComfyUI custom nodes - CUDA wheel resolution and process isolation
|
|
5
|
+
Project-URL: Homepage, https://github.com/PozzettiAndrea/comfy-env
|
|
6
|
+
Project-URL: Repository, https://github.com/PozzettiAndrea/comfy-env
|
|
7
|
+
Project-URL: Issues, https://github.com/PozzettiAndrea/comfy-env/issues
|
|
8
|
+
Author: Andrea Pozzetti
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: comfyui,cuda,environment,isolation,process,venv,wheels
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Requires-Python: >=3.10
|
|
20
|
+
Requires-Dist: pip>=21.0
|
|
21
|
+
Requires-Dist: tomli-w>=1.0.0
|
|
22
|
+
Requires-Dist: tomli>=2.0.0
|
|
23
|
+
Requires-Dist: uv>=0.4.0
|
|
24
|
+
Provides-Extra: dev
|
|
25
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
26
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
27
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
28
|
+
Description-Content-Type: text/markdown
|
|
29
|
+
|
|
30
|
+
# comfy-env
|
|
31
|
+
|
|
32
|
+
Environment management for ComfyUI custom nodes.
|
|
33
|
+
|
|
34
|
+
## Quick Start
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pip install comfy-env
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
**1. Create `comfy-env-root.toml` in your node directory:**
|
|
41
|
+
|
|
42
|
+
```toml
|
|
43
|
+
[cuda]
|
|
44
|
+
packages = ["nvdiffrast", "pytorch3d"]
|
|
45
|
+
|
|
46
|
+
[apt]
|
|
47
|
+
packages = ["libgl1-mesa-glx"]
|
|
48
|
+
|
|
49
|
+
[node_reqs]
|
|
50
|
+
ComfyUI_essentials = "cubiq/ComfyUI_essentials"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
PyPI deps go in `requirements.txt` (standard ComfyUI pattern).
|
|
54
|
+
|
|
55
|
+
**2. In `install.py`:**
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from comfy_env import install
|
|
59
|
+
install()
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
**3. In `prestartup_script.py`:**
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from comfy_env import setup_env
|
|
66
|
+
setup_env()
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Two Config Files
|
|
72
|
+
|
|
73
|
+
| File | Purpose |
|
|
74
|
+
|------|---------|
|
|
75
|
+
| `comfy-env-root.toml` | Main node config (root level) |
|
|
76
|
+
| `comfy-env.toml` | Isolated subfolder config |
|
|
77
|
+
|
|
78
|
+
### comfy-env-root.toml (main node)
|
|
79
|
+
|
|
80
|
+
```toml
|
|
81
|
+
[cuda]
|
|
82
|
+
packages = ["nvdiffrast", "pytorch3d"]
|
|
83
|
+
|
|
84
|
+
[apt]
|
|
85
|
+
packages = ["libgl1-mesa-glx"]
|
|
86
|
+
|
|
87
|
+
[dependencies]
|
|
88
|
+
cgal = "*"
|
|
89
|
+
|
|
90
|
+
[env_vars]
|
|
91
|
+
KMP_DUPLICATE_LIB_OK = "TRUE"
|
|
92
|
+
|
|
93
|
+
[node_reqs]
|
|
94
|
+
ComfyUI_essentials = "cubiq/ComfyUI_essentials"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
PyPI deps → `requirements.txt`
|
|
98
|
+
|
|
99
|
+
### comfy-env.toml (isolated folder)
|
|
100
|
+
|
|
101
|
+
```toml
|
|
102
|
+
python = "3.11"
|
|
103
|
+
|
|
104
|
+
[dependencies]
|
|
105
|
+
cgal = "*"
|
|
106
|
+
|
|
107
|
+
[pypi-dependencies]
|
|
108
|
+
trimesh = { version = "*", extras = ["easy"] }
|
|
109
|
+
|
|
110
|
+
[env_vars]
|
|
111
|
+
SOME_VAR = "value"
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### What goes where?
|
|
115
|
+
|
|
116
|
+
| Section | Root | Isolated |
|
|
117
|
+
|---------|------|----------|
|
|
118
|
+
| `[cuda]` | ✓ | ✓ |
|
|
119
|
+
| `[apt]` | ✓ | ✓ |
|
|
120
|
+
| `[dependencies]` | ✓ | ✓ |
|
|
121
|
+
| `[env_vars]` | ✓ | ✓ |
|
|
122
|
+
| `[node_reqs]` | ✓ | ✗ |
|
|
123
|
+
| `python = "X.Y"` | ✗ | ✓ |
|
|
124
|
+
| `[pypi-dependencies]` | ✗ | ✓ |
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## Process Isolation
|
|
129
|
+
|
|
130
|
+
For nodes with conflicting dependencies:
|
|
131
|
+
|
|
132
|
+
```python
|
|
133
|
+
# In nodes/__init__.py
|
|
134
|
+
from pathlib import Path
|
|
135
|
+
from comfy_env import wrap_isolated_nodes
|
|
136
|
+
|
|
137
|
+
from .cgal import NODE_CLASS_MAPPINGS as cgal_mappings
|
|
138
|
+
|
|
139
|
+
NODE_CLASS_MAPPINGS = wrap_isolated_nodes(
|
|
140
|
+
cgal_mappings,
|
|
141
|
+
Path(__file__).parent / "cgal" # Has comfy-env.toml
|
|
142
|
+
)
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
Each wrapped node runs in a subprocess with its own Python environment.
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## CLI
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
comfy-env init # Create comfy-env-root.toml
|
|
153
|
+
comfy-env init --isolated # Create comfy-env.toml (for subfolders)
|
|
154
|
+
comfy-env install # Install dependencies
|
|
155
|
+
comfy-env install --dry-run # Preview
|
|
156
|
+
comfy-env info # Show runtime info
|
|
157
|
+
comfy-env doctor # Verify packages
|
|
158
|
+
comfy-env apt-install # Install system packages
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## API
|
|
164
|
+
|
|
165
|
+
### install()
|
|
166
|
+
|
|
167
|
+
```python
|
|
168
|
+
from comfy_env import install
|
|
169
|
+
install()
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### setup_env()
|
|
173
|
+
|
|
174
|
+
```python
|
|
175
|
+
from comfy_env import setup_env
|
|
176
|
+
setup_env() # Call in prestartup_script.py
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### wrap_isolated_nodes()
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
from comfy_env import wrap_isolated_nodes
|
|
183
|
+
wrapped = wrap_isolated_nodes(NODE_CLASS_MAPPINGS, node_dir)
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Detection
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
from comfy_env import RuntimeEnv, detect_cuda_version, detect_gpu
|
|
190
|
+
|
|
191
|
+
env = RuntimeEnv.detect()
|
|
192
|
+
print(env) # Python 3.11, CUDA 12.8, PyTorch 2.8.0, GPU: RTX 4090
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
## Example
|
|
198
|
+
|
|
199
|
+
See [ComfyUI-GeometryPack](https://github.com/PozzettiAndrea/ComfyUI-GeometryPack):
|
|
200
|
+
|
|
201
|
+
- Multiple isolated environments (CGAL, Blender, GPU)
|
|
202
|
+
- Per-subdirectory `comfy-env.toml`
|
|
203
|
+
- Different Python versions
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## Why?
|
|
208
|
+
|
|
209
|
+
**Why isolation?** ComfyUI nodes share one Python. Conflicts happen when:
|
|
210
|
+
- Node A needs torch 2.4, Node B needs torch 2.8
|
|
211
|
+
- Two packages bundle incompatible libomp
|
|
212
|
+
- Blender API requires Python 3.11
|
|
213
|
+
|
|
214
|
+
**Why CUDA wheels?** Installing nvdiffrast normally needs CUDA toolkit + C++ compiler + 30 min compilation. [cuda-wheels](https://pozzettiandrea.github.io/cuda-wheels/) provides pre-built wheels.
|
|
215
|
+
|
|
216
|
+
**How envs work:**
|
|
217
|
+
- Central cache: `~/.comfy-env/envs/`
|
|
218
|
+
- Marker files link nodes → cached envs
|
|
219
|
+
- Config hash in name → changes create new envs
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## License
|
|
224
|
+
|
|
225
|
+
MIT
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# comfy-env
|
|
2
|
+
|
|
3
|
+
Environment management for ComfyUI custom nodes.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install comfy-env
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
**1. Create `comfy-env-root.toml` in your node directory:**
|
|
12
|
+
|
|
13
|
+
```toml
|
|
14
|
+
[cuda]
|
|
15
|
+
packages = ["nvdiffrast", "pytorch3d"]
|
|
16
|
+
|
|
17
|
+
[apt]
|
|
18
|
+
packages = ["libgl1-mesa-glx"]
|
|
19
|
+
|
|
20
|
+
[node_reqs]
|
|
21
|
+
ComfyUI_essentials = "cubiq/ComfyUI_essentials"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
PyPI deps go in `requirements.txt` (standard ComfyUI pattern).
|
|
25
|
+
|
|
26
|
+
**2. In `install.py`:**
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from comfy_env import install
|
|
30
|
+
install()
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**3. In `prestartup_script.py`:**
|
|
34
|
+
|
|
35
|
+
```python
|
|
36
|
+
from comfy_env import setup_env
|
|
37
|
+
setup_env()
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## Two Config Files
|
|
43
|
+
|
|
44
|
+
| File | Purpose |
|
|
45
|
+
|------|---------|
|
|
46
|
+
| `comfy-env-root.toml` | Main node config (root level) |
|
|
47
|
+
| `comfy-env.toml` | Isolated subfolder config |
|
|
48
|
+
|
|
49
|
+
### comfy-env-root.toml (main node)
|
|
50
|
+
|
|
51
|
+
```toml
|
|
52
|
+
[cuda]
|
|
53
|
+
packages = ["nvdiffrast", "pytorch3d"]
|
|
54
|
+
|
|
55
|
+
[apt]
|
|
56
|
+
packages = ["libgl1-mesa-glx"]
|
|
57
|
+
|
|
58
|
+
[dependencies]
|
|
59
|
+
cgal = "*"
|
|
60
|
+
|
|
61
|
+
[env_vars]
|
|
62
|
+
KMP_DUPLICATE_LIB_OK = "TRUE"
|
|
63
|
+
|
|
64
|
+
[node_reqs]
|
|
65
|
+
ComfyUI_essentials = "cubiq/ComfyUI_essentials"
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
PyPI deps → `requirements.txt`
|
|
69
|
+
|
|
70
|
+
### comfy-env.toml (isolated folder)
|
|
71
|
+
|
|
72
|
+
```toml
|
|
73
|
+
python = "3.11"
|
|
74
|
+
|
|
75
|
+
[dependencies]
|
|
76
|
+
cgal = "*"
|
|
77
|
+
|
|
78
|
+
[pypi-dependencies]
|
|
79
|
+
trimesh = { version = "*", extras = ["easy"] }
|
|
80
|
+
|
|
81
|
+
[env_vars]
|
|
82
|
+
SOME_VAR = "value"
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### What goes where?
|
|
86
|
+
|
|
87
|
+
| Section | Root | Isolated |
|
|
88
|
+
|---------|------|----------|
|
|
89
|
+
| `[cuda]` | ✓ | ✓ |
|
|
90
|
+
| `[apt]` | ✓ | ✓ |
|
|
91
|
+
| `[dependencies]` | ✓ | ✓ |
|
|
92
|
+
| `[env_vars]` | ✓ | ✓ |
|
|
93
|
+
| `[node_reqs]` | ✓ | ✗ |
|
|
94
|
+
| `python = "X.Y"` | ✗ | ✓ |
|
|
95
|
+
| `[pypi-dependencies]` | ✗ | ✓ |
|
|
96
|
+
|
|
97
|
+
---
|
|
98
|
+
|
|
99
|
+
## Process Isolation
|
|
100
|
+
|
|
101
|
+
For nodes with conflicting dependencies:
|
|
102
|
+
|
|
103
|
+
```python
|
|
104
|
+
# In nodes/__init__.py
|
|
105
|
+
from pathlib import Path
|
|
106
|
+
from comfy_env import wrap_isolated_nodes
|
|
107
|
+
|
|
108
|
+
from .cgal import NODE_CLASS_MAPPINGS as cgal_mappings
|
|
109
|
+
|
|
110
|
+
NODE_CLASS_MAPPINGS = wrap_isolated_nodes(
|
|
111
|
+
cgal_mappings,
|
|
112
|
+
Path(__file__).parent / "cgal" # Has comfy-env.toml
|
|
113
|
+
)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
Each wrapped node runs in a subprocess with its own Python environment.
|
|
117
|
+
|
|
118
|
+
---
|
|
119
|
+
|
|
120
|
+
## CLI
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
comfy-env init # Create comfy-env-root.toml
|
|
124
|
+
comfy-env init --isolated # Create comfy-env.toml (for subfolders)
|
|
125
|
+
comfy-env install # Install dependencies
|
|
126
|
+
comfy-env install --dry-run # Preview
|
|
127
|
+
comfy-env info # Show runtime info
|
|
128
|
+
comfy-env doctor # Verify packages
|
|
129
|
+
comfy-env apt-install # Install system packages
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## API
|
|
135
|
+
|
|
136
|
+
### install()
|
|
137
|
+
|
|
138
|
+
```python
|
|
139
|
+
from comfy_env import install
|
|
140
|
+
install()
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### setup_env()
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from comfy_env import setup_env
|
|
147
|
+
setup_env() # Call in prestartup_script.py
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
### wrap_isolated_nodes()
|
|
151
|
+
|
|
152
|
+
```python
|
|
153
|
+
from comfy_env import wrap_isolated_nodes
|
|
154
|
+
wrapped = wrap_isolated_nodes(NODE_CLASS_MAPPINGS, node_dir)
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Detection
|
|
158
|
+
|
|
159
|
+
```python
|
|
160
|
+
from comfy_env import RuntimeEnv, detect_cuda_version, detect_gpu
|
|
161
|
+
|
|
162
|
+
env = RuntimeEnv.detect()
|
|
163
|
+
print(env) # Python 3.11, CUDA 12.8, PyTorch 2.8.0, GPU: RTX 4090
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Example
|
|
169
|
+
|
|
170
|
+
See [ComfyUI-GeometryPack](https://github.com/PozzettiAndrea/ComfyUI-GeometryPack):
|
|
171
|
+
|
|
172
|
+
- Multiple isolated environments (CGAL, Blender, GPU)
|
|
173
|
+
- Per-subdirectory `comfy-env.toml`
|
|
174
|
+
- Different Python versions
|
|
175
|
+
|
|
176
|
+
---
|
|
177
|
+
|
|
178
|
+
## Why?
|
|
179
|
+
|
|
180
|
+
**Why isolation?** ComfyUI nodes share one Python. Conflicts happen when:
|
|
181
|
+
- Node A needs torch 2.4, Node B needs torch 2.8
|
|
182
|
+
- Two packages bundle incompatible libomp
|
|
183
|
+
- Blender API requires Python 3.11
|
|
184
|
+
|
|
185
|
+
**Why CUDA wheels?** Installing nvdiffrast normally needs CUDA toolkit + C++ compiler + 30 min compilation. [cuda-wheels](https://pozzettiandrea.github.io/cuda-wheels/) provides pre-built wheels.
|
|
186
|
+
|
|
187
|
+
**How envs work:**
|
|
188
|
+
- Central cache: `~/.comfy-env/envs/`
|
|
189
|
+
- Marker files link nodes → cached envs
|
|
190
|
+
- Config hash in name → changes create new envs
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## License
|
|
195
|
+
|
|
196
|
+
MIT
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
"""
|
|
2
|
+
comfy-env - Environment management for ComfyUI custom nodes.
|
|
3
|
+
|
|
4
|
+
Features:
|
|
5
|
+
- CUDA wheel resolution (pre-built wheels without compilation)
|
|
6
|
+
- Process isolation (run nodes in separate Python environments)
|
|
7
|
+
- Central environment cache (~/.comfy-env/envs/)
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
from importlib.metadata import version, PackageNotFoundError
|
|
11
|
+
|
|
12
|
+
try:
|
|
13
|
+
__version__ = version("comfy-env")
|
|
14
|
+
except PackageNotFoundError:
|
|
15
|
+
__version__ = "0.0.0-dev"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
# =============================================================================
|
|
19
|
+
# Primary API (what most users need)
|
|
20
|
+
# =============================================================================
|
|
21
|
+
|
|
22
|
+
# Install API
|
|
23
|
+
from .install import install, verify_installation, USE_COMFY_ENV_VAR
|
|
24
|
+
|
|
25
|
+
# Prestartup helpers
|
|
26
|
+
from .environment.setup import setup_env
|
|
27
|
+
from .environment.paths import copy_files
|
|
28
|
+
|
|
29
|
+
# Isolation
|
|
30
|
+
from .isolation import wrap_isolated_nodes, wrap_nodes
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# =============================================================================
|
|
34
|
+
# Config Layer
|
|
35
|
+
# =============================================================================
|
|
36
|
+
|
|
37
|
+
from .config import (
|
|
38
|
+
ComfyEnvConfig,
|
|
39
|
+
NodeDependency,
|
|
40
|
+
NodeReq,
|
|
41
|
+
load_config,
|
|
42
|
+
discover_config,
|
|
43
|
+
CONFIG_FILE_NAME,
|
|
44
|
+
ROOT_CONFIG_FILE_NAME,
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
# =============================================================================
|
|
49
|
+
# Detection Layer
|
|
50
|
+
# =============================================================================
|
|
51
|
+
|
|
52
|
+
from .detection import (
|
|
53
|
+
# CUDA detection
|
|
54
|
+
detect_cuda_version,
|
|
55
|
+
detect_cuda_environment,
|
|
56
|
+
get_recommended_cuda_version,
|
|
57
|
+
# GPU detection
|
|
58
|
+
GPUInfo,
|
|
59
|
+
CUDAEnvironment,
|
|
60
|
+
detect_gpu,
|
|
61
|
+
get_gpu_summary,
|
|
62
|
+
# Platform detection
|
|
63
|
+
detect_platform,
|
|
64
|
+
get_platform_tag,
|
|
65
|
+
# Runtime detection
|
|
66
|
+
RuntimeEnv,
|
|
67
|
+
detect_runtime,
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
# =============================================================================
|
|
72
|
+
# Packages Layer
|
|
73
|
+
# =============================================================================
|
|
74
|
+
|
|
75
|
+
from .packages import (
|
|
76
|
+
# Pixi
|
|
77
|
+
ensure_pixi,
|
|
78
|
+
get_pixi_path,
|
|
79
|
+
get_pixi_python,
|
|
80
|
+
pixi_run,
|
|
81
|
+
pixi_clean,
|
|
82
|
+
# CUDA wheels
|
|
83
|
+
CUDA_WHEELS_INDEX,
|
|
84
|
+
get_wheel_url,
|
|
85
|
+
get_cuda_torch_mapping,
|
|
86
|
+
)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
# =============================================================================
|
|
90
|
+
# Environment Layer
|
|
91
|
+
# =============================================================================
|
|
92
|
+
|
|
93
|
+
from .environment import (
|
|
94
|
+
# Cache management
|
|
95
|
+
get_cache_dir,
|
|
96
|
+
cleanup_orphaned_envs,
|
|
97
|
+
resolve_env_path,
|
|
98
|
+
CACHE_DIR,
|
|
99
|
+
MARKER_FILE,
|
|
100
|
+
)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
# =============================================================================
|
|
104
|
+
# Isolation Layer
|
|
105
|
+
# =============================================================================
|
|
106
|
+
|
|
107
|
+
from .isolation import (
|
|
108
|
+
# Workers
|
|
109
|
+
Worker,
|
|
110
|
+
WorkerError,
|
|
111
|
+
MPWorker,
|
|
112
|
+
SubprocessWorker,
|
|
113
|
+
# Tensor utilities
|
|
114
|
+
TensorKeeper,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
# =============================================================================
|
|
119
|
+
# Exports
|
|
120
|
+
# =============================================================================
|
|
121
|
+
|
|
122
|
+
__all__ = [
|
|
123
|
+
# Install API
|
|
124
|
+
"install",
|
|
125
|
+
"verify_installation",
|
|
126
|
+
"USE_COMFY_ENV_VAR",
|
|
127
|
+
# Prestartup
|
|
128
|
+
"setup_env",
|
|
129
|
+
"copy_files",
|
|
130
|
+
# Isolation
|
|
131
|
+
"wrap_isolated_nodes",
|
|
132
|
+
"wrap_nodes",
|
|
133
|
+
# Config
|
|
134
|
+
"ComfyEnvConfig",
|
|
135
|
+
"NodeDependency",
|
|
136
|
+
"NodeReq",
|
|
137
|
+
"load_config",
|
|
138
|
+
"discover_config",
|
|
139
|
+
"CONFIG_FILE_NAME",
|
|
140
|
+
"ROOT_CONFIG_FILE_NAME",
|
|
141
|
+
# Detection
|
|
142
|
+
"detect_cuda_version",
|
|
143
|
+
"detect_cuda_environment",
|
|
144
|
+
"get_recommended_cuda_version",
|
|
145
|
+
"GPUInfo",
|
|
146
|
+
"CUDAEnvironment",
|
|
147
|
+
"detect_gpu",
|
|
148
|
+
"get_gpu_summary",
|
|
149
|
+
"detect_platform",
|
|
150
|
+
"get_platform_tag",
|
|
151
|
+
"RuntimeEnv",
|
|
152
|
+
"detect_runtime",
|
|
153
|
+
# Packages
|
|
154
|
+
"ensure_pixi",
|
|
155
|
+
"get_pixi_path",
|
|
156
|
+
"get_pixi_python",
|
|
157
|
+
"pixi_run",
|
|
158
|
+
"pixi_clean",
|
|
159
|
+
"CUDA_WHEELS_INDEX",
|
|
160
|
+
"get_wheel_url",
|
|
161
|
+
"get_cuda_torch_mapping",
|
|
162
|
+
# Environment
|
|
163
|
+
"get_cache_dir",
|
|
164
|
+
"cleanup_orphaned_envs",
|
|
165
|
+
"resolve_env_path",
|
|
166
|
+
"CACHE_DIR",
|
|
167
|
+
"MARKER_FILE",
|
|
168
|
+
# Workers
|
|
169
|
+
"Worker",
|
|
170
|
+
"WorkerError",
|
|
171
|
+
"MPWorker",
|
|
172
|
+
"SubprocessWorker",
|
|
173
|
+
"TensorKeeper",
|
|
174
|
+
]
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
# =============================================================================
|
|
178
|
+
# Startup cleanup
|
|
179
|
+
# =============================================================================
|
|
180
|
+
|
|
181
|
+
def _run_startup_cleanup():
|
|
182
|
+
"""Clean orphaned envs on startup."""
|
|
183
|
+
try:
|
|
184
|
+
cleanup_orphaned_envs(log=lambda x: None) # Silent
|
|
185
|
+
except Exception:
|
|
186
|
+
pass # Never fail startup due to cleanup
|
|
187
|
+
|
|
188
|
+
_run_startup_cleanup()
|