11import os
2+ import re
23import subprocess
34from typing import Optional
45
@@ -87,6 +88,84 @@ 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+
98+ valid_os_prefixes = {"Microsoft" , "POSIX" , "MacOS" , "OS Independent" }
99+ has_invalid_os = False
100+
101+ for os_value in os_values :
102+ if not any (os_value .startswith (prefix ) for prefix in valid_os_prefixes ):
103+ has_invalid_os = True
104+ break
105+
106+ if has_invalid_os :
107+ typer .echo (
108+ 'Warning: Invalid Operating System classifier found. Operating System classifiers must start with one of: "Microsoft", "POSIX", "MacOS", "OS Independent". '
109+ 'Examples: "Operating System :: Microsoft :: Windows", "Operating System :: POSIX :: Linux", "Operating System :: MacOS", "Operating System :: OS Independent". '
110+ 'No OS information will be populated.'
111+ )
112+ return []
113+ else :
114+ return os_values
115+
116+
117+ def validate_and_extract_accelerator_classifiers (classifiers : list ) -> list :
118+ accelerator_classifiers = [c for c in classifiers if c .startswith ("Environment ::" )]
119+ if not accelerator_classifiers :
120+ return []
121+
122+ accelerator_values = [c [len ("Environment :: " ):] for c in accelerator_classifiers ]
123+
124+ valid_accelerators = {
125+ "GPU :: NVIDIA CUDA" ,
126+ "GPU :: AMD ROCm" ,
127+ "GPU :: Intel Arc" ,
128+ "NPU :: Huawei Ascend" ,
129+ "GPU :: Apple Metal" ,
130+ }
131+ has_invalid_accelerator = False
132+
133+ for accelerator_value in accelerator_values :
134+ if accelerator_value not in valid_accelerators :
135+ has_invalid_accelerator = True
136+ break
137+
138+ if has_invalid_accelerator :
139+ typer .echo (
140+ 'Warning: Invalid Environment classifier found. Environment classifiers must be one of: '
141+ '"Environment :: GPU :: NVIDIA CUDA", "Environment :: GPU :: AMD ROCm", "Environment :: GPU :: Intel Arc", '
142+ '"Environment :: NPU :: Huawei Ascend", "Environment :: GPU :: Apple Metal". '
143+ 'No accelerator information will be populated.'
144+ )
145+ return []
146+ else :
147+ return accelerator_values
148+
149+
150+ def validate_version (version : str , field_name : str ) -> str :
151+ if not version :
152+ return version
153+
154+ version_pattern = r'^(?:(==|>=|<=|!=|~=|>|<|<>|=)\s*)?(\d+\.\d+\.\d+(?:-[a-zA-Z0-9]+)?)?$'
155+
156+ if not re .match (version_pattern , version ):
157+ typer .echo (
158+ f'Warning: Invalid { field_name } format: "{ version } ". '
159+ f'Version must follow the pattern: [operator][version] where operator is optional (==, >=, <=, !=, ~=, >, <, <>, =) '
160+ f'and version is in format major.minor.patch[-suffix]. '
161+ f'Examples: ">=1.0.0", "==2.1.0-beta", "1.5.2". '
162+ f'No { field_name } will be populated.'
163+ )
164+ return ""
165+
166+ return version
167+
168+
90169def initialize_project_config ():
91170 create_comfynode_config ()
92171
@@ -157,6 +236,26 @@ def extract_node_configuration(
157236 urls_data = project_data .get ("urls" , {})
158237 comfy_data = data .get ("tool" , {}).get ("comfy" , {})
159238
239+ dependencies = project_data .get ("dependencies" , [])
240+ supported_comfyui_frontend_version = ""
241+ for dep in dependencies :
242+ if isinstance (dep , str ) and dep .startswith ("comfyui-frontend-package" ):
243+ supported_comfyui_frontend_version = dep
244+ break
245+
246+ # Remove the ComfyUI-frontend dependency from the dependencies list
247+ dependencies = [
248+ dep for dep in dependencies if not (isinstance (dep , str ) and dep .startswith ("comfyui-frontend-package" ))
249+ ]
250+
251+ supported_comfyui_version = data .get ("tool" , {}).get ("requires-comfyui" , "" )
252+
253+ classifiers = project_data .get ("classifiers" , [])
254+ supported_os = validate_and_extract_os_classifiers (classifiers )
255+ supported_accelerators = validate_and_extract_accelerator_classifiers (classifiers )
256+ supported_comfyui_version = validate_version (supported_comfyui_version , "requires-comfyui" )
257+ supported_comfyui_frontend_version = validate_version (supported_comfyui_frontend_version , "comfyui-frontend-package" )
258+
160259 license_data = project_data .get ("license" , {})
161260 if isinstance (license_data , str ):
162261 license = License (text = license_data )
@@ -182,14 +281,18 @@ def extract_node_configuration(
182281 description = project_data .get ("description" , "" ),
183282 version = project_data .get ("version" , "" ),
184283 requires_python = project_data .get ("requires-python" , "" ),
185- dependencies = project_data . get ( " dependencies" , []) ,
284+ dependencies = dependencies ,
186285 license = license ,
187286 urls = URLs (
188287 homepage = urls_data .get ("Homepage" , "" ),
189288 documentation = urls_data .get ("Documentation" , "" ),
190289 repository = urls_data .get ("Repository" , "" ),
191290 issues = urls_data .get ("Issues" , "" ),
192291 ),
292+ supported_os = supported_os ,
293+ supported_accelerators = supported_accelerators ,
294+ supported_comfyui_version = supported_comfyui_version ,
295+ supported_comfyui_frontend_version = supported_comfyui_frontend_version ,
193296 )
194297
195298 comfy = ComfyConfig (
0 commit comments