[GH-ISSUE #2] Making custom nodes installable via pip #3

Closed
opened 2026-10-27 21:08:31 +00:00 by bsakaguchi · 5 comments
Owner

Originally created by @Chaoses-Ib on GitHub (Jun 14, 2024).
Original GitHub issue: https://github.com/Comfy-Org/Comfy-PR/issues/2

I noticed that this project is adding pyproject.toml to a lot of custom nodes. I'd like to ask if you are also interested in making custom nodes installable via pip. I've done some research about this and found that by using some special options in pyproject.toml, most custom nodes can be packaged and uploaded to PyPI without changing the project structure. Adding this to Comfy-PR should be simple since it's just adding more text to pyproject.toml and it's compatible with ComfyUI Registry.

For example, adding the following content to a custom node:

[project]
# CHANGE: The project name
name = "ComfyUI_Ib_CustomNodes"
version = "0.1.0"
# description = '...'
readme = "README.md"
# requires-python = ">=3.8"
# license = "MIT"
keywords = ["comfyui"]
dynamic = ["dependencies"]

[project.urls]
# CHANGE: Homepage, mostly the GitHub repository
Homepage = "https://github.com/Chaoses-Ib/ComfyUI_Ib_CustomNodes"
comfyui-legacy = "https://github.com/Chaoses-Ib/comfyui-legacy"

[build-system]
requires = ["hatchling", "hatch-requirements-txt"]
build-backend = "hatchling.build"

[tool.hatch.metadata.hooks.requirements_txt]
# CHANGE: Remove this section if there is no requirements.txt
files = ["requirements.txt"]

[tool.hatch.build.targets.sdist]
packages = ["."]

[tool.hatch.build.targets.wheel]
packages = ["."]
exclude = [
  "*.md",
  "/images",
  "/docs",
  "/examples",
  "/workflow_examples",
  "/tests",
]

[tool.hatch.build.targets.sdist.sources]
# CHANGE: Package name. Must be an valid Python id (no dashes)
"." = "ComfyUI_Ib_CustomNodes"

[tool.hatch.build.targets.wheel.sources]
# CHANGE: Same as above
"." = "ComfyUI_Ib_CustomNodes"

[project.entry-points."comfyui_legacy.custom_nodes"]
# CHANGE: Same as above
ComfyUI_Ib_CustomNodes = "ComfyUI_Ib_CustomNodes"

Then the custom node can be installed via pip:

pip install git+https://github.com/Chaoses-Ib/ComfyUI_Ib_CustomNodes.git

One problem with this is ComfyUI won't look up nodes installed via pip. This can be solved by installing a special custom node to loading them. This is already done in ComfyScript, but if you're interested, I can split the related code to a separate repo.

I've already done this change to some custom nodes, including:

Originally created by @Chaoses-Ib on GitHub (Jun 14, 2024). Original GitHub issue: https://github.com/Comfy-Org/Comfy-PR/issues/2 I noticed that this project is adding `pyproject.toml` to a lot of custom nodes. I'd like to ask if you are also interested in making custom nodes installable via pip. I've done some research about this and found that by using some special options in `pyproject.toml`, most custom nodes can be packaged and uploaded to PyPI without changing the project structure. Adding this to Comfy-PR should be simple since it's just adding more text to `pyproject.toml` and it's compatible with ComfyUI Registry. For example, adding the following content to a custom node: ```toml [project] # CHANGE: The project name name = "ComfyUI_Ib_CustomNodes" version = "0.1.0" # description = '...' readme = "README.md" # requires-python = ">=3.8" # license = "MIT" keywords = ["comfyui"] dynamic = ["dependencies"] [project.urls] # CHANGE: Homepage, mostly the GitHub repository Homepage = "https://github.com/Chaoses-Ib/ComfyUI_Ib_CustomNodes" comfyui-legacy = "https://github.com/Chaoses-Ib/comfyui-legacy" [build-system] requires = ["hatchling", "hatch-requirements-txt"] build-backend = "hatchling.build" [tool.hatch.metadata.hooks.requirements_txt] # CHANGE: Remove this section if there is no requirements.txt files = ["requirements.txt"] [tool.hatch.build.targets.sdist] packages = ["."] [tool.hatch.build.targets.wheel] packages = ["."] exclude = [ "*.md", "/images", "/docs", "/examples", "/workflow_examples", "/tests", ] [tool.hatch.build.targets.sdist.sources] # CHANGE: Package name. Must be an valid Python id (no dashes) "." = "ComfyUI_Ib_CustomNodes" [tool.hatch.build.targets.wheel.sources] # CHANGE: Same as above "." = "ComfyUI_Ib_CustomNodes" [project.entry-points."comfyui_legacy.custom_nodes"] # CHANGE: Same as above ComfyUI_Ib_CustomNodes = "ComfyUI_Ib_CustomNodes" ``` Then the custom node can be installed via pip: ```sh pip install git+https://github.com/Chaoses-Ib/ComfyUI_Ib_CustomNodes.git ``` One problem with this is ComfyUI won't look up nodes installed via pip. This can be solved by installing a special custom node to loading them. This is already done in [ComfyScript](https://github.com/Chaoses-Ib/ComfyScript), but if you're interested, I can split the related code to a separate repo. I've already done this change to some custom nodes, including: - [civitai_comfy_nodes](https://pypi.org/project/civitai_comfy_nodes/) - [comfyui-tooling-nodes](https://pypi.org/project/comfyui-tooling-nodes/) - [ComfyUI_Ib_CustomNodes](https://pypi.org/project/ComfyUI_Ib_CustomNodes/)
Author
Owner

@snomiao commented on GitHub (Jun 14, 2024):

@yoland68 Could you help me check this out?

<!-- gh-comment-id:2167873690 --> @snomiao commented on GitHub (Jun 14, 2024): @yoland68 Could you help me check this out?
Author
Owner

@telamonian commented on GitHub (Jun 14, 2024):

@Chaoses-Ib There are already several efforts underway to do just this in ComfyUI core. My (completely unbiased, of course) preference is for https://github.com/comfyanonymous/ComfyUI/pull/3608. In general, I do think it would be best to reuse as much of the existing Python machinery as possible, such as using the entry_point mechanism to do the node finding/loading. Please see also CEP 1.

<!-- gh-comment-id:2168212826 --> @telamonian commented on GitHub (Jun 14, 2024): @Chaoses-Ib There are already several efforts underway to do just this in ComfyUI core. My (completely unbiased, of course) preference is for https://github.com/comfyanonymous/ComfyUI/pull/3608. In general, I do think it would be best to reuse as much of the existing Python machinery as possible, such as using the `entry_point` mechanism to do the node finding/loading. Please see also [CEP 1](https://github.com/telamonian/ComfyUI/blob/installer_script/comfy_enhancement_proposal_1.md).
Author
Owner

@Chaoses-Ib commented on GitHub (Jun 14, 2024):

Nice PR. I know https://github.com/comfyanonymous/ComfyUI/pull/298 has done something similar, but it has changed too many things and I'm afraid it'll never be merged. It'll be nice to see this kind of mechanism being merged one day.

In general, I do think it would be best to reuse as much of the existing Python machinery as possible

I have the same idea. That's why I'm here to ask whether you are willing to add this. I think it will be easier to first add this to custom nodes instead of changing their project structure, since that will break the old and current version of ComfyUI.

<!-- gh-comment-id:2168526349 --> @Chaoses-Ib commented on GitHub (Jun 14, 2024): Nice PR. I know https://github.com/comfyanonymous/ComfyUI/pull/298 has done something similar, but it has changed too many things and I'm afraid it'll never be merged. It'll be nice to see this kind of mechanism being merged one day. > In general, I do think it would be best to reuse as much of the existing Python machinery as possible I have the same idea. That's why I'm here to ask whether you are willing to add this. I think it will be easier to first add this to custom nodes instead of changing their project structure, since that will break the old and current version of ComfyUI.
Author
Owner

@Le09 commented on GitHub (Aug 15, 2024):

It would be nice to eventually have ComfyUI and custom nodes installable via pip. Right now there are a number of ways that deviate from the standard that are a bit confusing to get into. And maybe more importantly it causes a proliferation of ad-hoc solutions.

<!-- gh-comment-id:2291747465 --> @Le09 commented on GitHub (Aug 15, 2024): It would be nice to eventually have ComfyUI and custom nodes installable via pip. Right now there are a number of ways that deviate from the standard that are a bit confusing to get into. And maybe more importantly it causes a proliferation of ad-hoc solutions.
Author
Owner

@snomiao commented on GitHub (May 15, 2026):

We are not likey to support this officially, but feel free to share more here if anyone still wants it.

<!-- gh-comment-id:4461361559 --> @snomiao commented on GitHub (May 15, 2026): We are not likey to support this officially, but feel free to share more here if anyone still wants it.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Comfy-Org/Comfy-PR#3
No description provided.