o
    0i31                  
   @   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 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d0d1Z%d!efd2d3Z&d!efd4d5Z'd!efd6d7Z(d!efd8d9Z)d!efd:d;Z*d!efd<d=Z+d!efd>d?Z,d!efd@dAZ-d!efdBdCZ.d!efdDdEZ/d!efdFdGZ0d!efdHdIZ1d!efdJdKZ2d!efdLdMZ3d!efdNdOZ4d!efdPdQZ5d!efdRdSZ6d!efdTdUZ7d!efdVdWZ8d!efdXdYZ9d!efdZd[Z:d!efd\d]Z;d!efd^d_Z<d!efd`daZ=d!efdbdcZ>d!efdddeZ?d!efdfdgZ@d!efdhdiZAd!efdjdkZBd!efdldmZCd!efdndoZDz	dpeeE v ZFW n eGy   dqZFY nw d!efdrdsZHd!efdtduZId!efdvdwZJd!edx fdydzZKd!efd{d|ZLd!efd}d~ZMd!eNee
f fddZOdS )z0Check presence of installed packages at runtime.    N)Path)AnyLiteral   )__version__	constants+_PY_VERSIONaiohttpfastaifastapifastcoregradiographvizhf_xetjinjaZJinja2httpxkerasnumpypillowZ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#   X/home/kim/smarthome/.venv/lib/python3.10/site-packages/huggingface_hub/utils/_runtime.py_get_versionK      r%   c                 C   s   t | dkS r   r%   r"   r#   r#   r$   is_package_availableO   r&   r(   c                   C      t S N)r	   r#   r#   r#   r$   get_python_versionT      r+   c                   C   r)   r*   )r   r#   r#   r#   r$   get_hf_hub_versionY   r,   r-   c                   C      t dS Nr
   r(   r#   r#   r#   r$   is_aiohttp_available^      r1   c                   C   r.   r/   r'   r#   r#   r#   r$   get_aiohttp_versionb   r2   r3   c                   C   r.   Nr   r0   r#   r#   r#   r$   is_fastai_availableg   r2   r5   c                   C   r.   r4   r'   r#   r#   r#   r$   get_fastai_versionk   r2   r6   c                   C   r.   Nr   r0   r#   r#   r#   r$   is_fastapi_availablep   r2   r8   c                   C   r.   r7   r'   r#   r#   r#   r$   get_fastapi_versiont   r2   r9   c                   C   r.   Nr   r0   r#   r#   r#   r$   is_fastcore_availabley   r2   r;   c                   C   r.   r:   r'   r#   r#   r#   r$   get_fastcore_version}   r2   r<   c                   C   r.   Nr   r0   r#   r#   r#   r$   is_gradio_available   r2   r>   c                   C   r.   r=   r'   r#   r#   r#   r$   get_gradio_version   r2   r?   c                   C   r.   Nr   r0   r#   r#   r#   r$   is_graphviz_available   r2   rA   c                   C   r.   r@   r'   r#   r#   r#   r$   get_graphviz_version   r2   rB   c                   C   r.   Nr   r0   r#   r#   r#   r$   is_httpx_available   r2   rD   c                   C   r.   rC   r'   r#   r#   r#   r$   get_httpx_version   r2   rE   c                   C   s   t jrdS tdS )NFr   )r   HF_HUB_DISABLE_XETr(   r#   r#   r#   r$   is_xet_available   s   rG   c                   C   r.   )Nr   r'   r#   r#   r#   r$   get_xet_version   r2   rH   c                   C   r.   Nr   r0   r#   r#   r#   r$   is_keras_available   r2   rJ   c                   C   r.   rI   r'   r#   r#   r#   r$   get_keras_version   r2   rK   c                   C   r.   Nr   r0   r#   r#   r#   r$   is_numpy_available   r2   rM   c                   C   r.   rL   r'   r#   r#   r#   r$   get_numpy_version   r2   rN   c                   C   r.   Nr   r0   r#   r#   r#   r$   is_jinja_available   r2   rP   c                   C   r.   rO   r'   r#   r#   r#   r$   get_jinja_version   r2   rQ   c                   C   r.   Nr   r0   r#   r#   r#   r$   is_pillow_available   r2   rS   c                   C   r.   rR   r'   r#   r#   r#   r$   get_pillow_version   r2   rT   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   rV   ImportErrorwarningswarnrU   r#   r#   r$   is_pydantic_available   s   
rZ   c                   C   r.   )Nr   r'   r#   r#   r#   r$   get_pydantic_version   r2   r[   c                   C   r.   Nr   r0   r#   r#   r#   r$   is_pydot_available   r2   r]   c                   C   r.   r\   r'   r#   r#   r#   r$   get_pydot_version   r2   r^   c                   C   r.   Nr   r0   r#   r#   r#   r$   is_tensorboard_available   r2   r`   c                   C   r.   r_   r'   r#   r#   r#   r$   get_tensorboard_version   r2   ra   c                   C   r.   Nr   r0   r#   r#   r#   r$   is_tf_available   r2   rc   c                   C   r.   rb   r'   r#   r#   r#   r$   get_tf_version  r2   rd   c                   C   r.   Nr   r0   r#   r#   r#   r$   is_torch_available  r2   rf   c                   C   r.   re   r'   r#   r#   r#   r$   get_torch_version
  r2   rg   c                   C   r.   )Nr   r0   r#   r#   r#   r$   is_safetensors_available  r2   rh   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   

