规范

pyproject.toml 文件包含两个主要的 ComfyUI 自定义节点部分:[project][tool.comfy]。以下是每个部分的规范。

[project] 部分

name(必需)

节点 ID 唯一标识自定义节点,并将用于注册表中的 URL。用户可以通过引用此名称来安装节点:

comfy node install <node-id>

要求:

  • 必须小于 100 个字符
  • 只能包含字母、数字、连字符、下划线和句点
  • 不能有连续的特殊字符
  • 不能以数字或特殊字符开头
  • 不区分大小写比较

最佳实践:

  • 使用简短、描述性的名称
  • 不要在名称中包含 “ComfyUI”
  • 使其易于记忆和输入

Examples:

name = "image-processor"      # ✅ Good: Simple and clear
name = "super-resolution"     # ✅ Good: Describes functionality
name = "ComfyUI-enhancer"    # ❌ Bad: Includes ComfyUI
name = "123-tool"            # ❌ Bad: Starts with number

更多详细信息,请参阅官方 Python 文档

version(必需)

使用 语义化版本控制 并包含三个数字的版本号 X.Y.Z:

  • X(MAJOR):重大更改
  • Y(MINOR):新功能(向后兼容)
  • Z (PATCH): Bug fixes

Examples:

version = "1.0.0"    # 初始版本
version = "1.1.0"    # 添加新功能
version = "1.1.1"    # 修复错误
version = "2.0.0"    # 重大更改

license(可选)

指定自定义节点的许可证。可以以两种方式指定:

  1. 文件引用:
license = { file = "LICENSE" }     # ✅ 指向 LICENSE 文件
license = { file = "LICENSE.txt" } # ✅ 指向 LICENSE.txt 文件
license = "LICENSE"                # ❌ 格式错误
  1. 许可证名称:
license = { text = "MIT License" }  # ✅ 正确格式
license = { text = "Apache-2.0" }   # ✅ 正确格式
license = "MIT LICENSE"             # ❌ 格式错误

常见许可证:MIT, GPL, Apache

description(推荐)

自定义节点的简要描述。

description = "A super resolution node for enhancing image quality"

urls(推荐)

相关资源的链接:

[project.urls]
Repository = "https://github.com/username/repository"
Documentation = "https://github.com/username/repository/wiki"
"Bug Tracker" = "https://github.com/username/repository/issues"

requires-python(推荐)

指定自定义节点支持的 Python 版本:

requires-python = ">=3.8"        # Python 3.8 或更高版本
requires-python = ">=3.8,<3.11"  # Python 3.8 到 3.11 之间(不包括 3.11)

classifiers(推荐)

使用分类器指定操作系统的兼容性和其他元数据。最相关的操作系统分类器是:

[project]
classifiers = [
    # 适用于所有操作系统的节点
    "Operating System :: OS Independent",

    # 或者对于特定操作系统的节点,指定支持的系统:
    "Operating System :: Microsoft :: Windows",  # Windows specific
    "Operating System :: POSIX :: Linux",  # Linux specific
    "Operating System :: MacOS",  # macOS specific
    
    # 如果需要,您可以更具体地指定
    "Operating System :: Microsoft :: Windows :: Windows 10",
    "Operating System :: POSIX :: Linux :: Ubuntu",
    "Operating System :: MacOS :: MacOS X",
]

常见组合:

# 适用于所有操作系统的节点
classifiers = [
    "Operating System :: OS Independent",
]

# 适用于仅 Windows 的节点
classifiers = [
    "Operating System :: Microsoft :: Windows",
    "Operating System :: Microsoft :: Windows :: Windows 10",
]

# 适用于特定操作系统组合的节点(例如,仅 Linux 和 macOS)
classifiers = [
    "Operating System :: POSIX :: Linux",
    "Operating System :: MacOS",
]

查看PyPI上所有有效的分类器。

[tool.comfy] 部分

PublisherId(必需)

你的唯一发布者标识符,通常与您的 GitHub 用户名匹配。

Examples:

PublisherId = "john-doe"        # ✅ 匹配 GitHub 用户名
PublisherId = "image-wizard"    # ✅ 唯一标识符

DisplayName(可选)

你的自定义节点的用户友好名称。

DisplayName = "Super Resolution Node"

Icon(可选)

你的自定义节点的图标 URL。

要求:

  • 文件类型:SVG, PNG, JPG, 或 GIF
  • 最大分辨率:800px × 400px
Icon = "https://raw.githubusercontent.com/username/repo/main/icon.png"

完整示例

[project]
name = "super-resolution-node"
version = "1.0.0"
description = "Enhance image quality using advanced super resolution techniques"
license = { file = "LICENSE" }
requires-python = ">=3.8"
classifiers = [
    "Operating System :: OS Independent"  # Works on all operating systems
]
dynamic = ["dependencies"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[project.urls]
Repository = "https://github.com/username/super-resolution-node"
Documentation = "https://github.com/username/super-resolution-node/wiki"
"Bug Tracker" = "https://github.com/username/super-resolution-node/issues"

[tool.comfy]
PublisherId = "image-wizard"
DisplayName = "Super Resolution Node"
Icon = "https://raw.githubusercontent.com/username/super-resolution-node/main/icon.png"