U
    U?hG                     @   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   s  d} d}t   }d}d}|dkrP|} t   }|dkrNtd| d n|dkrt|d	d	d
 } t|ddd }| st|ddd
 } t|ddd
 }|  } | }nX|dkr|} t   }t|	dd dk rtd| d ntd| d d S )N z/etc/os-releasez/etc/lsb-releasewindows)10Z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.zUnsupported platform (zB). ONNX Runtime supports Linux, macOS and Windows platforms, only.)
platformsystemlowerreleasewarningswarn	linecachegetlineintsplit)Z__my_distro__Z__my_distro_ver__Z__my_system__Z__OS_RELEASE_FILE__Z__LSB_RELEASE_FILE__ r   Y/var/www/html/venv/lib/python3.8/site-packages/onnxruntime/capi/onnxruntime_validation.pycheck_distro_info   s<    
	



r   c                     s  d } d}zddl m} d}W nx tk
r4   d}Y nb tk
r } zDzddlm} t||r`d}W n tk
rz   d}Y nX |s|} W 5 d }~X Y nX ddd |rzddlm dd	lm	 zdd
lm
  W n tk
r   Y nX  rzddlm W n$ tk
r"   td d Y nX  fdd}ddlm} |d d}r|r|kr|  td td|  n W n6 tk
r } ztd t| W 5 d }~X Y nX | 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   r"   r#   r!   versionr   r   print_build_package_infot   s    z=validate_build_package_info.<locals>.print_build_package_info)find_cudart_versions)	build_envZ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)Zonnxruntime.training.ortmoduler   ImportError	ExceptionZ(onnxruntime.training.ortmodule._fallbackr   
isinstanceZbuild_and_package_infor    r!   r"   r#   r   r   Z/onnxruntime.capi.onnxruntime_collect_build_infor'   print)Zimport_ortmodule_exceptionhas_ortmoduler   er   r&   r'   Zlocal_cudart_versionsr   r$   r   validate_build_package_info@   s^    





r/   )
__doc__r   r   r   r   r/   r-   r!   r%   r"   r   r   r   r   <module>   s   3P