|
11 | 11 | PyProjectSettings
|
12 | 12 | )
|
13 | 13 |
|
| 14 | +def validate_and_extract_os_classifiers(classifiers: list) -> list: |
| 15 | + os_classifiers = [c for c in classifiers if c.startswith("Operating System :: ")] |
| 16 | + if not os_classifiers: |
| 17 | + return [] |
| 18 | + |
| 19 | + os_values = [c[len("Operating System :: ") :] for c in os_classifiers] |
| 20 | + valid_os_prefixes = {"Microsoft", "POSIX", "MacOS", "OS Independent"} |
| 21 | + |
| 22 | + for os_value in os_values: |
| 23 | + if not any(os_value.startswith(prefix) for prefix in valid_os_prefixes): |
| 24 | + return [] |
| 25 | + |
| 26 | + return os_values |
| 27 | + |
| 28 | + |
| 29 | +def validate_and_extract_accelerator_classifiers(classifiers: list) -> list: |
| 30 | + accelerator_classifiers = [c for c in classifiers if c.startswith("Environment ::")] |
| 31 | + if not accelerator_classifiers: |
| 32 | + return [] |
| 33 | + |
| 34 | + accelerator_values = [c[len("Environment :: ") :] for c in accelerator_classifiers] |
| 35 | + |
| 36 | + valid_accelerators = { |
| 37 | + "GPU :: NVIDIA CUDA", |
| 38 | + "GPU :: AMD ROCm", |
| 39 | + "GPU :: Intel Arc", |
| 40 | + "NPU :: Huawei Ascend", |
| 41 | + "GPU :: Apple Metal", |
| 42 | + } |
| 43 | + |
| 44 | + for accelerator_value in accelerator_values: |
| 45 | + if accelerator_value not in valid_accelerators: |
| 46 | + return [] |
| 47 | + |
| 48 | + return accelerator_values |
| 49 | + |
| 50 | + |
14 | 51 | """
|
15 | 52 | Extract configuration from a custom node directory's pyproject.toml file or a Python file.
|
16 | 53 |
|
@@ -78,6 +115,24 @@ def extract_node_configuration(path) -> Optional[PyProjectConfig]:
|
78 | 115 | tool_data = raw_settings.tool
|
79 | 116 | comfy_data = tool_data.get("comfy", {}) if tool_data else {}
|
80 | 117 |
|
| 118 | + dependencies = project_data.get("dependencies", []) |
| 119 | + supported_comfyui_frontend_version = "" |
| 120 | + for dep in dependencies: |
| 121 | + if isinstance(dep, str) and dep.startswith("comfyui-frontend-package"): |
| 122 | + supported_comfyui_frontend_version = dep.removeprefix("comfyui-frontend-package") |
| 123 | + break |
| 124 | + |
| 125 | + supported_comfyui_version = comfy_data.get("requires-comfyui", "") |
| 126 | + |
| 127 | + classifiers = project_data.get('classifiers', []) |
| 128 | + supported_os = validate_and_extract_os_classifiers(classifiers) |
| 129 | + supported_accelerators = validate_and_extract_accelerator_classifiers(classifiers) |
| 130 | + |
| 131 | + project_data['supported_os'] = supported_os |
| 132 | + project_data['supported_accelerators'] = supported_accelerators |
| 133 | + project_data['supported_comfyui_frontend_version'] = supported_comfyui_frontend_version |
| 134 | + project_data['supported_comfyui_version'] = supported_comfyui_version |
| 135 | + |
81 | 136 | return PyProjectConfig(project=project_data, tool_comfy=comfy_data)
|
82 | 137 |
|
83 | 138 |
|
|
0 commit comments