feat: comfyui create venv as needed
Fixes #263, #272.
As comfy-cli might be installed globally via pipx or uv, as per linked issue, it ends up installing the comfyui dependencies into the managed environment. Especially since comfy-cli can manage several comfyui installs, it should install into environments per each install. Hence the below logic:
- If
.venv/venvis present in comfyui folder, use that. - If a Conda environment is currently active, use that.
- Create
.venvusing the currently active Python in--copiesmode to prevent broken symlinks if user were to later delete that Python version.
I have thus far tested only on Linux, but I assume it should work for MacOS and Windows too. That said, I only tested if comfy install and comfy launch work as expected.
I tried to selectively change sys.executable to use the venv where appropriate. However, as I am new to this codebase, I might have missed out some places or changed some places I should not, so I need help to check that. The riskiest part, comfy standalone seems to be broken for me before I made my changes, so I can't tell if I may have broke that.
Also, while this approach works perfectly fine for venvs, it is limited for Conda environments. Since it doesn't properly activate Conda, tools installed in the Conda environment like nvcc aren't available as expected. I think this can be solved as a separate issue.
Fixed the merge conflicts; Haven't tested if the PR still works on any of Linux, Mac or Windows though cause its been a while since I last used comfyui. Change from draft to open to hopefully increase visibility. Am open to fixing any new bugs since June.
bump