comfy-env 0.1.6__py3-none-any.whl → 0.1.8__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/prestartup.py CHANGED
@@ -39,6 +39,56 @@ def _load_env_vars(config_path: str) -> Dict[str, str]:
39
39
  return {}
40
40
 
41
41
 
42
+ def _dedupe_libomp_macos():
43
+ """
44
+ macOS: Dedupe libomp.dylib to prevent OpenMP runtime conflicts.
45
+
46
+ Torch and other packages (PyMeshLab, etc.) bundle their own libomp.
47
+ Two OpenMP runtimes in same process = crash.
48
+ Fix: symlink all libomp copies to torch's (canonical source).
49
+ """
50
+ if sys.platform != "darwin":
51
+ return
52
+
53
+ # Find torch's libomp (canonical source) via introspection
54
+ try:
55
+ import torch
56
+ torch_libomp = os.path.join(os.path.dirname(torch.__file__), 'lib', 'libomp.dylib')
57
+ if not os.path.exists(torch_libomp):
58
+ return
59
+ except ImportError:
60
+ return # No torch, skip
61
+
62
+ # Find site-packages for scanning
63
+ site_packages = os.path.dirname(os.path.dirname(torch.__file__))
64
+
65
+ # Find other libomp files and symlink to torch's
66
+ patterns = [
67
+ os.path.join(site_packages, '*', 'Frameworks', 'libomp.dylib'),
68
+ os.path.join(site_packages, '*', '.dylibs', 'libomp.dylib'),
69
+ os.path.join(site_packages, '*', 'lib', 'libomp.dylib'),
70
+ ]
71
+
72
+ for pattern in patterns:
73
+ for libomp in glob.glob(pattern):
74
+ # Skip torch's own copy
75
+ if 'torch' in libomp:
76
+ continue
77
+ # Skip if already a symlink pointing to torch
78
+ if os.path.islink(libomp):
79
+ if os.path.realpath(libomp) == os.path.realpath(torch_libomp):
80
+ continue
81
+ # Replace with symlink to torch's
82
+ try:
83
+ if os.path.islink(libomp):
84
+ os.unlink(libomp)
85
+ else:
86
+ os.rename(libomp, libomp + '.bak')
87
+ os.symlink(torch_libomp, libomp)
88
+ except OSError:
89
+ pass # Permission denied, etc.
90
+
91
+
42
92
  def setup_env(node_dir: Optional[str] = None) -> None:
43
93
  """
44
94
  Set up environment for pixi conda libraries.
@@ -56,6 +106,9 @@ def setup_env(node_dir: Optional[str] = None) -> None:
56
106
  from comfy_env import setup_env
57
107
  setup_env()
58
108
  """
109
+ # macOS: Dedupe libomp to prevent OpenMP conflicts (torch vs pymeshlab, etc.)
110
+ _dedupe_libomp_macos()
111
+
59
112
  # Auto-detect node_dir from caller
60
113
  if node_dir is None:
61
114
  import inspect
@@ -78,8 +131,13 @@ def setup_env(node_dir: Optional[str] = None) -> None:
78
131
  lib_dir = os.path.join(pixi_env, "Library", "bin")
79
132
  if os.path.exists(lib_dir):
80
133
  os.environ["PATH"] = lib_dir + ";" + os.environ.get("PATH", "")
134
+ elif sys.platform == "darwin":
135
+ # macOS: DYLD_LIBRARY_PATH
136
+ lib_dir = os.path.join(pixi_env, "lib")
137
+ if os.path.exists(lib_dir):
138
+ os.environ["DYLD_LIBRARY_PATH"] = lib_dir + ":" + os.environ.get("DYLD_LIBRARY_PATH", "")
81
139
  else:
82
- # Linux/Mac: LD_LIBRARY_PATH
140
+ # Linux: LD_LIBRARY_PATH
83
141
  lib_dir = os.path.join(pixi_env, "lib")
84
142
  if os.path.exists(lib_dir):
85
143
  os.environ["LD_LIBRARY_PATH"] = lib_dir + ":" + os.environ.get("LD_LIBRARY_PATH", "")