rp   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   rr   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)osenvironr!   r#   r#   r#   r$   is_colab_enterprise7  s   ru   )brewhf_installerunknownc                   C   s   t  rdS t r
dS dS )zReturn the installation method of the current environment.

    - "hf_installer" if installed via the official installer script
    - "brew" if installed via Homebrew
    - "unknown" otherwise
    rv   rw   rx   )_is_brew_installation_is_hf_installer_installationr#   r#   r#   r$   installation_method?  s
   r{   c                  C   s0   t tj } t| }d|v pd|v p|dS )zVCheck if running from a Homebrew installation.

    Note: AI-generated by Claude.
    z/Cellar/z/opt/homebrew/z/usr/local/Cellar/)r   sys
executableresolvestr
startswith)Zexe_pathZexe_strr#   r#   r$   ry   N  s   ry   c                  C   s   t j} t| d }| S )a  Return `True` if the current environment was set up via the official hf installer script.

    i.e. using one of
        curl -LsSf https://hf.co/cli/install.sh | bash
        powershell -ExecutionPolicy ByPass -c "irm https://hf.co/cli/install.ps1 | iex"
    z.hf_installer_marker)r|   prefixr   exists)venvmarkerr#   r#   r$   rz   [  s   rz   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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j%|d&< t&d' t&d(d)d* |' D d(  |S )+a  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Installation methodr   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_TOKENrF   HF_HUB_ETAG_TIMEOUTHF_HUB_DOWNLOAD_TIMEOUTHF_XET_HIGH_PERFORMANCEz5
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>)(Zhuggingface_hubr   r   Zhuggingface_hub.utilsr   r-   platformr+   rj   rk   rm   rn   rp   rr   ru   r   r   	Exceptionjoinr{   rE   rH   r?   ra   r   r   r   r   r   r   r   r   r   r   rF   r   r   r   printitems)r   r   r   tokeninforo   r#   r#   r$   dump_environment_infog  sj   




















 r   )P__doc__importlib.metadata	importlibrs   r   r|   rX   pathlibr   typingr   r    r   r   versionsplitrstripr	   r   __annotations__r    Z_CANDIDATESr   Zcandidate_nameZpackage_namesr   metadataPackageNotFoundErrorr%   boolr(   r+   r-   r1   r3   r5   r6   r8   r9   r;   r<   r>   r?   rA   rB   rD   rE   rG   rH   rJ   rK   rM   rN   rP   rQ   rS   rT   rZ   r[   r]   r^   r`   ra   rc   rd   rf   rg   rh   rj   rq   rn   rp   rr   ru   r{   ry   rz   dictr   r#   r#   r#   r$   <module>   s   	
!