o
    0j4                  
   @   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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Z0d!efdFdGZ1d!efdHdIZ2d!efdJdKZ3d!efdLdMZ4d!efdNdOZ5d!efdPdQZ6d!efdRdSZ7d!efdTdUZ8d!efdVdWZ9d!efdXdYZ:d!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ZAd!efdhdiZBd!efdjdkZCd!efdldmZDd!efdndoZEz	dpeeF v ZGW n eHy   dqZGY nw d!efdrdsZId!efdtduZJd!efdvdwZKd!edx fdydzZLd!efd{d|ZMd!efd}d~ZNd!efddZOd!ePeef fddZQd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#   _/var/www/html/Deteccion_Ine/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     ru   )brewhf_installerpipunknownc                   C   s"   t  rdS t r
dS t rdS dS )a  Return the installation method of the current environment.

    - "hf_installer" if installed via the official installer script
    - "brew" if installed via Homebrew
    - "pip" if pip is available (default fallback for standard Python environments)
    - "unknown" otherwise
    rx   rw   ry   rz   )_is_hf_installer_installation_is_brew_installation_is_pip_availabler#   r#   r#   r$   installation_method?  s   r~   c                  C   s   t ttj } d| v S )u  Check if running from a Homebrew installation.

    Homebrew installs the `hf` formula into a Cellar directory and creates a
    libexec virtualenv at e.g. /opt/homebrew/Cellar/hf/0.30.0/libexec/.
    We check `sys.prefix` (the venv/prefix root) for "/Cellar/hf/" rather
    than checking `sys.executable` — the latter resolves to Homebrew's Python
    (e.g. /opt/homebrew/Cellar/python@3.12/...) even for non-brew installs
    when the system Python happens to come from Homebrew.
    z/Cellar/hf/)strr   sysprefixresolve)r   r#   r#   r$   r|   S  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   r   r   exists)venvmarkerr#   r#   r$   r{   a  s   r{   c                   C   s   t jdduS )z>Return `True` if pip is importable in the current environment.ry   N)	importlibutil	find_specr#   r#   r#   r$   r}   m  rv   r}   c                  C   s&  ddl m} m} ddlm}m} |  }t t t d}zt	 j
}d|d< |j|d< W n ty9   d|d< Y nw t r?dnd|d	< t rHdnd|d
< t rQdnd|d< tj|d< |du|d< |durwz	| d |d< W n	 tyv   Y nw z
d| |d< W n	 ty   Y nw | rdnd|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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)is_agent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Run by AI agent ?z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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   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   r   rF   r   r   r   printitems)r   r   r   r   tokeninforo   r#   r#   r$   dump_environment_infor  sn   





















 r   )R__doc__importlib.metadatar   importlib.utilrs   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~   r|   r{   r}   dictr   r#   r#   r#   r$   <module>   s   	
!