feat: comfyui create venv as needed #282
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #263, #272.
As comfy-cli might be installed globally via
pipxoruv, 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:.venv/venvis present in comfyui folder, use that..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 installandcomfy launchwork as expected.I tried to selectively change
sys.executableto 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 standaloneseems 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
nvccaren't available as expected. I think this can be solved as a separate issue.