comfy-env 0.0.48__py3-none-any.whl → 0.0.49__py3-none-any.whl

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/decorator.py CHANGED
@@ -178,7 +178,10 @@ def _get_or_create_worker(config: WorkerConfig, log_fn: Callable):
178
178
  # Same Python - use TorchMPWorker (fast, zero-copy)
179
179
  from .workers import TorchMPWorker
180
180
  log_fn(f"Creating TorchMPWorker (same Python, zero-copy tensors)")
181
- worker = TorchMPWorker(name=config.env_name, sys_path=config.sys_path)
181
+ worker = TorchMPWorker(
182
+ name=config.env_name,
183
+ sys_path=config.sys_path,
184
+ )
182
185
  else:
183
186
  # Different Python - use PersistentVenvWorker
184
187
  from .workers.venv import PersistentVenvWorker
@@ -0,0 +1,82 @@
1
+ comfy-env Setup Instructions
2
+ ============================
3
+
4
+ comfy-env handles CUDA wheel installation and process isolation for ComfyUI
5
+ custom nodes.
6
+
7
+ QUICK START
8
+ -----------
9
+ 1. Install comfy-env:
10
+ pip install comfy-env
11
+
12
+ 2. Initialize config in your node directory:
13
+ comfy-env init
14
+
15
+ 3. Edit comfy-env.toml to add your dependencies
16
+
17
+ 4. Add to your __init__.py (at the top, before other imports):
18
+ from comfy_env import install
19
+ install()
20
+
21
+ 5. Test locally:
22
+ comfy-env install --dry-run # Preview what will be installed
23
+ comfy-env install # Actually install
24
+ comfy-env doctor # Verify all packages work
25
+
26
+
27
+ COMMON USE CASES
28
+ ----------------
29
+
30
+ Case 1: Just need CUDA packages (nvdiffrast, pytorch3d, etc.)
31
+ - Add packages to [cuda] section
32
+ - Call install() in your __init__.py
33
+
34
+ Case 2: Need process isolation (conflicting dependencies)
35
+ - Define an isolated environment section like [myenv]
36
+ - Use @isolated(env="myenv") decorator on your node class
37
+
38
+ Case 3: Need system packages (apt)
39
+ - Add to [system] linux = ["package1", "package2"]
40
+
41
+
42
+ CLI COMMANDS
43
+ ------------
44
+ comfy-env init Create comfy-env.toml template
45
+ comfy-env install Install dependencies from config
46
+ comfy-env install --dry-run Preview without installing
47
+ comfy-env info Show detected environment (Python, CUDA, PyTorch)
48
+ comfy-env resolve PKG Show resolved wheel URL for a package
49
+ comfy-env doctor Verify installation
50
+ comfy-env list-packages Show all packages in built-in registry
51
+
52
+
53
+ PROCESS ISOLATION
54
+ -----------------
55
+ For nodes that need isolated dependencies:
56
+
57
+ from comfy_env import isolated
58
+
59
+ @isolated(env="myenv")
60
+ class MyNode:
61
+ FUNCTION = "process"
62
+ RETURN_TYPES = ("IMAGE",)
63
+
64
+ def process(self, image):
65
+ # This runs in isolated subprocess
66
+ import conflicting_lib
67
+ return (result,)
68
+
69
+ The decorator:
70
+ - Runs your node's FUNCTION method in a separate Python process
71
+ - Transfers tensors efficiently via PyTorch IPC (zero-copy for CUDA)
72
+ - Uses the venv defined in your comfy-env.toml [myenv] section
73
+
74
+
75
+ TROUBLESHOOTING
76
+ ---------------
77
+ - "Package X not found in registry": Add custom wheel URL to [wheel_sources]
78
+ - "CUDA not detected": Ensure PyTorch with CUDA is installed in ComfyUI
79
+ - "Worker failed to connect": Check the isolated env was set up correctly
80
+ - Import errors: Run `comfy-env doctor` to verify packages
81
+
82
+ For more help: https://github.com/PozzettiAndrea/comfy-env
@@ -0,0 +1,211 @@
1
+ # =============================================================================
2
+ # comfy-env.toml - Environment configuration for ComfyUI custom nodes
3
+ # Documentation: https://github.com/PozzettiAndrea/comfy-env
4
+ # =============================================================================
5
+ #
6
+ # This file configures dependencies for your ComfyUI custom node.
7
+ # comfy-env handles two main challenges:
8
+ # 1. Installing CUDA packages that require compilation (nvdiffrast, pytorch3d, etc.)
9
+ # 2. Running nodes in isolated environments with their own dependencies
10
+ #
11
+ # Quick start:
12
+ # pip install comfy-env
13
+ # comfy-env init # Creates this template
14
+ # comfy-env install # Installs dependencies
15
+ # comfy-env doctor # Verifies installation
16
+
17
+
18
+ # =============================================================================
19
+ # SYSTEM PACKAGES (optional)
20
+ # =============================================================================
21
+ # System-level packages installed via apt (Linux) before Python packages.
22
+ # Useful for packages that need system libraries to compile or run.
23
+
24
+ [system]
25
+ linux = []
26
+ # Examples:
27
+ # linux = ["libgl1", "libopengl0"] # For OpenGL rendering (nvdiffrast)
28
+ # linux = ["python3-dev"] # For packages that compile C extensions
29
+ # linux = ["ffmpeg"] # For video processing nodes
30
+
31
+
32
+ # =============================================================================
33
+ # CUDA PACKAGES
34
+ # =============================================================================
35
+ # CUDA packages from the built-in registry. These are pre-compiled wheels
36
+ # that install without needing a compiler. Run `comfy-env list-packages`
37
+ # to see all available packages.
38
+
39
+ [cuda]
40
+ # Use exact package names from `comfy-env list-packages` (hyphens vs underscores matter!)
41
+ # nvdiffrast = "0.4.0" # NVIDIA differentiable rasterizer
42
+ # pytorch3d = "0.7.9" # PyTorch3D - 3D deep learning
43
+ # gsplat = "1.5.3" # Gaussian splatting rasterization
44
+ # torch-scatter = "2.1.2" # PyG scatter operations
45
+ # torch-cluster = "1.6.3" # PyG clustering algorithms
46
+ # flash-attn = "2.7.4" # Flash Attention (Linux x86_64 only)
47
+ # spconv = "2.3.8" # Sparse convolution library
48
+ # sageattention = "2.2.0" # SageAttention - faster than FlashAttention
49
+ # dpvo_cuda = "0.0.0" # DPVO CUDA extensions
50
+
51
+
52
+ # =============================================================================
53
+ # REGULAR PACKAGES
54
+ # =============================================================================
55
+ # Standard pip packages (no special CUDA handling needed).
56
+
57
+ [packages]
58
+ requirements = []
59
+ # Examples:
60
+ # requirements = [
61
+ # "transformers>=4.56",
62
+ # "pillow",
63
+ # "opencv-python-headless",
64
+ # "trimesh",
65
+ # ]
66
+
67
+
68
+ # =============================================================================
69
+ # CUSTOM WHEEL SOURCES (optional)
70
+ # =============================================================================
71
+ # Override built-in wheel URLs or add packages not in the registry.
72
+ # Template variables: {version}, {cuda_short}, {torch_mm}, {py_tag}, {platform}
73
+
74
+ [wheel_sources]
75
+ # my-custom-package = "https://my-server.com/my-package-{version}+cu{cuda_short}-{py_tag}-{platform}.whl"
76
+
77
+
78
+ # =============================================================================
79
+ # NODE DEPENDENCIES (optional)
80
+ # =============================================================================
81
+ # Other ComfyUI custom nodes this node depends on.
82
+
83
+ [node_reqs]
84
+ # VideoHelperSuite = "Kosinkadink/ComfyUI-VideoHelperSuite"
85
+ # ComfyUI-Impact-Pack = "ltdrdata/ComfyUI-Impact-Pack"
86
+
87
+
88
+ # =============================================================================
89
+ # EXTERNAL TOOLS (optional)
90
+ # =============================================================================
91
+ # External applications required by the node.
92
+
93
+ [tools]
94
+ # blender = "4.2"
95
+
96
+
97
+ # #############################################################################
98
+ #
99
+ # PROCESS ISOLATION (ADVANCED)
100
+ #
101
+ # #############################################################################
102
+ #
103
+ # For nodes that need completely isolated dependencies (different PyTorch
104
+ # version, conflicting native libraries, etc.), define isolated environments.
105
+ #
106
+ # How it works:
107
+ # 1. Define an environment below with its own Python/CUDA/packages
108
+ # 2. Use the @isolated decorator on your node class
109
+ # 3. The node runs in a separate subprocess with its own venv
110
+ #
111
+ # Example in __init__.py:
112
+ #
113
+ # from comfy_env import isolated
114
+ #
115
+ # @isolated(env="myenv")
116
+ # class MyIsolatedNode:
117
+ # FUNCTION = "process"
118
+ # RETURN_TYPES = ("IMAGE",)
119
+ #
120
+ # def process(self, image):
121
+ # # This runs in isolated subprocess with its own dependencies
122
+ # import conflicting_package
123
+ # return (result,)
124
+ #
125
+ # =============================================================================
126
+
127
+
128
+ # -----------------------------------------------------------------------------
129
+ # Example: Simple isolation (same Python, different process)
130
+ # -----------------------------------------------------------------------------
131
+ # Use when you just need process isolation but no venv (fastest option).
132
+ # In your code: @isolated(env="simple", same_venv=True)
133
+
134
+ # [simple]
135
+ # python = "3.11"
136
+ # cuda_version = "auto"
137
+ # pytorch_version = "auto"
138
+
139
+
140
+ # -----------------------------------------------------------------------------
141
+ # Example: Full venv isolation
142
+ # -----------------------------------------------------------------------------
143
+ # Use when you need completely different dependencies.
144
+ # Creates a separate virtual environment with its own packages.
145
+
146
+ # [myenv]
147
+ # python = "3.10"
148
+ # cuda_version = "12.8"
149
+ # pytorch_version = "2.8.0"
150
+ #
151
+ # [myenv.cuda]
152
+ # nvdiffrast = "0.4.0"
153
+ # pytorch3d = "0.7.9"
154
+ #
155
+ # [myenv.packages]
156
+ # requirements = ["trimesh", "scipy"]
157
+
158
+
159
+ # -----------------------------------------------------------------------------
160
+ # Example: Multiple isolated environments
161
+ # -----------------------------------------------------------------------------
162
+ # Some nodes need multiple different environments for different operations.
163
+
164
+ # [env-preprocessing]
165
+ # python = "3.11"
166
+ # cuda_version = "12.8"
167
+ # pytorch_version = "2.8.0"
168
+ #
169
+ # [env-preprocessing.packages]
170
+ # requirements = ["opencv-python-headless", "pillow"]
171
+
172
+ # [env-inference]
173
+ # python = "3.10"
174
+ # cuda_version = "12.4"
175
+ # pytorch_version = "2.5.1"
176
+ #
177
+ # [env-inference.cuda]
178
+ # torch-scatter = "2.1.2" # Use exact name from `comfy-env list-packages`
179
+
180
+
181
+ # -----------------------------------------------------------------------------
182
+ # Example: Platform-specific packages
183
+ # -----------------------------------------------------------------------------
184
+ # Different packages for Windows vs Linux.
185
+
186
+ # [crossplatform]
187
+ # python = "3.11"
188
+ # cuda_version = "auto"
189
+ #
190
+ # [crossplatform.packages]
191
+ # requirements = ["numpy", "pillow"]
192
+ #
193
+ # [crossplatform.packages.windows]
194
+ # requirements = ["pywin32"]
195
+ #
196
+ # [crossplatform.packages.linux]
197
+ # requirements = ["python-xlib"]
198
+
199
+
200
+ # -----------------------------------------------------------------------------
201
+ # Example: Conda packages (uses pixi backend)
202
+ # -----------------------------------------------------------------------------
203
+ # For packages that are easier to install via conda (e.g., CUDA toolkit).
204
+
205
+ # [blender-env]
206
+ # python = "3.11"
207
+ # cuda_version = "12.8"
208
+ #
209
+ # [blender-env.conda]
210
+ # channels = ["conda-forge", "nvidia"]
211
+ # packages = ["cuda-toolkit=12.8", "bpy"]
@@ -107,7 +107,7 @@ packages:
107
107
  default_version: "2.2.0"
