o
    i31                  
   @   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jinjaJinja2httpxkerasnumpypillowPillowpydanticpydotsafetensorstensorboard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&   d/var/www/html/karishye-ai-python/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/   r0   c                   C      t dS Nr
   r+   r&   r&   r&   r'   is_aiohttp_available^      r4   c                   C   r1   r2   r*   r&   r&   r&   r'   get_aiohttp_versionb   r5   r6   c                   C   r1   Nr   r3   r&   r&   r&   r'   is_fastai_availableg   r5   r8   c                   C   r1   r7   r*   r&   r&   r&   r'   get_fastai_versionk   r5   r9   c                   C   r1   Nr   r3   r&   r&   r&   r'   is_fastapi_availablep   r5   r;   c                   C   r1   r:   r*   r&   r&   r&   r'   get_fastapi_versiont   r5   r<   c                   C   r1   Nr   r3   r&   r&   r&   r'   is_fastcore_availabley   r5   r>   c                   C   r1   r=   r*   r&   r&   r&   r'   get_fastcore_version}   r5   r?   c                   C   r1   Nr   r3   r&   r&   r&   r'   is_gradio_available   r5   rA   c                   C   r1   r@   r*   r&   r&   r&   r'   get_gradio_version   r5   rB   c                   C   r1   Nr   r3   r&   r&   r&   r'   is_graphviz_available   r5   rD   c                   C   r1   rC   r*   r&   r&   r&   r'   get_graphviz_version   r5   rE   c                   C   r1   Nr   r3   r&   r&   r&   r'   is_httpx_available   r5   rG   c                   C   r1   rF   r*   r&   r&   r&   r'   get_httpx_version   r5   rH   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   rJ   c                   C   r1   )Nr   r*   r&   r&   r&   r'   get_xet_version   r5   rK   c                   C   r1   Nr   r3   r&   r&   r&   r'   is_keras_available   r5   rM   c                   C   r1   rL   r*   r&   r&   r&   r'   get_keras_version   r5   rN   c                   C   r1   Nr   r3   r&   r&   r&   r'   is_numpy_available   r5   rP   c                   C   r1   rO   r*   r&   r&   r&   r'   get_numpy_version   r5   rQ   c                   C   r1   Nr   r3   r&   r&   r&   r'   is_jinja_available   r5   rS   c                   C   r1   rR   r*   r&   r&   r&   r'   get_jinja_version   r5   rT   c                   C   r1   Nr   r3   r&   r&   r&   r'   is_pillow_available   r5   rV   c                   C   r1   rU   r*   r&   r&   r&   r'   get_pillow_version   r5   rW   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   rY   ImportErrorwarningswarnrX   r&   r&   r'   is_pydantic_available   s   
r]   c                   C   r1   )Nr   r*   r&   r&   r&   r'   get_pydantic_version   r5   r^   c                   C   r1   Nr   r3   r&   r&   r&   r'   is_pydot_available   r5   r`   c                   C   r1   r_   r*   r&   r&   r&   r'   get_pydot_version   r5   ra   c                   C   r1   Nr   r3   r&   r&   r&   r'   is_tensorboard_available   r5   rc   c                   C   r1   rb   r*   r&   r&   r&   r'   get_tensorboard_version   r5   rd   c                   C   r1   Nr   r3   r&   r&   r&   r'   is_tf_available   r5   rf   c                   C   r1   re   r*   r&   r&   r&   r'   get_tf_version  r5   rg   c                   C   r1   Nr   r3   r&   r&   r&   r'   is_torch_available  r5   ri   c                   C   r1   rh   r*   r&   r&   r&   r'   get_torch_version
  r5   rj   c                   C   r1   )Nr   r3   r&   r&   r&   r'   is_safetensors_available  r5   rk   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_classparent_classr&   r&   r'   is_notebook  s   

rt   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   rv   c                   C   s   t jddkS )zKReturn `True` if code is executed in a Google Colab Enterprise environment.VERTEX_PRODUCTCOLAB_ENTERPRISE)osenvironr$   r&   r&   r&   r'   is_colab_enterprise7  s   r{   )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
    r|   r}   r~   )_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)exe_pathexe_strr&   r&   r'   r   N  s   r   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'   r   [  s   r   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 versionYeszRunning in iPython ?ziPython shell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_TOKENrI   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>)(huggingface_hubr   r   huggingface_hub.utilsr   r0   platformr.   rm   rn   rp   rq   rt   rv   r{   r   r   	Exceptionjoinr   rH   rK   rB   rd   r   r   r   r   r   r   r   r   r   r   rI   r   r   r   printitems)r   r   r   tokeninforr   r&   r&   r'   dump_environment_infog  sj   




















 r   )P__doc__importlib.metadata	importlibry   r   r   r[   pathlibr   typingr   r    r   r   versionsplitrstripr	   r   __annotations__r#   _CANDIDATESr   candidate_namepackage_namesr   metadataPackageNotFoundErrorr(   boolr+   r.   r0   r4   r6   r8   r9   r;   r<   r>   r?   rA   rB   rD   rE   rG   rH   rJ   rK   rM   rN   rP   rQ   rS   rT   rV   rW   r]   r^   r`   ra   rc   rd   rf   rg   ri   rj   rk   rm   ru   rq   rt   rv   r{   r   r   r   dictr   r&   r&   r&   r'   <module>   s   	
!