11import os
2+ import re
23import subprocess
34from typing import Optional
45
@@ -87,6 +88,76 @@ def sanitize_node_name(name: str) -> str:
8788 return name
8889
8990
91+ def validate_and_extract_os_classifiers (classifiers : list ) -> list :
92+ os_classifiers = [c for c in classifiers if c .startswith ("Operating System :: " )]
93+ if not os_classifiers :
94+ return []
95+
96+ os_values = [c [len ("Operating System :: " ):] for c in os_classifiers ]
97+ valid_os_prefixes = {"Microsoft" , "POSIX" , "MacOS" , "OS Independent" }
98+
99+ for os_value in os_values :
100+ if not any (os_value .startswith (prefix ) for prefix in valid_os_prefixes ):
101+ typer .echo (
102+ 'Warning: Invalid Operating System classifier found. Operating System classifiers must start with one of: "Microsoft", "POSIX", "MacOS", "OS Independent". '
103+ 'Examples: "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Operating System :: MacOS", "Operating System :: OS Independent". '
104+ 'No OS information will be populated.'
105+ )
106+ return []
107+
108+ return os_values
109+
110+
111+ def validate_and_extract_accelerator_classifiers (classifiers : list ) -> list :
112+ accelerator_classifiers = [c for c in classifiers if c .startswith ("Environment ::" )]
113+ if not accelerator_classifiers :
114+ return []
115+
116+ accelerator_values = [c [len ("Environment :: " ):] for c in accelerator_classifiers ]
117+
118+ valid_accelerators = {
119+ "GPU :: NVIDIA CUDA" ,
120+ "GPU :: AMD ROCm" ,
121+ "GPU :: Intel Arc" ,
122+ "NPU :: Huawei Ascend" ,
123+ "GPU :: Apple Metal" ,
124+ }
125+
126+ for accelerator_value in accelerator_values :
127+ if accelerator_value not in valid_accelerators :
128+ typer .echo (
129+ 'Warning: Invalid Environment classifier found. Environment classifiers must be one of: '
130+ '"Environment :: GPU :: NVIDIA CUDA", "Environment :: GPU :: AMD ROCm", "Environment :: GPU :: Intel Arc", '
131+ '"Environment :: NPU :: Huawei Ascend", "Environment :: GPU :: Apple Metal". '
132+ 'No accelerator information will be populated.'
133+ )
134+ return []
135+
136+ return accelerator_values
137+
138+
139+ def validate_version (version : str , field_name : str ) -> str :
140+ if not version :
141+ return version
142+
143+ version_pattern = r'^(?:(==|>=|<=|!=|~=|>|<|<>|=)\s*)?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9]+)?)?$'
144+
145+ version_parts = [part .strip () for part in version .split (',' )]
146+ for part in version_parts :
147+ if not re .match (version_pattern , part ):
148+ typer .echo (
149+ f'Warning: Invalid { field_name } format: "{ version } ". '
150+ f'Each version part must follow the pattern: [operator][version] where operator is optional (==, >=, <=, !=, ~=, >, <, <>, =) '
151+ f'and version is in format major.minor.patch[-suffix]. '
152+ f'Multiple versions can be comma-separated. '
153+ f'Examples: ">=1.0.0", "==2.1.0-beta", "1.5.2", ">=1.0.0,<2.0.0". '
154+ f'No { field_name } will be populated.'
155+ )
156+ return ""
157+
158+ return version
159+
160+
90161def initialize_project_config ():
91162 create_comfynode_config ()
92163
@@ -157,6 +228,26 @@ def extract_node_configuration(
157228 urls_data = project_data .get ("urls" , {})
158229 comfy_data = data .get ("tool" , {}).get ("comfy" , {})
159230
231+ dependencies = project_data .get ("dependencies" , [])
232+ supported_comfyui_frontend_version = ""
233+ for dep in dependencies :
234+ if isinstance (dep , str ) and dep .startswith ("comfyui-frontend-package" ):
235+ supported_comfyui_frontend_version = dep .removeprefix ("comfyui-frontend-package" )
236+ break
237+
238+ # Remove the ComfyUI-frontend dependency from the dependencies list
239+ dependencies = [
240+ dep for dep in dependencies if not (isinstance (dep , str ) and dep .startswith ("comfyui-frontend-package" ))
241+ ]
242+
243+ supported_comfyui_version = data .get ("tool" , {}).get ("requires-comfyui" , "" )
244+
245+ classifiers = project_data .get ("classifiers" , [])
246+ supported_os = validate_and_extract_os_classifiers (classifiers )
247+ supported_accelerators = validate_and_extract_accelerator_classifiers (classifiers )
248+ supported_comfyui_version = validate_version (supported_comfyui_version , "requires-comfyui" )
249+ supported_comfyui_frontend_version = validate_version (supported_comfyui_frontend_version , "comfyui-frontend-package" )
250+
160251 license_data = project_data .get ("license" , {})
161252 if isinstance (license_data , str ):
162253 license = License (text = license_data )
@@ -182,14 +273,18 @@ def extract_node_configuration(
182273 description = project_data .get ("description" , "" ),
183274 version = project_data .get ("version" , "" ),
184275 requires_python = project_data .get ("requires-python" , "" ),
185- dependencies = project_data . get ( " dependencies" , []) ,
276+ dependencies = dependencies ,
186277 license = license ,
187278 urls = URLs (
188279 homepage = urls_data .get ("Homepage" , "" ),
189280 documentation = urls_data .get ("Documentation" , "" ),
190281 repository = urls_data .get ("Repository" , "" ),
191282 issues = urls_data .get ("Issues" , "" ),
192283 ),
284+ supported_os = supported_os ,
285+ supported_accelerators = supported_accelerators ,
286+ supported_comfyui_version = supported_comfyui_version ,
287+ supported_comfyui_frontend_version = supported_comfyui_frontend_version ,
193288 )
194289
195290 comfy = ComfyConfig (
0 commit comments