o
    °ƒðj7  ã                   @   s8   d Z ddlZddlZddlZdd„ Zdd„ Zdd„ ZdS )	z9
Check OS requirements for ONNX Runtime Python Bindings.
é    Nc            	      C   sZ  d} d}t  ¡  ¡ }d}d}|dkr+|} t  ¡  ¡ }|dvr)t d|› d�¡ d S d S |dkrd	 t |d	¡d	d
… } t |d¡dd… }| sZt |d¡dd
… } t |d¡dd
… }|  ¡ } | ¡ }d S |dkrˆ|} t  ¡  ¡ }t| 	d¡d ƒdk r†t d|› d�¡ d S d S |dkr¢dd l
}| d¡}| d¡}|d d	… }d S t d|› d�¡ d S )NÚ z/etc/os-releasez/etc/lsb-releaseÚwindows)Ú10Ú11zUnsupported Windows version (z4). ONNX Runtime supports Windows 10 and above, only.Úlinuxé   éÿÿÿÿé   é   éþÿÿÿé   é   é   é   ÚdarwinÚ.r   zUnsupported macOS version (z-). ONNX Runtime supports macOS 11.0 or later.ÚaixÚoslevelzutf-8zUnsupported platform (zG). ONNX Runtime supports Linux, macOS, AIX and Windows platforms, only.)ÚplatformÚsystemÚlowerÚreleaseÚwarningsÚwarnÚ	linecacheÚgetlineÚintÚsplitÚ
subprocessÚcheck_outputÚdecode)	Ú__my_distro__Ú__my_distro_ver__Ú__my_system__Ú__OS_RELEASE_FILE__Ú__LSB_RELEASE_FILE__r   Úreturned_outputÚ__my_distro_ver__strÚ__my_distro_ver© r)   ú©/tmp/claude-1000/-var-www-html-academy/3f42efd1-c2b7-4d08-9b05-30d86bb35479/scratchpad/piper/venv/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_validation.pyÚcheck_distro_info   sL   
ÿÿ
ÿÿ


ÿr+   c               
   C   sŽ   d} d}d}z ddl m} ddl m}  zddl m} W n	 ty$   Y nw W n tyA } zt d¡ t|ƒ W Y d }~nd }~ww | ||fS )Nr   r   )Ú__version__)Úpackage_name)Úcuda_versionz8WARNING: failed to collect package name and version info)	Úbuild_and_package_infor,   r-   r.   ÚImportErrorÚ	Exceptionr   r   Úprint)r-   Úversionr.   Úer)   r)   r*   Ú!get_package_name_and_version_infoG   s$   þ€
€þ
r5   c                     s„  d } d}z
ddl m} d}W n; ty   d}Y n1 tyI } z%zddlm} t||ƒr.d}W n ty:   d}Y nw |s?|} W Y d }~nd }~ww tƒ \‰‰‰ |r¸ˆ r¸zHzddlm	‰ W n tym   t
 d¡ d ‰Y nw ‡ ‡‡‡fd	d
„}ddlm} |dˆ d�}ˆr›|r›ˆ|vr›|ƒ  t
 d¡ t
 d|› �¡ W n ty· } zt
 d¡ t|ƒ W Y d }~nd }~ww | r¼| ‚|ˆˆˆ fS )NFr   )Ú	ORTModuleT)ÚORTModuleInitExceptionr   )Úcudart_versionzBWARNING: failed to get cudart_version from onnxruntime build info.c                      sD   t  dˆ› �¡ t  dˆ› �¡ t  dˆ › �¡ t  dˆ› �¡ d S )Nz1onnxruntime training package info: package_name: z0onnxruntime training package info: __version__: z1onnxruntime training package info: cuda_version: z(onnxruntime build info: cudart_version: )r   r   r)   ©r.   r8   r-   r3   r)   r*   Úprint_build_package_info…   s   z7check_training_module.<locals>.print_build_package_info)Úfind_cudart_versions)Ú	build_envÚbuild_cuda_versionzJWARNING: failed to find cudart version that matches onnxruntime build infoz WARNING: found cudart versions: z=WARNING: failed to collect onnxruntime version and build info)Úonnxruntime.training.ortmoduler6   r0   r1   Ú(onnxruntime.training.ortmodule._fallbackr7   Ú
isinstancer5   r/   r8   r   r   Ú/onnxruntime.capi.onnxruntime_collect_build_infor;   r2   )Úimport_ortmodule_exceptionÚhas_ortmoduler6   r4   r7   r:   r;   Úlocal_cudart_versionsr)   r9   r*   Úcheck_training_module\   sZ   
€þ€ñ
þ
€
€þrE   )Ú__doc__r   r   r   r+   r5   rE   r)   r)   r)   r*   Ú<module>   s   9