o
    4ѹg                     @   sB   d dl Zd dl Zd dlZd dlZd dlZdd ZdefddZdS )    Nc                 C   s@   |  dd dd}tj|| }tj|}|j| |S )u   
    从给定的文件路径动态加载模块。

    :param file_path: 模块文件的绝对路径。
    :return: 加载的模块
    /.py N)splitreplace	importlibutilspec_from_file_locationmodule_from_specloaderexec_module)	file_pathmodule_namespecmodule r   _/Users/admin/.pyenv/versions/3.10.0/lib/python3.10/site-packages/funasr/utils/dynamic_import.pyload_module_from_path	   s
   r   r   c              
   C   s   |  drddlm} || } tj| }| dd dd}t|dk r(d	}t	j
| zt| td
|   W d S  tyZ } ztd|  d|  W Y d }~d S d }~ww )Nhttpr   )download_from_urlr   r   r   r      z./z"Loading remote code successfully: zLoading remote code failed: z, )
startswithZfunasr.download.filer   ospathdirnamer   r   lensysappendr   import_moduleprint	Exception)r   r   Zfile_dirr   er   r   r   import_module_from_path   s   

"r#   )	importlib.utilr   inspectos.pathr   r   r   strr#   r   r   r   r   <module>   s    