comfy-env 0.0.65__py3-none-any.whl → 0.0.67__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 +68 -122
  2. comfy_env/cli.py +74 -204
  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 +69 -128
  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} +397 -443
  20. {comfy_env-0.0.65.dist-info → comfy_env-0.0.67.dist-info}/METADATA +23 -92
  21. comfy_env-0.0.67.dist-info/RECORD +32 -0
  22. comfy_env/decorator.py +0 -700
  23. comfy_env/env/__init__.py +0 -46
  24. comfy_env/env/config.py +0 -191
  25. comfy_env/env/config_file.py +0 -706
  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/registry.py +0 -130
  38. comfy_env/stub_imports.py +0 -270
  39. comfy_env/stubs/__init__.py +0 -1
  40. comfy_env/stubs/comfy/__init__.py +0 -6
  41. comfy_env/stubs/comfy/model_management.py +0 -58
  42. comfy_env/stubs/comfy/utils.py +0 -29
  43. comfy_env/stubs/folder_paths.py +0 -71
  44. comfy_env/wheel_sources.yml +0 -141
  45. comfy_env/workers/pool.py +0 -241
  46. comfy_env-0.0.65.dist-info/RECORD +0 -48
  47. /comfy_env/{env/cuda_gpu_detection.py → pixi/cuda_detection.py} +0 -0
  48. /comfy_env/{env → pixi}/platform/__init__.py +0 -0
  49. /comfy_env/{env → pixi}/platform/base.py +0 -0
  50. /comfy_env/{env → pixi}/platform/darwin.py +0 -0
  51. /comfy_env/{env → pixi}/platform/linux.py +0 -0
  52. /comfy_env/{env → pixi}/platform/windows.py +0 -0
  53. {comfy_env-0.0.65.dist-info → comfy_env-0.0.67.dist-info}/WHEEL +0 -0
  54. {comfy_env-0.0.65.dist-info → comfy_env-0.0.67.dist-info}/entry_points.txt +0 -0
  55. {comfy_env-0.0.65.dist-info → comfy_env-0.0.67.dist-info}/licenses/LICENSE +0 -0
