comfy-env 0.0.30__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.0.30/.github/workflows/publish.yml +67 -0
- comfy_env-0.0.30/.gitignore +32 -0
- comfy_env-0.0.30/LICENSE +21 -0
- comfy_env-0.0.30/PKG-INFO +229 -0
- comfy_env-0.0.30/README.md +201 -0
- comfy_env-0.0.30/pyproject.toml +50 -0
- comfy_env-0.0.30/src/comfy_env/__init__.py +151 -0
- comfy_env-0.0.30/src/comfy_env/cli.py +486 -0
- comfy_env-0.0.30/src/comfy_env/decorator.py +446 -0
- comfy_env-0.0.30/src/comfy_env/env/__init__.py +47 -0
- comfy_env-0.0.30/src/comfy_env/env/config.py +195 -0
- comfy_env-0.0.30/src/comfy_env/env/config_file.py +704 -0
- comfy_env-0.0.30/src/comfy_env/env/cuda_gpu_detection.py +303 -0
- comfy_env-0.0.30/src/comfy_env/env/manager.py +674 -0
- comfy_env-0.0.30/src/comfy_env/env/platform/__init__.py +21 -0
- comfy_env-0.0.30/src/comfy_env/env/platform/base.py +96 -0
- comfy_env-0.0.30/src/comfy_env/env/platform/darwin.py +53 -0
- comfy_env-0.0.30/src/comfy_env/env/platform/linux.py +68 -0
- comfy_env-0.0.30/src/comfy_env/env/platform/windows.py +284 -0
- comfy_env-0.0.30/src/comfy_env/env/security.py +267 -0
- comfy_env-0.0.30/src/comfy_env/errors.py +293 -0
- comfy_env-0.0.30/src/comfy_env/install.py +782 -0
- comfy_env-0.0.30/src/comfy_env/ipc/__init__.py +55 -0
- comfy_env-0.0.30/src/comfy_env/ipc/bridge.py +476 -0
- comfy_env-0.0.30/src/comfy_env/ipc/protocol.py +265 -0
- comfy_env-0.0.30/src/comfy_env/ipc/tensor.py +371 -0
- comfy_env-0.0.30/src/comfy_env/ipc/torch_bridge.py +401 -0
- comfy_env-0.0.30/src/comfy_env/ipc/transport.py +318 -0
- comfy_env-0.0.30/src/comfy_env/ipc/worker.py +221 -0
- comfy_env-0.0.30/src/comfy_env/nodes.py +154 -0
- comfy_env-0.0.30/src/comfy_env/pixi.py +431 -0
- comfy_env-0.0.30/src/comfy_env/registry.py +91 -0
- comfy_env-0.0.30/src/comfy_env/resolver.py +388 -0
- comfy_env-0.0.30/src/comfy_env/stubs/__init__.py +1 -0
- comfy_env-0.0.30/src/comfy_env/stubs/folder_paths.py +61 -0
- comfy_env-0.0.30/src/comfy_env/wheel_sources.yml +162 -0
- comfy_env-0.0.30/src/comfy_env/workers/__init__.py +49 -0
- comfy_env-0.0.30/src/comfy_env/workers/base.py +82 -0
- comfy_env-0.0.30/src/comfy_env/workers/pool.py +241 -0
- comfy_env-0.0.30/src/comfy_env/workers/tensor_utils.py +188 -0
- comfy_env-0.0.30/src/comfy_env/workers/torch_mp.py +592 -0
- comfy_env-0.0.30/src/comfy_env/workers/venv.py +903 -0
- comfy_env-0.0.30/untitled.txt +0 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
name: Bump Version & Publish
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
workflow_dispatch:
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
bump-and-publish:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
environment: pypi
|
|
13
|
+
permissions:
|
|
14
|
+
contents: write
|
|
15
|
+
id-token: write
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
with:
|
|
19
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
20
|
+
|
|
21
|
+
- name: Setup Python
|
|
22
|
+
uses: actions/setup-python@v5
|
|
23
|
+
with:
|
|
24
|
+
python-version: '3.11'
|
|
25
|
+
|
|
26
|
+
- name: Get current version
|
|
27
|
+
id: get_version
|
|
28
|
+
run: |
|
|
29
|
+
current=$(grep '^version = ' pyproject.toml | sed 's/version = "\(.*\)"/\1/' | tr -d '\r')
|
|
30
|
+
echo "current=$current" >> $GITHUB_OUTPUT
|
|
31
|
+
|
|
32
|
+
- name: Bump patch version
|
|
33
|
+
id: bump_version
|
|
34
|
+
run: |
|
|
35
|
+
current="${{ steps.get_version.outputs.current }}"
|
|
36
|
+
IFS='.' read -r major minor patch <<< "$current"
|
|
37
|
+
new_patch=$((patch + 1))
|
|
38
|
+
new_version="${major}.${minor}.${new_patch}"
|
|
39
|
+
sed -i "s/^version = \".*\"/version = \"${new_version}\"/" pyproject.toml
|
|
40
|
+
echo "new_version=$new_version" >> $GITHUB_OUTPUT
|
|
41
|
+
echo "Bumped version: $current -> $new_version"
|
|
42
|
+
|
|
43
|
+
- name: Commit version bump
|
|
44
|
+
run: |
|
|
45
|
+
git config user.name "github-actions[bot]"
|
|
46
|
+
git config user.email "github-actions[bot]@users.noreply.github.com"
|
|
47
|
+
git add pyproject.toml
|
|
48
|
+
git commit -m "Bump version to ${{ steps.bump_version.outputs.new_version }} [skip ci]"
|
|
49
|
+
git tag "v${{ steps.bump_version.outputs.new_version }}"
|
|
50
|
+
git push origin main --tags
|
|
51
|
+
|
|
52
|
+
- name: Install build tools
|
|
53
|
+
run: pip install build
|
|
54
|
+
|
|
55
|
+
- name: Build package
|
|
56
|
+
run: python -m build
|
|
57
|
+
|
|
58
|
+
- name: Create GitHub Release
|
|
59
|
+
uses: softprops/action-gh-release@v1
|
|
60
|
+
with:
|
|
61
|
+
tag_name: v${{ steps.bump_version.outputs.new_version }}
|
|
62
|
+
name: v${{ steps.bump_version.outputs.new_version }}
|
|
63
|
+
generate_release_notes: true
|
|
64
|
+
files: dist/*
|
|
65
|
+
|
|
66
|
+
- name: Publish to PyPI
|
|
67
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.so
|
|
5
|
+
*.egg
|
|
6
|
+
*.egg-info/
|
|
7
|
+
dist/
|
|
8
|
+
build/
|
|
9
|
+
.eggs/
|
|
10
|
+
|
|
11
|
+
# Virtual environments
|
|
12
|
+
.venv/
|
|
13
|
+
venv/
|
|
14
|
+
ENV/
|
|
15
|
+
|
|
16
|
+
# IDE
|
|
17
|
+
.idea/
|
|
18
|
+
.vscode/
|
|
19
|
+
*.swp
|
|
20
|
+
*.swo
|
|
21
|
+
|
|
22
|
+
# Jupyter
|
|
23
|
+
.ipynb_checkpoints/
|
|
24
|
+
|
|
25
|
+
# Testing
|
|
26
|
+
.pytest_cache/
|
|
27
|
+
.coverage
|
|
28
|
+
htmlcov/
|
|
29
|
+
|
|
30
|
+
# OS
|
|
31
|
+
.DS_Store
|
|
32
|
+
Thumbs.db
|
comfy_env-0.0.30/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Andrea Pozzetti
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: comfy-env
|
|
3
|
+
Version: 0.0.30
|
|
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: pyyaml>=6.0
|
|
21
|
+
Requires-Dist: tomli>=2.0.0; python_version < '3.11'
|
|
22
|
+
Requires-Dist: uv>=0.4.0
|
|
23
|
+
Provides-Extra: dev
|
|
24
|
+
Requires-Dist: mypy; extra == 'dev'
|
|
25
|
+
Requires-Dist: pytest; extra == 'dev'
|
|
26
|
+
Requires-Dist: ruff; extra == 'dev'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# comfy-env
|
|
30
|
+
|
|
31
|
+
Environment management for ComfyUI custom nodes. Provides:
|
|
32
|
+
|
|
33
|
+
1. **CUDA Wheel Resolution** - Install pre-built CUDA wheels (nvdiffrast, pytorch3d) without compilation
|
|
34
|
+
2. **Process Isolation** - Run nodes in separate Python environments with their own dependencies
|
|
35
|
+
|
|
36
|
+
## Why?
|
|
37
|
+
|
|
38
|
+
ComfyUI custom nodes face two challenges:
|
|
39
|
+
|
|
40
|
+
**Type 1: Dependency Conflicts**
|
|
41
|
+
- Node A needs `torch==2.1.0` with CUDA 11.8
|
|
42
|
+
- Node B needs `torch==2.8.0` with CUDA 12.8
|
|
43
|
+
|
|
44
|
+
**Type 2: CUDA Package Installation**
|
|
45
|
+
- Users don't have compilers installed
|
|
46
|
+
- Building from source takes forever
|
|
47
|
+
- pip install fails with cryptic errors
|
|
48
|
+
|
|
49
|
+
This package solves both problems.
|
|
50
|
+
|
|
51
|
+
## Installation
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
pip install comfy-env
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Requires [uv](https://github.com/astral-sh/uv) for fast environment creation:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Quick Start
|
|
64
|
+
|
|
65
|
+
### In-Place Installation (Type 2 - CUDA Wheels)
|
|
66
|
+
|
|
67
|
+
Create a `comfy-env.toml` in your node directory:
|
|
68
|
+
|
|
69
|
+
```toml
|
|
70
|
+
[env]
|
|
71
|
+
name = "my-node"
|
|
72
|
+
python = "3.10"
|
|
73
|
+
cuda = "auto"
|
|
74
|
+
|
|
75
|
+
[packages]
|
|
76
|
+
requirements = ["transformers>=4.56", "pillow"]
|
|
77
|
+
no_deps = ["nvdiffrast==0.4.0", "pytorch3d>=0.7.8"]
|
|
78
|
+
|
|
79
|
+
[sources]
|
|
80
|
+
wheel_sources = ["https://github.com/PozzettiAndrea/nvdiffrast-full-wheels/releases/download/"]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Then in your `__init__.py`:
|
|
84
|
+
|
|
85
|
+
```python
|
|
86
|
+
from comfy_env import install
|
|
87
|
+
|
|
88
|
+
# Install CUDA wheels into current environment
|
|
89
|
+
install()
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Process Isolation (Type 1 - Separate Venv)
|
|
93
|
+
|
|
94
|
+
For nodes that need completely separate dependencies:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
from comfy_env import isolated
|
|
98
|
+
|
|
99
|
+
@isolated(env="my-node")
|
|
100
|
+
class MyNode:
|
|
101
|
+
FUNCTION = "process"
|
|
102
|
+
RETURN_TYPES = ("IMAGE",)
|
|
103
|
+
|
|
104
|
+
def process(self, image):
|
|
105
|
+
# Runs in isolated subprocess with its own venv
|
|
106
|
+
import conflicting_package
|
|
107
|
+
return (result,)
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## CLI
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Show detected environment
|
|
114
|
+
comfy-env info
|
|
115
|
+
|
|
116
|
+
# Install from config
|
|
117
|
+
comfy-env install
|
|
118
|
+
|
|
119
|
+
# Dry run (show what would be installed)
|
|
120
|
+
comfy-env install --dry-run
|
|
121
|
+
|
|
122
|
+
# Resolve wheel URLs without installing
|
|
123
|
+
comfy-env resolve nvdiffrast==0.4.0
|
|
124
|
+
|
|
125
|
+
# Verify installation
|
|
126
|
+
comfy-env doctor
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Configurations
|
|
130
|
+
|
|
131
|
+
### comfy-env.toml
|
|
132
|
+
|
|
133
|
+
```toml
|
|
134
|
+
[env]
|
|
135
|
+
name = "my-node" # Unique name for caching
|
|
136
|
+
python = "3.10" # Python version
|
|
137
|
+
cuda = "auto" # "auto", "12.8", "12.4", or null
|
|
138
|
+
|
|
139
|
+
[packages]
|
|
140
|
+
requirements = [ # Regular pip packages
|
|
141
|
+
"transformers>=4.56",
|
|
142
|
+
"pillow",
|
|
143
|
+
]
|
|
144
|
+
no_deps = [ # CUDA packages (installed with --no-deps)
|
|
145
|
+
"nvdiffrast==0.4.0",
|
|
146
|
+
"pytorch3d>=0.7.8",
|
|
147
|
+
]
|
|
148
|
+
|
|
149
|
+
[sources]
|
|
150
|
+
wheel_sources = [ # GitHub releases with pre-built wheels
|
|
151
|
+
"https://github.com/.../releases/download/",
|
|
152
|
+
]
|
|
153
|
+
index_urls = [ # Extra pip index URLs
|
|
154
|
+
"https://pypi.org/simple/",
|
|
155
|
+
]
|
|
156
|
+
|
|
157
|
+
[worker] # For isolation mode
|
|
158
|
+
package = "worker" # worker/__main__.py
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
### Template Variables
|
|
162
|
+
|
|
163
|
+
Wheel URLs support these template variables:
|
|
164
|
+
|
|
165
|
+
| Variable | Example | Description |
|
|
166
|
+
|----------|---------|-------------|
|
|
167
|
+
| `{cuda_version}` | `12.8` | Full CUDA version |
|
|
168
|
+
| `{cuda_short}` | `128` | CUDA without dot |
|
|
169
|
+
| `{torch_version}` | `2.8.0` | PyTorch version |
|
|
170
|
+
| `{torch_mm}` | `28` | PyTorch major.minor |
|
|
171
|
+
| `{py_version}` | `3.10` | Python version |
|
|
172
|
+
| `{py_short}` | `310` | Python without dot |
|
|
173
|
+
| `{platform}` | `linux_x86_64` | Platform tag |
|
|
174
|
+
|
|
175
|
+
## API Reference
|
|
176
|
+
|
|
177
|
+
### install()
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
from comfy_env import install
|
|
181
|
+
|
|
182
|
+
# Auto-discover config
|
|
183
|
+
install()
|
|
184
|
+
|
|
185
|
+
# Explicit config
|
|
186
|
+
install(config="comfy-env.toml")
|
|
187
|
+
|
|
188
|
+
# Isolated mode (creates separate venv)
|
|
189
|
+
install(mode="isolated")
|
|
190
|
+
|
|
191
|
+
# Dry run
|
|
192
|
+
install(dry_run=True)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### WheelResolver
|
|
196
|
+
|
|
197
|
+
```python
|
|
198
|
+
from comfy_env import RuntimeEnv, WheelResolver
|
|
199
|
+
|
|
200
|
+
env = RuntimeEnv.detect()
|
|
201
|
+
resolver = WheelResolver()
|
|
202
|
+
|
|
203
|
+
url = resolver.resolve("nvdiffrast", "0.4.0", env)
|
|
204
|
+
print(url) # https://github.com/.../nvdiffrast-0.4.0+cu128torch28-...whl
|
|
205
|
+
```
|
|
206
|
+
|
|
207
|
+
### Workers (for isolation)
|
|
208
|
+
|
|
209
|
+
```python
|
|
210
|
+
from comfy_env import TorchMPWorker
|
|
211
|
+
|
|
212
|
+
# Same-venv isolation (zero-copy tensors)
|
|
213
|
+
worker = TorchMPWorker()
|
|
214
|
+
result = worker.call(my_function, image=tensor)
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## GPU Detection
|
|
218
|
+
|
|
219
|
+
```python
|
|
220
|
+
from comfy_env import detect_cuda_version, get_gpu_summary
|
|
221
|
+
|
|
222
|
+
cuda = detect_cuda_version() # "12.8", "12.4", or None
|
|
223
|
+
print(get_gpu_summary())
|
|
224
|
+
# GPU 0: NVIDIA GeForce RTX 5090 (sm_120) [Blackwell - CUDA 12.8]
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## License
|
|
228
|
+
|
|
229
|
+
MIT - see LICENSE file.
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# comfy-env
|
|
2
|
+
|
|
3
|
+
Environment management for ComfyUI custom nodes. Provides:
|
|
4
|
+
|
|
5
|
+
1. **CUDA Wheel Resolution** - Install pre-built CUDA wheels (nvdiffrast, pytorch3d) without compilation
|
|
6
|
+
2. **Process Isolation** - Run nodes in separate Python environments with their own dependencies
|
|
7
|
+
|
|
8
|
+
## Why?
|
|
9
|
+
|
|
10
|
+
ComfyUI custom nodes face two challenges:
|
|
11
|
+
|
|
12
|
+
**Type 1: Dependency Conflicts**
|
|
13
|
+
- Node A needs `torch==2.1.0` with CUDA 11.8
|
|
14
|
+
- Node B needs `torch==2.8.0` with CUDA 12.8
|
|
15
|
+
|
|
16
|
+
**Type 2: CUDA Package Installation**
|
|
17
|
+
- Users don't have compilers installed
|
|
18
|
+
- Building from source takes forever
|
|
19
|
+
- pip install fails with cryptic errors
|
|
20
|
+
|
|
21
|
+
This package solves both problems.
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
pip install comfy-env
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Requires [uv](https://github.com/astral-sh/uv) for fast environment creation:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
### In-Place Installation (Type 2 - CUDA Wheels)
|
|
38
|
+
|
|
39
|
+
Create a `comfy-env.toml` in your node directory:
|
|
40
|
+
|
|
41
|
+
```toml
|
|
42
|
+
[env]
|
|
43
|
+
name = "my-node"
|
|
44
|
+
python = "3.10"
|
|
45
|
+
cuda = "auto"
|
|
46
|
+
|
|
47
|
+
[packages]
|
|
48
|
+
requirements = ["transformers>=4.56", "pillow"]
|
|
49
|
+
no_deps = ["nvdiffrast==0.4.0", "pytorch3d>=0.7.8"]
|
|
50
|
+
|
|
51
|
+
[sources]
|
|
52
|
+
wheel_sources = ["https://github.com/PozzettiAndrea/nvdiffrast-full-wheels/releases/download/"]
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Then in your `__init__.py`:
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from comfy_env import install
|
|
59
|
+
|
|
60
|
+
# Install CUDA wheels into current environment
|
|
61
|
+
install()
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Process Isolation (Type 1 - Separate Venv)
|
|
65
|
+
|
|
66
|
+
For nodes that need completely separate dependencies:
|
|
67
|
+
|
|
68
|
+
```python
|
|
69
|
+
from comfy_env import isolated
|
|
70
|
+
|
|
71
|
+
@isolated(env="my-node")
|
|
72
|
+
class MyNode:
|
|
73
|
+
FUNCTION = "process"
|
|
74
|
+
RETURN_TYPES = ("IMAGE",)
|
|
75
|
+
|
|
76
|
+
def process(self, image):
|
|
77
|
+
# Runs in isolated subprocess with its own venv
|
|
78
|
+
import conflicting_package
|
|
79
|
+
return (result,)
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## CLI
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
# Show detected environment
|
|
86
|
+
comfy-env info
|
|
87
|
+
|
|
88
|
+
# Install from config
|
|
89
|
+
comfy-env install
|
|
90
|
+
|
|
91
|
+
# Dry run (show what would be installed)
|
|
92
|
+
comfy-env install --dry-run
|
|
93
|
+
|
|
94
|
+
# Resolve wheel URLs without installing
|
|
95
|
+
comfy-env resolve nvdiffrast==0.4.0
|
|
96
|
+
|
|
97
|
+
# Verify installation
|
|
98
|
+
comfy-env doctor
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
## Configurations
|
|
102
|
+
|
|
103
|
+
### comfy-env.toml
|
|
104
|
+
|
|
105
|
+
```toml
|
|
106
|
+
[env]
|
|
107
|
+
name = "my-node" # Unique name for caching
|
|
108
|
+
python = "3.10" # Python version
|
|
109
|
+
cuda = "auto" # "auto", "12.8", "12.4", or null
|
|
110
|
+
|
|
111
|
+
[packages]
|
|
112
|
+
requirements = [ # Regular pip packages
|
|
113
|
+
"transformers>=4.56",
|
|
114
|
+
"pillow",
|
|
115
|
+
]
|
|
116
|
+
no_deps = [ # CUDA packages (installed with --no-deps)
|
|
117
|
+
"nvdiffrast==0.4.0",
|
|
118
|
+
"pytorch3d>=0.7.8",
|
|
119
|
+
]
|
|
120
|
+
|
|
121
|
+
[sources]
|
|
122
|
+
wheel_sources = [ # GitHub releases with pre-built wheels
|
|
123
|
+
"https://github.com/.../releases/download/",
|
|
124
|
+
]
|
|
125
|
+
index_urls = [ # Extra pip index URLs
|
|
126
|
+
"https://pypi.org/simple/",
|
|
127
|
+
]
|
|
128
|
+
|
|
129
|
+
[worker] # For isolation mode
|
|
130
|
+
package = "worker" # worker/__main__.py
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Template Variables
|
|
134
|
+
|
|
135
|
+
Wheel URLs support these template variables:
|
|
136
|
+
|
|
137
|
+
| Variable | Example | Description |
|
|
138
|
+
|----------|---------|-------------|
|
|
139
|
+
| `{cuda_version}` | `12.8` | Full CUDA version |
|
|
140
|
+
| `{cuda_short}` | `128` | CUDA without dot |
|
|
141
|
+
| `{torch_version}` | `2.8.0` | PyTorch version |
|
|
142
|
+
| `{torch_mm}` | `28` | PyTorch major.minor |
|
|
143
|
+
| `{py_version}` | `3.10` | Python version |
|
|
144
|
+
| `{py_short}` | `310` | Python without dot |
|
|
145
|
+
| `{platform}` | `linux_x86_64` | Platform tag |
|
|
146
|
+
|
|
147
|
+
## API Reference
|
|
148
|
+
|
|
149
|
+
### install()
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
from comfy_env import install
|
|
153
|
+
|
|
154
|
+
# Auto-discover config
|
|
155
|
+
install()
|
|
156
|
+
|
|
157
|
+
# Explicit config
|
|
158
|
+
install(config="comfy-env.toml")
|
|
159
|
+
|
|
160
|
+
# Isolated mode (creates separate venv)
|
|
161
|
+
install(mode="isolated")
|
|
162
|
+
|
|
163
|
+
# Dry run
|
|
164
|
+
install(dry_run=True)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### WheelResolver
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
from comfy_env import RuntimeEnv, WheelResolver
|
|
171
|
+
|
|
172
|
+
env = RuntimeEnv.detect()
|
|
173
|
+
resolver = WheelResolver()
|
|
174
|
+
|
|
175
|
+
url = resolver.resolve("nvdiffrast", "0.4.0", env)
|
|
176
|
+
print(url) # https://github.com/.../nvdiffrast-0.4.0+cu128torch28-...whl
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Workers (for isolation)
|
|
180
|
+
|
|
181
|
+
```python
|
|
182
|
+
from comfy_env import TorchMPWorker
|
|
183
|
+
|
|
184
|
+
# Same-venv isolation (zero-copy tensors)
|
|
185
|
+
worker = TorchMPWorker()
|
|
186
|
+
result = worker.call(my_function, image=tensor)
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
## GPU Detection
|
|
190
|
+
|
|
191
|
+
```python
|
|
192
|
+
from comfy_env import detect_cuda_version, get_gpu_summary
|
|
193
|
+
|
|
194
|
+
cuda = detect_cuda_version() # "12.8", "12.4", or None
|
|
195
|
+
print(get_gpu_summary())
|
|
196
|
+
# GPU 0: NVIDIA GeForce RTX 5090 (sm_120) [Blackwell - CUDA 12.8]
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## License
|
|
200
|
+
|
|
201
|
+
MIT - see LICENSE file.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "comfy-env"
|
|
3
|
+
version = "0.0.30"
|
|
4
|
+
description = "Environment management for ComfyUI custom nodes - CUDA wheel resolution and process isolation"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = {text = "MIT"}
|
|
7
|
+
requires-python = ">=3.10"
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "Andrea Pozzetti"}
|
|
10
|
+
]
|
|
11
|
+
keywords = ["comfyui", "cuda", "wheels", "environment", "isolation", "venv", "process"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 3 - Alpha",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Programming Language :: Python :: 3.10",
|
|
17
|
+
"Programming Language :: Python :: 3.11",
|
|
18
|
+
"Programming Language :: Python :: 3.12",
|
|
19
|
+
"Programming Language :: Python :: 3.13",
|
|
20
|
+
]
|
|
21
|
+
dependencies = [
|
|
22
|
+
"tomli>=2.0.0; python_version < '3.11'", # TOML parsing (built-in tomllib for 3.11+)
|
|
23
|
+
"uv>=0.4.0", # Fast Python package installer and venv creator
|
|
24
|
+
"pyyaml>=6.0", # YAML parsing for wheel_sources.yml
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
dev = ["pytest", "ruff", "mypy"]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
Homepage = "https://github.com/PozzettiAndrea/comfy-env"
|
|
32
|
+
Repository = "https://github.com/PozzettiAndrea/comfy-env"
|
|
33
|
+
Issues = "https://github.com/PozzettiAndrea/comfy-env/issues"
|
|
34
|
+
|
|
35
|
+
[project.scripts]
|
|
36
|
+
comfy-env = "comfy_env.cli:main"
|
|
37
|
+
|
|
38
|
+
[build-system]
|
|
39
|
+
requires = ["hatchling"]
|
|
40
|
+
build-backend = "hatchling.build"
|
|
41
|
+
|
|
42
|
+
[tool.hatch.build.targets.wheel]
|
|
43
|
+
packages = ["src/comfy_env"]
|
|
44
|
+
|
|
45
|
+
[tool.hatch.build.targets.wheel.force-include]
|
|
46
|
+
"src/comfy_env/wheel_sources.yml" = "comfy_env/wheel_sources.yml"
|
|
47
|
+
|
|
48
|
+
[tool.ruff]
|
|
49
|
+
line-length = 100
|
|
50
|
+
target-version = "py310"
|