comfy-env 0.0.64__py3-none-any.whl → 0.0.66__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.
Files changed (55) hide show
  1. comfy_env/__init__.py +70 -122
  2. comfy_env/cli.py +78 -7
  3. comfy_env/config/__init__.py +19 -0
  4. comfy_env/config/parser.py +151 -0
  5. comfy_env/config/types.py +64 -0
  6. comfy_env/install.py +83 -361
  7. comfy_env/isolation/__init__.py +9 -0
  8. comfy_env/isolation/wrap.py +351 -0
  9. comfy_env/nodes.py +2 -2
  10. comfy_env/pixi/__init__.py +48 -0
  11. comfy_env/pixi/core.py +356 -0
  12. comfy_env/{resolver.py → pixi/resolver.py} +1 -14
  13. comfy_env/prestartup.py +60 -0
  14. comfy_env/templates/comfy-env-instructions.txt +30 -87
  15. comfy_env/templates/comfy-env.toml +68 -136
  16. comfy_env/workers/__init__.py +21 -32
  17. comfy_env/workers/base.py +1 -1
  18. comfy_env/workers/{torch_mp.py → mp.py} +47 -14
  19. comfy_env/workers/{venv.py → subprocess.py} +405 -441
  20. {comfy_env-0.0.64.dist-info → comfy_env-0.0.66.dist-info}/METADATA +2 -1
  21. comfy_env-0.0.66.dist-info/RECORD +34 -0
  22. comfy_env/decorator.py +0 -700
  23. comfy_env/env/__init__.py +0 -47
  24. comfy_env/env/config.py +0 -201
  25. comfy_env/env/config_file.py +0 -740
  26. comfy_env/env/manager.py +0 -636
  27. comfy_env/env/security.py +0 -267
  28. comfy_env/ipc/__init__.py +0 -55
  29. comfy_env/ipc/bridge.py +0 -476
  30. comfy_env/ipc/protocol.py +0 -265
  31. comfy_env/ipc/tensor.py +0 -371
  32. comfy_env/ipc/torch_bridge.py +0 -401
  33. comfy_env/ipc/transport.py +0 -318
  34. comfy_env/ipc/worker.py +0 -221
  35. comfy_env/isolation.py +0 -310
  36. comfy_env/pixi.py +0 -760
  37. comfy_env/stub_imports.py +0 -270
  38. comfy_env/stubs/__init__.py +0 -1
  39. comfy_env/stubs/comfy/__init__.py +0 -6
  40. comfy_env/stubs/comfy/model_management.py +0 -58
  41. comfy_env/stubs/comfy/utils.py +0 -29
  42. comfy_env/stubs/folder_paths.py +0 -71
  43. comfy_env/workers/pool.py +0 -241
  44. comfy_env-0.0.64.dist-info/RECORD +0 -48
  45. /comfy_env/{env/cuda_gpu_detection.py → pixi/cuda_detection.py} +0 -0
  46. /comfy_env/{env → pixi}/platform/__init__.py +0 -0
  47. /comfy_env/{env → pixi}/platform/base.py +0 -0
  48. /comfy_env/{env → pixi}/platform/darwin.py +0 -0
  49. /comfy_env/{env → pixi}/platform/linux.py +0 -0
  50. /comfy_env/{env → pixi}/platform/windows.py +0 -0
  51. /comfy_env/{registry.py → pixi/registry.py} +0 -0
  52. /comfy_env/{wheel_sources.yml → pixi/wheel_sources.yml} +0 -0
  53. {comfy_env-0.0.64.dist-info → comfy_env-0.0.66.dist-info}/WHEEL +0 -0
  54. {comfy_env-0.0.64.dist-info → comfy_env-0.0.66.dist-info}/entry_points.txt +0 -0
  55. {comfy_env-0.0.64.dist-info → comfy_env-0.0.66.dist-info}/licenses/LICENSE +0 -0
