o
    vZh`-                  
   @   s  U d Z ddlZddlZddlZddlZddlZddlmZm	Z	 ddl
mZmZ ej d dZeed< i Zi ddhd	d	hd
d
hddhddhddhddhddhddhddhddhddhddhddhddhddhddddhiZe D ]#\ZZdee< eD ]Zzejeee< W  n ejjy   Y qw qded efd!d"Zded efd#d$Zd efd%d&Zd efd'd(Zd efd)d*Z d efd+d,Z!d efd-d.Z"d efd/d0Z#d efd1d2Z$d efd3d4Z%d efd5d6Z&d efd7d8Z'd efd9d:Z(d efd;d<Z)d efd=d>Z*d efd?d@Z+d efdAdBZ,d efdCdDZ-d efdEdFZ.d efdGdHZ/d efdIdJZ0d efdKdLZ1d efdMdNZ2d efdOdPZ3d efdQdRZ4d efdSdTZ5d efdUdVZ6d efdWdXZ7d efdYdZZ8d efd[d\Z9d efd]d^Z:d efd_d`Z;d efdadbZ<d efdcddZ=d efdedfZ>d efdgdhZ?d efdidjZ@d efdkdlZAd efdmdnZBz	doeeC v ZDW n eEy   dpZDY nw d efdqdrZFd efdsdtZGd efdudvZHd e	eef fdwdxZIdS )yz0Check presence of installed packages at runtime.    N)AnyDict   )__version__	constants+_PY_VERSIONaiohttpfastaifastapifastcoregradiographvizhf_transferhf_xetjinjaJinja2kerasnumpypillowPillowpydanticpydotsafetensorstensorboardZtensorboardX
tensorflow)
r   ztensorflow-cpuztensorflow-gpuz
tf-nightlyztf-nightly-cpuztf-nightly-gpuzintel-tensorflowzintel-tensorflow-avx512ztensorflow-rocmztensorflow-macostorchN/Apackage_namereturnc                 C   s   t | dS Nr   )_package_versionsgetr    r$   M/var/www/auris/lib/python3.10/site-packages/huggingface_hub/utils/_runtime.py_get_versionJ      r&   c                 C   s   t | dkS r    r&   r#   r$   r$   r%   is_package_availableN   r'   r)   c                   C      t S N)r   r$   r$   r$   r%   get_python_versionS      r,   c                   C   r*   r+   )r   r$   r$   r$   r%   get_hf_hub_versionX   r-   r.   c                   C      t dS Nr	   r)   r$   r$   r$   r%   is_aiohttp_available]      r2   c                   C   r/   r0   r(   r$   r$   r$   r%   get_aiohttp_versiona   r3   r4   c                   C   r/   Nr
   r1   r$   r$   r$   r%   is_fastai_availablef   r3   r6   c                   C   r/   r5   r(   r$   r$   r$   r%   get_fastai_versionj   r3   r7   c                   C   r/   Nr   r1   r$   r$   r$   r%   is_fastapi_availableo   r3   r9   c                   C   r/   r8   r(   r$   r$   r$   r%   get_fastapi_versions   r3   r:   c                   C   r/   Nr   r1   r$   r$   r$   r%   is_fastcore_availablex   r3   r<   c                   C   r/   r;   r(   r$   r$   r$   r%   get_fastcore_version|   r3   r=   c                   C   r/   Nr   r1   r$   r$   r$   r%   is_gradio_available   r3   r?   c                   C   r/   r>   r(   r$   r$   r$   r%   get_gradio_version   r3   r@   c                   C   r/   Nr   r1   r$   r$   r$   r%   is_graphviz_available   r3   rB   c                   C   r/   rA   r(   r$   r$   r$   r%   get_graphviz_version   r3   rC   c                   C   r/   Nr   r1   r$   r$   r$   r%   is_hf_transfer_available   r3   rE   c                   C   r/   rD   r(   r$   r$   r$   r%   get_hf_transfer_version   r3   rF   c                   C   s   t tjdrdS tdS )NZHF_HUB_DISABLE_XETFr   )r   Z_is_trueosenvironr"   r)   r$   r$   r$   r%   is_xet_available   s   rI   c                   C   r/   )Nr   r(   r$   r$   r$   r%   get_xet_version   r3   rJ   c                   C   r/   Nr   r1   r$   r$   r$   r%   is_keras_available   r3   rL   c                   C   r/   rK   r(   r$   r$   r$   r%   get_keras_version   r3   rM   c                   C   r/   Nr   r1   r$   r$   r$   r%   is_numpy_available   r3   rO   c                   C   r/   rN   r(   r$   r$   r$   r%   get_numpy_version   r3   rP   c                   C   r/   Nr   r1   r$   r$   r$   r%   is_jinja_available   r3   rR   c                   C   r/   rQ   r(   r$   r$   r$   r%   get_jinja_version   r3   rS   c                   C   r/   Nr   r1   r$   r$   r$   r%   is_pillow_available   r3   rU   c                   C   r/   rT   r(   r$   r$   r$   r%   get_pillow_version   r3   rV   c                  C   s>   t dsdS z	ddlm}  W dS  ty   td Y dS w )Nr   Fr   	validatorzPydantic is installed but cannot be imported. Please check your installation. `huggingface_hub` will default to not using Pydantic. Error message: '{e}'T)r)   r   rX   ImportErrorwarningswarnrW   r$   r$   r%   is_pydantic_available   s   
r\   c                   C   r/   )Nr   r(   r$   r$   r$   r%   get_pydantic_version   r3   r]   c                   C   r/   Nr   r1   r$   r$   r$   r%   is_pydot_available   r3   r_   c                   C   r/   r^   r(   r$   r$   r$   r%   get_pydot_version   r3   r`   c                   C   r/   Nr   r1   r$   r$   r$   r%   is_tensorboard_available   r3   rb   c                   C   r/   ra   r(   r$   r$   r$   r%   get_tensorboard_version   r3   rc   c                   C   r/   Nr   r1   r$   r$   r$   r%   is_tf_available   r3   re   c                   C   r/   rd   r(   r$   r$   r$   r%   get_tf_version   r3   rf   c                   C   r/   Nr   r1   r$   r$   r$   r%   is_torch_available  r3   rh   c                   C   r/   rg   r(   r$   r$   r$   r%   get_torch_version	  r3   ri   c                   C   r/   )Nr   r1   r$   r$   r$   r%   is_safetensors_available  r3   rj   zgoogle.colabFc                  C   sB   zt  j} | jD ]}|jdkr W dS qW dS  ty    Y dS w )zReturn `True` if code is executed in a notebook (Jupyter, Colab, QTconsole).

    Taken from https://stackoverflow.com/a/39662359.
    Adapted to make it work with Google colab as well.
    ZMQInteractiveShellTF)get_ipython	__class____mro____name__	NameError)shell_classZparent_classr$   r$   r%   is_notebook  s   

rr   c                   C   r*   )zoReturn `True` if code is executed in a Google colab.

    Taken from https://stackoverflow.com/a/63519730.
    )_is_google_colabr$   r$   r$   r%   is_google_colab.  s   rt   c                   C   s   t jddkS )zKReturn `True` if code is executed in a Google Colab Enterprise environment.ZVERTEX_PRODUCTZCOLAB_ENTERPRISE)rG   rH   r"   r$   r$   r$   r%   is_colab_enterprise6  s   ru   c                  C   s`  ddl m} m} ddlm} |  }t t t d}zt j	}d|d< |j
