o
    di                     @   s|   d dl Z d dlZd dlZejdkrd dl mZ nd dlZd dlmZmZ ddl	m
Z
 eeZdedefd	d
Zdd ZdS )    N)      )metadata)	find_specmodule_from_spec   )is_onnxruntime_available	namespacemodulec           	      C   s   t  D ]p}|jd }|du rq||  dkrq||  ds!q|dd}| d| }|tjv r4qt|}|du r=qzt|}|tj|< |j	
| td|  W q tyt } ztd| d| d W Y d}~qd}~ww dS )	a  Load modules with a specific name inside a namespace

    This method operates on namespace packages:
    https://packaging.python.org/en/latest/guides/packaging-namespace-packages/

    For each package inside the specified `namespace`, it looks for the specified `module` and loads it.

    Args:
        namespace (`str`):
            The namespace containing modules to be loaded.
        module (`str`):
            The name of the module to load in each namespace package.
    NameNz
-benchmark-.zSuccessfully loaded z#An exception occured while loading z: )importlib_metadatadistributionsr   
startswithreplacesysmodulesr   r   loaderexec_moduleloggerdebug	Exceptionerror)	r	   r
   dist	dist_namepackage_import_namemodule_import_namebackend_specimported_modulee r!   a/lsinfo/ai/hellotax_ai/llm_service/venv_embed/lib/python3.10/site-packages/optimum/subpackages.pyload_namespace_modules!   s2   


$r#   c                  C   s2   d} t d|  d|  }t rtj|dd dS dS )zLoad optimum subpackages

    This method goes through packages inside the `optimum` namespace and loads the `subpackage` module if it exists.

    This module is then in charge of registering the subpackage commands.
    
subpackageoptimumr   zoptimum.onnxruntime)packageN)r#   r   	importlibimport_module)SUBPACKAGE_LOADERloader_namer!   r!   r"   load_subpackagesH   s   
r+   )r'   loggingr   version_infor   r   importlib.utilr   r   utilsr   	getLogger__name__r   strr#   r+   r!   r!   r!   r"   <module>   s   

'