comfy_env/env/__init__.py DELETED
@@ -1,47 +0,0 @@
1
- """Environment management for comfyui-isolation."""
2
-
3
- from .config import IsolatedEnv, ToolConfig
4
- from .manager import IsolatedEnvManager
5
- from .cuda_gpu_detection import (
6
- GPUInfo,
7
- CUDAEnvironment,
8
- detect_cuda_environment,
9
- detect_cuda_version,
10
- detect_gpu_info,
11
- detect_gpus,
12
- get_gpu_summary,
13
- get_recommended_cuda_version,
14
- )
15
- from .platform import get_platform, PlatformProvider, PlatformPaths
16
- from .security import (
17
- normalize_env_name,
18
- validate_dependency,
19
- validate_dependencies,
20
- validate_path_within_root,
21
- validate_wheel_url,
22
- )
23
-
24
- __all__ = [
25
- "IsolatedEnv",
26
- "IsolatedEnvManager",
27
- "ToolConfig",
28
- # GPU Detection
29
- "GPUInfo",
30
- "CUDAEnvironment",
31
- "detect_cuda_environment",
32
- "detect_cuda_version",
33
- "detect_gpu_info",
34
- "detect_gpus",
35
- "get_gpu_summary",
36
- "get_recommended_cuda_version",
37
- # Platform
38
- "get_platform",
39
- "PlatformProvider",
40
- "PlatformPaths",
41
- # Security
42
- "normalize_env_name",
43
- "validate_dependency",
44
- "validate_dependencies",
45
- "validate_path_within_root",
46
- "validate_wheel_url",
47
- ]
comfy_env/env/config.py DELETED
@@ -1,201 +0,0 @@
1
- """Configuration for isolated environments."""
2
-
3
- from dataclasses import dataclass, field
4
- from pathlib import Path
5
- from typing import Dict, List, Optional
6
-
7
-
8
- @dataclass
9
- class SystemConfig:
10
- """Configuration for system-level packages.
11
-
12
- These are OS-level packages (apt, brew, etc.) that need to be installed
13
- before Python packages can work properly.
14
- """
15
- linux: List[str] = field(default_factory=list) # apt packages
16
- darwin: List[str] = field(default_factory=list) # brew packages (future)
17
- windows: List[str] = field(default_factory=list) # winget packages (future)
18
-
19
-
20
- @dataclass
21
- class LocalConfig:
22
- """Configuration for local (host environment) installs.
23
-
24
- These packages are installed into ComfyUI's main environment,
25
- not into an isolated venv.
26
- """
27
- cuda_packages: Dict[str, str] = field(default_factory=dict) # package -> version
28
- requirements: List[str] = field(default_factory=list)
29
-
30
-
31
- @dataclass
32
- class CondaConfig:
33
- """Configuration for conda packages (installed via pixi).
34
-
35
- When present, the environment uses pixi as the backend instead of uv.
36
- Pixi manages both conda and pip packages in a unified environment.
37
- """
38
- channels: List[str] = field(default_factory=list) # conda channels
39
- packages: List[str] = field(default_factory=list) # conda packages
40
-
41
-
42
- @dataclass
43
- class NodeReq:
44
- """A node dependency (another ComfyUI node pack)."""
45
- name: str
46
- repo: str # GitHub repo path, e.g., "Kosinkadink/ComfyUI-VideoHelperSuite"
47
-
48
-
49
- @dataclass
50
- class ToolConfig:
51
- """Configuration for an external tool like Blender."""
52
- name: str
53
- version: str = "latest"
54
- install_dir: Optional[Path] = None
55
-
56
-
57
- @dataclass
58
- class EnvManagerConfig:
59
- """
60
- Full configuration parsed from comfy-env.toml.
61
-
62
- Supports the v2 schema:
63
- [system] - System-level packages (apt, brew, etc.)
64
- [local.cuda] - CUDA packages for host environment
65
- [local.packages] - Regular packages for host environment
66
- [envname] - Isolated env definition
67
- [envname.cuda] - CUDA packages for isolated env
68
- [envname.packages] - Regular packages for isolated env
69
- [node_reqs] - Node dependencies
70
- [tools] - External tools (e.g., blender = "4.2")
71
- [wheel_sources] - Custom wheel URL templates (override registry)
72
- """
73
- system: SystemConfig = field(default_factory=SystemConfig)
74
- local: LocalConfig = field(default_factory=LocalConfig)
75
- envs: Dict[str, "IsolatedEnv"] = field(default_factory=dict)
76
- node_reqs: List[NodeReq] = field(default_factory=list)
77
- tools: Dict[str, ToolConfig] = field(default_factory=dict)
78
- wheel_sources: Dict[str, str] = field(default_factory=dict) # package -> wheel_template URL
79
-
80
- @property
81
- def has_system(self) -> bool:
82
- """Check if there are system packages to install."""
83
- return bool(self.system.linux or self.system.darwin or self.system.windows)
84
-
85
- @property
86
- def has_local(self) -> bool:
87
- """Check if there are local packages to install."""
88
- return bool(self.local.cuda_packages or self.local.requirements)
89
-
90
- @property
91
- def has_envs(self) -> bool:
92
- """Check if there are isolated environments defined."""
93
- return bool(self.envs)
94
-
95
- def get_env(self, name: str) -> Optional["IsolatedEnv"]:
96
- """Get an isolated environment by name."""
97
- return self.envs.get(name)
98
-
99
- @property
100
- def default_env(self) -> Optional["IsolatedEnv"]:
101
- """Get the first/only isolated environment, or None."""
102
- if self.envs:
103
- return next(iter(self.envs.values()))
104
- return None
105
-
106
-
107
- @dataclass
108
- class IsolatedEnv:
109
- """
110
- Configuration for an isolated Python environment.
111
-
112
- This defines what Python version, CUDA version, and dependencies
113
- should be installed in the isolated environment.
114
-
115
- Args:
116
- name: Unique name for this environment (used for caching)
117
- python: Python version (e.g., "3.10", "3.11")
118
- cuda: CUDA version (e.g., "12.4", "12.8") or None for CPU-only
119
- requirements: List of pip requirements (e.g., ["torch==2.8.0", "numpy"])
120
- requirements_file: Path to requirements.txt file
121
- wheel_sources: List of URLs for --find-links (custom wheel repos)
122
- index_urls: List of URLs for --extra-index-url
123
- env_dir: Custom directory for the venv (default: auto-generated)
124
- pytorch_version: Specific PyTorch version (auto-detected if None)
125
- worker_package: Worker package directory (e.g., "worker" -> worker/__main__.py)
126
- worker_script: Worker script file (e.g., "worker.py")
127
-
128
- Example:
129
- env = IsolatedEnv(
130
- name="my-node",
131
- python="3.10",
132
- cuda="12.8",
133
- requirements=["torch==2.8.0", "nvdiffrast"],
134
- wheel_sources=["https://my-wheels.github.io/"],
135
- )
136
- """
137
-
138
- name: str
139
- python: str = "3.10"
140
- cuda: Optional[str] = None
141
- requirements: list[str] = field(default_factory=list)
142
- no_deps_requirements: list[str] = field(default_factory=list) # Install with --no-deps
143
- # Platform-specific requirements (merged at install time)
144
- windows_requirements: list[str] = field(default_factory=list)
145
- linux_requirements: list[str] = field(default_factory=list)
146
- darwin_requirements: list[str] = field(default_factory=list)
147
- requirements_file: Optional[Path] = None
148
- wheel_sources: list[str] = field(default_factory=list)
149
- index_urls: list[str] = field(default_factory=list)
150
- env_dir: Optional[Path] = None
151
- pytorch_version: Optional[str] = None
152
- # Worker configuration
153
- worker_package: Optional[str] = None # e.g., "worker" -> worker/__main__.py
154
- worker_script: Optional[str] = None # e.g., "worker.py" -> worker.py
155
- # Conda configuration (uses pixi backend when present)
156
- conda: Optional["CondaConfig"] = None
157
- # Runtime isolation - run node FUNCTION methods in isolated subprocess
158
- isolated: bool = False
159
- # Environment variables for install (e.g., CMAKE_ARGS for build flags)
160
- env_vars: Dict[str, str] = field(default_factory=dict)
161
-
162
- def __post_init__(self):
163
- """Validate and normalize configuration."""
164
- # Normalize paths
165
- if self.requirements_file is not None:
166
- self.requirements_file = Path(self.requirements_file)
167
- if self.env_dir is not None:
168
- self.env_dir = Path(self.env_dir)
169
-
170
- # Validate Python version
171
- if not self.python.replace(".", "").isdigit():
172
- raise ValueError(f"Invalid Python version: {self.python}")
173
-
174
- # Validate CUDA version if specified
175
- if self.cuda is not None:
176
- cuda_clean = self.cuda.replace(".", "")
177
- if not cuda_clean.isdigit():
178
- raise ValueError(f"Invalid CUDA version: {self.cuda}")
179
-
180
- @property
181
- def cuda_short(self) -> Optional[str]:
182
- """Get CUDA version without dots (e.g., '128' for '12.8')."""
183
- if self.cuda is None:
184
- return None
185
- return self.cuda.replace(".", "")
186
-
187
- @property
188
- def python_short(self) -> str:
189
- """Get Python version without dots (e.g., '310' for '3.10')."""
190
- return self.python.replace(".", "")
191
-
192
- def get_default_env_dir(self, base_dir: Path) -> Path:
193
- """Get the default environment directory path."""
194
- if self.env_dir is not None:
195
- return self.env_dir
196
- return base_dir / f"_env_{self.name}"
197
-
198
- @property
199
- def uses_conda(self) -> bool:
200
- """Check if this environment uses conda packages (pixi backend)."""
201
- return self.conda is not None and bool(self.conda.packages)