o
    g7                     @   s>   d Z ddlZddlZddlZdd Zdd Ze \ZZZ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 rtd| d d S d S |dkrd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)   ^/var/www/visachat/venv/lib/python3.10/site-packages/onnxruntime/capi/onnxruntime_validation.pycheck_distro_info   sL   




r+   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 ddd |rzjddlm dd	lm	 zdd
lm
  W n	 typ   Y nw  rzddlm W n ty   td d Y nw  fdd}ddlm} |d d}r|r|vr|  td td|  n	 W n ty } ztd t| W Y d }~nd }~ww | r| | fS )NFr   )	ORTModuleT)ORTModuleInitExceptionr   r   )__version__)package_name)cuda_version)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)   r0   r1   r/   versionr)   r*   print_build_package_infoz   s   z=validate_build_package_info.<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.ortmoduler,   ImportError	Exception(onnxruntime.training.ortmodule._fallbackr-   
isinstancebuild_and_package_infor.   r/   r0   r1   r   r   /onnxruntime.capi.onnxruntime_collect_build_infor5   print)import_ortmodule_exceptionhas_ortmoduler,   er-   r4   r5   local_cudart_versionsr)   r2   r*   validate_build_package_infoF   sr   



rD   )
__doc__r   r   r   r+   rD   rA   r/   r3   r0   r)   r)   r)   r*   <module>   s   9P