|d< W n ty7   d|d< Y nw t r=dnd|d	< t rFdnd|d
< t rOdnd|d< tj|d< |du|d< |duruz	| d |d< W n	 tyt   Y nw z
d| |d< W n	 ty   Y nw t |d< t |d< t |d< t |d< t |d< t |d< t |d< t |d< t |d< t |d< t |d< t |d< t |d< t  |d < t! |d!< tj"|d"< tj#|d#< tj$|d$< tj|d%< tj%|d&< tj&|d'< tj'|d(< tj(|d)< tj)|d*< tj*|d+< tj+|d,< tj,|d-< tj-|d.< tj.|d/< t/d0 t/d1d2d3 |0 D d1  |S )4a  Dump information about the machine to help debugging issues.

    Similar helper exist in:
    - `datasets` (https://github.com/huggingface/datasets/blob/main/src/datasets/commands/env.py)
    - `diffusers` (https://github.com/huggingface/diffusers/blob/main/src/diffusers/commands/env.py)
    - `transformers` (https://github.com/huggingface/transformers/blob/main/src/transformers/commands/env.py)
    r   )	get_tokenwhoami)list_credential_helpers)zhuggingface_hub versionPlatformzPython versionZYeszRunning in iPython ?ziPython shellZNozRunning in notebook ?zRunning in Google Colab ?z$Running in Google Colab Enterprise ?zToken path ?NzHas saved token ?namez
Who am I ?z, z!Configured git credential helpersZFastAIZ
TensorflowZTorchr   Graphvizr   ZPydotr   r   r   r   r   r   r	   r   ENDPOINTHF_HUB_CACHEHF_ASSETS_CACHEHF_TOKEN_PATHHF_STORED_TOKENS_PATHHF_HUB_OFFLINEHF_HUB_DISABLE_TELEMETRYHF_HUB_DISABLE_PROGRESS_BARSHF_HUB_DISABLE_SYMLINKS_WARNING#HF_HUB_DISABLE_EXPERIMENTAL_WARNINGHF_HUB_DISABLE_IMPLICIT_TOKENHF_HUB_ENABLE_HF_TRANSFERHF_HUB_ETAG_TIMEOUTHF_HUB_DOWNLOAD_TIMEOUTz5
Copy-and-paste the text below in your GitHub issue.

c                 S   s    g | ]\}}d | d| qS )z- z: r$   ).0propvalr$   r$   r%   
<listcomp>  s     z)dump_environment_info.<locals>.<listcomp>)1Zhuggingface_hubrv   rw   Zhuggingface_hub.utilsrx   r.   platformr,   rl   rm   ro   rp   rr   rt   ru   r   r   	Exceptionjoinr7   rf   ri   rS   rC   rM   r`   rV   rF   r@   rc   rP   r]   r4   rJ   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   printitems)rv   rw   rx   tokeninforq   r$   r$   r%   dump_environment_info;  s|   





























 r   )J__doc__importlib.metadata	importlibrG   r   sysrZ   typingr   r    r   r   versionsplitrstripr   str__annotations__r!   Z_CANDIDATESr   Zcandidate_nameZpackage_namesrz   metadataZPackageNotFoundErrorr&   boolr)   r,   r.   r2   r4   r6   r7   r9   r:   r<   r=   r?   r@   rB   rC   rE   rF   rI   rJ   rL   rM   rO   rP   rR   rS   rU   rV   r\   r]   r_   r`   rb   rc   re   rf   rh   ri   rj   rl   rs   rp   rr   rt   ru   r   r$   r$   r$   r%   <module>   s   	
!