o
    ;ήc/                     @   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r)|} t   }|dkr'td|  d S d S |dkrb	 t|ddd	 } t|d
dd }| sXt|ddd	 } t|ddd	 }|  } | }d S |dkr|} t   }t|	dd dk rtd|  d S d S td|  d S )N z/etc/os-releasez/etc/lsb-releasewindows10zSUnsupported Windows version (%s). ONNX Runtime supports Windows 10 and above, only.linux                     darwin.r   zJUnsupported macOS version (%s). ONNX Runtime supports macOS 11.0 or later.zZUnsupported platform (%s). ONNX Runtime supports Linux, macOS and Windows platforms, only.)
platformsystemlowerreleasewarningswarn	linecachegetlineintsplit)__my_distro____my_distro_ver____my_system____OS_RELEASE_FILE____LSB_RELEASE_FILE__ r    N/tmp/pip-target-vg8gfxp4/lib/python/onnxruntime/capi/onnxruntime_validation.pycheck_distro_info   sF   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 |rz_ddlm dd	lm	 zdd
lm
  W n   Y  rzddlm W n   td d Y  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                      s<   t d  t d  t d   t d  d S )Nz3onnxruntime training package info: package_name: %sz2onnxruntime training package info: __version__: %sz3onnxruntime training package info: cuda_version: %sz*onnxruntime build info: cudart_version: %s)r   r   r    r'   r(   r&   versionr    r!   print_build_package_infou   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: %sz=WARNING: failed to collect onnxruntime version and build info)onnxruntime.training.ortmoduler#   ImportError	Exception(onnxruntime.training.ortmodule._fallbackr$   
isinstancebuild_and_package_infor%   r&   r'   r(   r   r   /onnxruntime.capi.onnxruntime_collect_build_infor,   print)import_ortmodule_exceptionhas_ortmoduler#   er$   r+   r,   local_cudart_versionsr    r)   r!   validate_build_package_infoA   sn   



r;   )
__doc__r   r   r   r"   r;   r8   r&   r*   r'   r    r    r    r!   <module>   s   4P