@@ -0,0 +1,151 @@
1
+ """Load configuration from comfy-env.toml.
2
+
3
+ comfy-env.toml is a superset of pixi.toml. Custom sections we handle:
4
+ - python = "3.11" - Python version for isolated envs
5
+ - [cuda] packages = [...] - CUDA packages (triggers find-links + PyTorch detection)
6
+ - [node_reqs] - Other ComfyUI nodes to clone
7
+
8
+ Everything else passes through to pixi.toml directly.
9
+
10
+ Example config:
11
+
12
+ python = "3.11"
13
+
14
+ [cuda]
15
+ packages = ["cumesh"]
16
+
17
+ [dependencies]
18
+ mesalib = "*"
19
+ cgal = "*"
20
+
21
+ [pypi-dependencies]
22
+ numpy = ">=1.21.0,<2"
23
+ trimesh = { version = ">=4.0.0", extras = ["easy"] }
24
+
25
+ [target.linux-64.pypi-dependencies]
26
+ embreex = "*"
27
+
28
+ [node_reqs]
29
+ SomeNode = "owner/repo"
30
+ """
31
+
32
+ import copy
33
+ import sys
34
+ from pathlib import Path
35
+ from typing import Optional, Dict, Any, List
36
+
37
+ # Use built-in tomllib (Python 3.11+) or tomli fallback
38
+ if sys.version_info >= (3, 11):
39
+ import tomllib
40
+ else:
41
+ try:
42
+ import tomli as tomllib
43
+ except ImportError:
44
+ tomllib = None # type: ignore
45
+
46
+ from .types import ComfyEnvConfig, NodeReq
47
+
48
+
49
+ CONFIG_FILE_NAME = "comfy-env.toml"
50
+
51
+ # Sections we handle specially (not passed through to pixi.toml)
52
+ CUSTOM_SECTIONS = {"python", "cuda", "node_reqs"}
53
+
54
+
55
+ def load_config(path: Path) -> ComfyEnvConfig:
56
+ """
57
+ Load configuration from a TOML file.
58
+
59
+ Args:
60
+ path: Path to comfy-env.toml
61
+
62
+ Returns:
63
+ ComfyEnvConfig instance
64
+
65
+ Raises:
66
+ FileNotFoundError: If config file doesn't exist
67
+ ImportError: If tomli not installed (Python < 3.11)
68
+ """
69
+ if tomllib is None:
70
+ raise ImportError(
71
+ "TOML parsing requires tomli for Python < 3.11. "
72
+ "Install with: pip install tomli"
73
+ )
74
+
75
+ path = Path(path)
76
+ if not path.exists():
77
+ raise FileNotFoundError(f"Config file not found: {path}")
78
+
79
+ with open(path, "rb") as f:
80
+ data = tomllib.load(f)
81
+
82
+ return _parse_config(data)
83
+
84
+
85
+ def discover_config(node_dir: Path) -> Optional[ComfyEnvConfig]:
86
+ """
87
+ Find and load comfy-env.toml from a directory.
88
+
89
+ Args:
90
+ node_dir: Directory to search
91
+
92
+ Returns:
93
+ ComfyEnvConfig if found, None otherwise
94
+ """
95
+ if tomllib is None:
96
+ return None
97
+
98
+ config_path = Path(node_dir) / CONFIG_FILE_NAME
99
+ if config_path.exists():
100
+ return load_config(config_path)
101
+
102
+ return None
103
+
104
+
105
+ def _parse_config(data: Dict[str, Any]) -> ComfyEnvConfig:
106
+ """Parse TOML data into ComfyEnvConfig."""
107
+ # Make a copy so we can pop our custom sections
108
+ data = copy.deepcopy(data)
109
+
110
+ # Extract python version (top-level key)
111
+ python_version = data.pop("python", None)
112
+ if python_version is not None:
113
+ python_version = str(python_version)
114
+
115
+ # Extract [cuda] section
116
+ cuda_data = data.pop("cuda", {})
117
+ cuda_packages = _ensure_list(cuda_data.get("packages", []))
118
+
119
+ # Extract [node_reqs] section
120
+ node_reqs_data = data.pop("node_reqs", {})
121
+ node_reqs = _parse_node_reqs(node_reqs_data)
122
+
123
+ # Everything else passes through to pixi.toml
124
+ pixi_passthrough = data
125
+
126
+ return ComfyEnvConfig(
127
+ python=python_version,
128
+ cuda_packages=cuda_packages,
129
+ node_reqs=node_reqs,
130
+ pixi_passthrough=pixi_passthrough,
131
+ )
132
+
133
+
134
+ def _parse_node_reqs(data: Dict[str, Any]) -> List[NodeReq]:
135
+ """Parse [node_reqs] section."""
136
+ node_reqs = []
137
+ for name, value in data.items():
138
+ if isinstance(value, str):
139
+ node_reqs.append(NodeReq(name=name, repo=value))
140
+ elif isinstance(value, dict):
141
+ node_reqs.append(NodeReq(name=name, repo=value.get("repo", "")))
142
+ return node_reqs
143
+
144
+
145
+ def _ensure_list(value) -> List:
146
+ """Ensure value is a list."""
147
+ if isinstance(value, list):
148
+ return value
149
+ if value:
150
+ return [value]
151
+ return []
@@ -0,0 +1,64 @@
1
+ """Configuration types for comfy-env."""
2
+
3
+ from dataclasses import dataclass, field
4
+ from typing import Any, Dict, List, Optional
5
+
6
+
7
+ @dataclass
8
+ class NodeReq:
9
+ """A node dependency (another ComfyUI custom node)."""
10
+ name: str
11
+ repo: str # GitHub repo, e.g., "owner/repo"
12
+
13
+
14
+ @dataclass
15
+ class ComfyEnvConfig:
16
+ """
17
+ Configuration from comfy-env.toml.
18
+
19
+ comfy-env.toml is a superset of pixi.toml. Custom sections we handle:
20
+ - python = "3.11" - Python version for isolated envs
21
+ - [cuda] packages = [...] - CUDA packages (triggers find-links + PyTorch detection)
22
+ - [node_reqs] - Other ComfyUI nodes to clone
23
+
24
+ Everything else passes through to pixi.toml directly:
25
+ - [dependencies] - conda packages
26
+ - [pypi-dependencies] - pip packages
27
+ - [target.linux-64.pypi-dependencies] - platform-specific deps
28
+ - Any other pixi.toml syntax
29
+
30
+ Example config:
31
+ python = "3.11"
32
+
33
+ [cuda]
34
+ packages = ["cumesh"]
35
+
36
+ [dependencies]
37
+ mesalib = "*"
38
+ cgal = "*"
39
+
40
+ [pypi-dependencies]
41
+ numpy = ">=1.21.0,<2"
42
+ trimesh = { version = ">=4.0.0", extras = ["easy"] }
43
+
44
+ [target.linux-64.pypi-dependencies]
45
+ embreex = "*"
46
+
47
+ [node_reqs]
48
+ SomeNode = "owner/repo"
49
+ """
50
+ # python = "3.11" - Python version (for isolated envs)
51
+ python: Optional[str] = None
52
+
53
+ # [cuda] - CUDA packages (installed via find-links index)
54
+ cuda_packages: List[str] = field(default_factory=list)
55
+
56
+ # [node_reqs] - other ComfyUI nodes to clone
57
+ node_reqs: List[NodeReq] = field(default_factory=list)
58
+
59
+ # Everything else from comfy-env.toml passes through to pixi.toml
60
+ pixi_passthrough: Dict[str, Any] = field(default_factory=dict)
61
+
62
+ @property
63
+ def has_cuda(self) -> bool:
64
+ return bool(self.cuda_packages)