comfy_env/workers/mp.py CHANGED
@@ -80,7 +80,7 @@ def _dump_worker_env(worker_name: str = "unknown", print_to_terminal: bool = Fal
80
80
  print(f"[comfy-env] Python: {sys.executable}")
81
81
  print(f"[comfy-env] Version: {sys.version.split()[0]}")
82
82
  print(f"[comfy-env] PID: {os.getpid()}, CWD: {os.getcwd()}")
83
- for var in ['PATH', 'LD_LIBRARY_PATH', 'PYTHONPATH', 'OMP_NUM_THREADS', 'KMP_DUPLICATE_LIB_OK']:
83
+ for var in ['PATH', 'LD_LIBRARY_PATH', 'DYLD_LIBRARY_PATH', 'PYTHONPATH', 'OMP_NUM_THREADS', 'KMP_DUPLICATE_LIB_OK']:
84
84
  val = os.environ.get(var, '<unset>')
85
85
  if len(val) > 100:
86
86
  val = val[:100] + '...'
@@ -143,8 +143,14 @@ def _worker_loop(queue_in, queue_out, sys_path_additions=None, lib_path=None, en
143
143
  if lib_path:
144
144
  clean_parts.insert(0, lib_path)
145
145
  os.environ["PATH"] = path_sep.join(clean_parts)
146
+ elif sys.platform == "darwin":
147
+ # macOS: ONLY use the isolated lib_path, don't inherit
148
+ if lib_path:
149
+ os.environ["DYLD_LIBRARY_PATH"] = lib_path
150
+ else:
151
+ os.environ.pop("DYLD_LIBRARY_PATH", None)
146
152
  else:
147
- # Linux/Mac: Filter LD_LIBRARY_PATH with same patterns
153
+ # Linux: Use LD_LIBRARY_PATH
148
154
  current = os.environ.get("LD_LIBRARY_PATH", "")
149
155
  clean_parts = [
150
156
  p for p in current.split(path_sep) if p
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: comfy-env
3
- Version: 0.1.6
3
+ Version: 0.1.8
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
@@ -3,7 +3,7 @@ comfy_env/cli.py,sha256=ty4HYlzollCUCS0o6Sha6eczPAsW_gHRVgvck3IfA2w,12723
3
3
  comfy_env/errors.py,sha256=q-C3vyrPa_kk_Ao8l17mIGfJiG2IR0hCFV0GFcNLmcI,9924
4
4
  comfy_env/install.py,sha256=N7eBj8wB2DrGepVYk-Hks2mSf6UuGzj34pfVLNYJgQ4,10357
5
5
  comfy_env/nodes.py,sha256=nBkG2pESeOt5kXSgTDIHAHaVdHK8-rEueR3BxXWn6TE,4354
6
- comfy_env/prestartup.py,sha256=rP0TtT9lxiU7Py27U79Ew7954VpHsYL6lfx4IpQY1Uc,3152
6
+ comfy_env/prestartup.py,sha256=NML_nzg4h37YdEg7gHxA7ke_uXWZsldz-X3HldHEUsE,5338
7
7
  comfy_env/config/__init__.py,sha256=4Guylkb-FV8QxhFwschzpzbr2eu8y-KNgNT3_JOm9jc,403
8
8
  comfy_env/config/parser.py,sha256=dA1lX5ExBEfCqUJwe4V5i_jn2NJ69bMq3c3ji3lMSV8,4295
9
9
  comfy_env/config/types.py,sha256=Sb8HO34xsSZu5YAc2K4M7Gb3QNevJlngf12hHiwuU0w,2140
@@ -22,11 +22,11 @@ comfy_env/templates/comfy-env-instructions.txt,sha256=ve1RAthW7ouumU9h6DM7mIRX1M
22
22
  comfy_env/templates/comfy-env.toml,sha256=ROIqi4BlPL1MEdL1VgebfTHpdwPNYGHwWeigI9Kw-1I,4831
23
23
  comfy_env/workers/__init__.py,sha256=TMVG55d2XLP1mJ3x1d16H0SBDJZtk2kMC5P4HLk9TrA,1073
24
24
  comfy_env/workers/base.py,sha256=4ZYTaQ4J0kBHCoO_OfZnsowm4rJCoqinZUaOtgkOPbw,2307
25
- comfy_env/workers/mp.py,sha256=xqSLnpR5zSVdZKt10nM6LmNyJ2SmlSr1yQ5I9HX5OJ4,29514
25
+ comfy_env/workers/mp.py,sha256=8Xqcr4R4KlHtP1P_UDAtSTPHA_5i-ySTlxxLpqyOk-w,29757
26
26
  comfy_env/workers/subprocess.py,sha256=UMhKhaJoSjv2-FWnwQq9TeMWtaDLIs3ajAFTq1ngdJw,57844
27
27
  comfy_env/workers/tensor_utils.py,sha256=TCuOAjJymrSbkgfyvcKtQ_KbVWTqSwP9VH_bCaFLLq8,6409
28
- comfy_env-0.1.6.dist-info/METADATA,sha256=IT7HN3q_Q7hdsZqcGRbgtoeKBTN6z_1Gzr8KhVtPpg0,6945
29
- comfy_env-0.1.6.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
30
- comfy_env-0.1.6.dist-info/entry_points.txt,sha256=J4fXeqgxU_YenuW_Zxn_pEL7J-3R0--b6MS5t0QmAr0,49
31
- comfy_env-0.1.6.dist-info/licenses/LICENSE,sha256=E68QZMMpW4P2YKstTZ3QU54HRQO8ecew09XZ4_Vn870,1093
32
- comfy_env-0.1.6.dist-info/RECORD,,
28
+ comfy_env-0.1.8.dist-info/METADATA,sha256=8WOllc7KtZ1wb3pkCam0qZd5YW1CEd33WwQIzBqENJI,6945
29
+ comfy_env-0.1.8.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
30
+ comfy_env-0.1.8.dist-info/entry_points.txt,sha256=J4fXeqgxU_YenuW_Zxn_pEL7J-3R0--b6MS5t0QmAr0,49
31
+ comfy_env-0.1.8.dist-info/licenses/LICENSE,sha256=E68QZMMpW4P2YKstTZ3QU54HRQO8ecew09XZ4_Vn870,1093
32
+ comfy_env-0.1.8.dist-info/RECORD,,