@@ -328,20 +328,45 @@ async def remove_app_fe_setting(req: AppFeSettingDelReq):
328328
329329 @app .get (f"{ api_base } /version" , dependencies = [Depends (verify_secret )])
330330 async def get_version ():
331- av_version = None
332- try :
333- import av as _av
334- av_version = getattr (_av , "__version__" , None )
335- except Exception :
336- # av (PyAV) not installed or failed to import
337- av_version = None
331+ import sys
332+ import platform
338333
339- return {
334+ def _get_dist_version (dist_name : str = None , module_name : str = None ):
335+ # Try importlib.metadata first (distribution metadata), then fallback to module __version__
336+ try :
337+ if dist_name :
338+ try :
339+ from importlib .metadata import version
340+
341+ return version (dist_name )
342+ except Exception :
343+ pass
344+ if module_name :
345+ mod = __import__ (module_name )
346+ return getattr (mod , "__version__" , None )
347+ if dist_name :
348+ # try importing by normalized name
349+ mod = __import__ (dist_name .replace ("-" , "_" ))
350+ return getattr (mod , "__version__" , None )
351+ except Exception as e :
352+ logger .debug ("Version probe failed for %s/%s: %s" , dist_name , module_name , e )
353+ return None
354+
355+ versions = {
356+ "python_version" : sys .version .splitlines ()[0 ],
357+ "platform" : platform .platform (),
340358 "hash" : get_current_commit_hash (),
341359 "tag" : get_current_tag (),
342- "av_version" : av_version ,
360+ "av" : _get_dist_version ("av" , "av" ),
361+ "imageio" : _get_dist_version ("imageio" , "imageio" ),
362+ "pillow" : _get_dist_version ("Pillow" , "PIL" ),
363+ "imageio_ffmpeg" : _get_dist_version ("imageio-ffmpeg" , "imageio_ffmpeg" ),
364+ "pillow_avif_plugin" : _get_dist_version ("pillow-avif-plugin" , "pillow_avif" ),
343365 }
344366
367+ logger .info ("Version info requested: %s" , {k : v for k , v in versions .items () if v })
368+ return versions
369+
345370 class DeleteFilesReq (BaseModel ):
346371 file_paths : List [str ]
347372
0 commit comments