108
108
  description: SageAttention - 2-5x faster than FlashAttention with quantized kernels
109
109
 
110
- dpvo_cuda:
110
+ dpvo-cuda:
111
111
  wheel_template: "https://github.com/PozzettiAndrea/cuda-wheels/releases/download/dpvo_cuda-latest/dpvo_cuda-{version}%2Bcu{cuda_short}torch{torch_mm}-{py_tag}-{py_tag}-{platform}.whl"
112
112
  default_version: "0.0.0"
113
113
  description: DPVO CUDA extensions (cuda_corr, cuda_ba, lietorch_backends) - torch 2.4 only
@@ -50,8 +50,12 @@ def _worker_loop(queue_in, queue_out, sys_path_additions=None):
50
50
  - _SHUTDOWN: Shutdown the worker
51
51
 
52
52
  Runs until receiving _SHUTDOWN sentinel.
53
+
54
+ Args:
55
+ queue_in: Input queue for receiving work items
56
+ queue_out: Output queue for sending results
57
+ sys_path_additions: Paths to add to sys.path
53
58
  """
54
- import importlib
55
59
  import os
56
60
  import sys
57
61
  from pathlib import Path
comfy_env/workers/venv.py CHANGED
@@ -912,7 +912,9 @@ class PersistentVenvWorker(Worker):
912
912
  self._transport = SocketTransport(client_sock)
913
913
 
914
914
  # Send config
915
- config = {"sys_paths": all_sys_path}
915
+ config = {
916
+ "sys_paths": all_sys_path,
917
+ }
916
918
  self._transport.send(config)
917
919
 
918
920
  # Wait for ready signal
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: comfy-env
3
- Version: 0.0.48
3
+ Version: 0.0.49
4
4
  Summary: Environment management for ComfyUI custom nodes - CUDA wheel resolution and process isolation
5
5
  Project-URL: Homepage, https://github.com/PozzettiAndrea/comfy-env
6
6
  Project-URL: Repository, https://github.com/PozzettiAndrea/comfy-env
@@ -1,6 +1,6 @@
1
1
  comfy_env/__init__.py,sha256=OQJFNjmArjLcgrfHAFxgDJQFH_IhxibqMXbU5bu_j9Q,3822
2
2
  comfy_env/cli.py,sha256=Pjzb-jsoH67lyHxmBFOWvasWX01eHFE_BEjUk1l-uEo,14509
3
- comfy_env/decorator.py,sha256=6JCKwLHaZtOLVDexs_gh_-NtS2ZK0V7nGCPqkyeYEAA,16688
3
+ comfy_env/decorator.py,sha256=sCb3DQIYYdt8fuMiJnmNfU8oLawbfjMMR2Hf0YMT4B0,16738
4
4
  comfy_env/errors.py,sha256=8hN8NDlo8oBUdapc-eT3ZluigI5VBzfqsSBvQdfWlz4,9943
5
5
  comfy_env/install.py,sha256=m4NKlfCcQGI5xzVRjHw3ep-lWbqx5kE1e21sUUZ2Leo,17528
6
6
  comfy_env/nodes.py,sha256=CWUe35jU5SKk4ur-SddZePdqWgxJDlxGhpcJiu5pAK4,4354
@@ -30,15 +30,17 @@ comfy_env/stubs/folder_paths.py,sha256=K90J34EG6LD4eZP8YG-xMeBmqwpp_wA8E92DKMXd1
30
30
  comfy_env/stubs/comfy/__init__.py,sha256=-y4L6gX21vrI2V8MvNaMeHOcAn5kUNK3jUyLvtXRmJQ,173
31
31
  comfy_env/stubs/comfy/model_management.py,sha256=Khx8Qa3NutKPLTn9oSM3VLeATUOg1fe4QCjxdxXd6eE,1462
32
32
  comfy_env/stubs/comfy/utils.py,sha256=s3t_KLj_-w1Uj3A3iAy69wIk4Ggklojw5hsDNb69Pcc,776
33
+ comfy_env/templates/comfy-env-instructions.txt,sha256=pXxlyOxWKq8NYtxIsa9wD8Y3qzC8JUWguTPiV9dB0Mw,2481
34
+ comfy_env/templates/comfy-env.toml,sha256=1CyphZu9DVc-EKzkLiDCnNzY9AWH5s_Kp9o4s2Fnw9g,7441
33
35
  comfy_env/workers/__init__.py,sha256=IKZwOvrWOGqBLDUIFAalg4CdqzJ_YnAdxo2Ha7gZTJ0,1467
34
36
  comfy_env/workers/base.py,sha256=ZILYXlvGCWuCZXmjKqfG8VeD19ihdYaASdlbasl2BMo,2312
35
37
  comfy_env/workers/pool.py,sha256=MtjeOWfvHSCockq8j1gfnxIl-t01GSB79T5N4YB82Lg,6956
36
38
  comfy_env/workers/tensor_utils.py,sha256=TCuOAjJymrSbkgfyvcKtQ_KbVWTqSwP9VH_bCaFLLq8,6409
37
- comfy_env/workers/torch_mp.py,sha256=4YSNPn7hALrvMVbkO4RkTeFTcc0lhfLMk5QTWjY4PHw,22134
38
- comfy_env/workers/venv.py,sha256=9xP3Y_ZoegMMCnBuRrd-mlIEKRF4oE01zL_8bngRuCk,38916
39
- comfy_env/wheel_sources.yml,sha256=K5dksy21YcT7QdFlVDkKF4Rv9ZCjHaWhQgoEhdSyAOI,8156
40
- comfy_env-0.0.48.dist-info/METADATA,sha256=a8hWh2c1hJZt2WkfR4giYSjl86bBTDuXYWB0Mn2z-8E,7138
41
- comfy_env-0.0.48.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
42
- comfy_env-0.0.48.dist-info/entry_points.txt,sha256=J4fXeqgxU_YenuW_Zxn_pEL7J-3R0--b6MS5t0QmAr0,49
43
- comfy_env-0.0.48.dist-info/licenses/LICENSE,sha256=E68QZMMpW4P2YKstTZ3QU54HRQO8ecew09XZ4_Vn870,1093
44
- comfy_env-0.0.48.dist-info/RECORD,,
39
+ comfy_env/workers/torch_mp.py,sha256=TnsCoBHEJBXEoBkx7WiCd9tBAlzFtMOw1dk_7_zGJZY,22288
40
+ comfy_env/workers/venv.py,sha256=kAaADoUJpKItZoG73YZhn0ufqzHmDgU1xeSHNCiZ77I,38941
41
+ comfy_env/wheel_sources.yml,sha256=uU0YJmWaiLAicQNN9VYS8PZevlP2NOH6mBUE294dvAo,8156
42
+ comfy_env-0.0.49.dist-info/METADATA,sha256=Ve0XcboM1LLVeXVFYTbBDMxIcefaYiYnC8Nf84inrhQ,7138
43
+ comfy_env-0.0.49.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
44
+ comfy_env-0.0.49.dist-info/entry_points.txt,sha256=J4fXeqgxU_YenuW_Zxn_pEL7J-3R0--b6MS5t0QmAr0,49
45
+ comfy_env-0.0.49.dist-info/licenses/LICENSE,sha256=E68QZMMpW4P2YKstTZ3QU54HRQO8ecew09XZ4_Vn870,1093
46
+ comfy_env-0.0.49.dist-info/RECORD,,