
    i4                        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 ]C\  ZZdee<   eD ]6Z	 ej                            e          ee<    n# ej        j        $ r Y 3w xY wDd ed!efd"Zd ed!efd#Z d!efd$Z!d!efd%Z"d!efd&Z#d!efd'Z$d!efd(Z%d!efd)Z&d!efd*Z'd!efd+Z(d!efd,Z)d!efd-Z*d!efd.Z+d!efd/Z,d!efd0Z-d!efd1Z.d!efd2Z/d!efd3Z0d!efd4Z1d!efd5Z2d!efd6Z3d!efd7Z4d!efd8Z5d!efd9Z6d!efd:Z7d!efd;Z8d!efd<Z9d!efd=Z:d!efd>Z;d!efd?Z<d!efd@Z=d!efdAZ>d!efdBZ?d!efdCZ@d!efdDZAd!efdEZBd!efdFZCd!efdGZDd!efdHZE	 dI e eF                      v ZGn# eH$ r dJZGY nw xY wd!efdKZId!efdLZJd!efdMZKd!edN         fdOZLd!efdPZMd!efdQZNd!efdRZOd!ePeef         fdSZQdS )Tz0Check 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                 8    t                               | d          S Nr    )_package_versionsgetr!   s    _/usr/local/lib/hermes-agent/venv/lib/python3.11/site-packages/huggingface_hub/utils/_runtime.py_get_versionr)   K   s      u555    c                 (    t          |           dk    S r$   r)   r'   s    r(   is_package_availabler-   O   s    %%..r*   c                      t           S N)r
    r*   r(   get_python_versionr1   T       r*   c                      t           S r/   )r   r0   r*   r(   get_hf_hub_versionr4   Y   r2   r*   c                       t          d          S Nr   r-   r0   r*   r(   is_aiohttp_availabler8   ^       	***r*   c                       t          d          S r6   r,   r0   r*   r(   get_aiohttp_versionr;   b       	"""r*   c                       t          d          S Nr   r7   r0   r*   r(   is_fastai_availabler?   g       )))r*   c                       t          d          S r>   r,   r0   r*   r(   get_fastai_versionrB   k       !!!r*   c                       t          d          S Nr   r7   r0   r*   r(   is_fastapi_availablerF   p   r9   r*   c                       t          d          S rE   r,   r0   r*   r(   get_fastapi_versionrH   t   r<   r*   c                       t          d          S Nr   r7   r0   r*   r(   is_fastcore_availablerK   y       
+++r*   c                       t          d          S rJ   r,   r0   r*   r(   get_fastcore_versionrN   }       
###r*   c                       t          d          S Nr   r7   r0   r*   r(   is_gradio_availablerR      r@   r*   c                       t          d          S rQ   r,   r0   r*   r(   get_gradio_versionrT      rC   r*   c                       t          d          S Nr   r7   r0   r*   r(   is_graphviz_availablerW      rL   r*   c                       t          d          S rV   r,   r0   r*   r(   get_graphviz_versionrY      rO   r*   c                       t          d          S Nr   r7   r0   r*   r(   is_httpx_availabler\          (((r*   c                       t          d          S r[   r,   r0   r*   r(   get_httpx_versionr_             r*   c                  <    t           j        rdS t          d          S )NFr   )r   HF_HUB_DISABLE_XETr-   r0   r*   r(   is_xet_availablerc      s     # u)))r*   c                       t          d          S )Nr   r,   r0   r*   r(   get_xet_versionre      rC   r*   c                       t          d          S Nr   r7   r0   r*   r(   is_keras_availablerh      r]   r*   c                       t          d          S rg   r,   r0   r*   r(   get_keras_versionrj      r`   r*   c                       t          d          S Nr   r7   r0   r*   r(   is_numpy_availablerm      r]   r*   c                       t          d          S rl   r,   r0   r*   r(   get_numpy_versionro      r`   r*   c                       t          d          S Nr   r7   r0   r*   r(   is_jinja_availablerr      r]   r*   c                       t          d          S rq   r,   r0   r*   r(   get_jinja_versionrt      r`   r*   c                       t          d          S Nr   r7   r0   r*   r(   is_pillow_availablerw      r@   r*   c                       t          d          S rv   r,   r0   r*   r(   get_pillow_versionry      rC   r*   c                      t          d          sdS 	 ddlm}  n%# t          $ r t	          j        d           Y dS w xY wdS )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   r|   ImportErrorwarningswarnr{   s    r(   is_pydantic_availabler      sv    
++ u&&&&&&&   B	
 	
 	
 uu 4s    <<c                       t          d          S )Nr   r,   r0   r*   r(   get_pydantic_versionr      rO   r*   c                       t          d          S Nr   r7   r0   r*   r(   is_pydot_availabler      r]   r*   c                       t          d          S r   r,   r0   r*   r(   get_pydot_versionr      r`   r*   c                       t          d          S Nr   r7   r0   r*   r(   is_tensorboard_availabler          ...r*   c                       t          d          S r   r,   r0   r*   r(   get_tensorboard_versionr      s    &&&r*   c                       t          d          S Nr   r7   r0   r*   r(   is_tf_availabler      s    ---r*   c                       t          d          S r   r,   r0   r*   r(   get_tf_versionr     s    %%%r*   c                       t          d          S Nr   r7   r0   r*   r(   is_torch_availabler     r]   r*   c                       t          d          S r   r,   r0   r*   r(   get_torch_versionr   
  r`   r*   c                       t          d          S )Nr   r7   r0   r*   r(   is_safetensors_availabler     r   r*   zgoogle.colabFc                      	 t                      j        } | j        D ]}|j        dk    r dS dS # t          $ r Y dS w xY 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_classs     r(   is_notebookr     sg    !mm-'/ 	 	L$(===tt >u   uus   (/ / 
==c                      t           S )zoReturn `True` if code is executed in a Google colab.

    Taken from https://stackoverflow.com/a/63519730.
    )_is_google_colabr0   r*   r(   is_google_colabr   /  s
    
 r*   c                  H    t           j                            d          dk    S )zKReturn `True` if code is executed in a Google Colab Enterprise environment.VERTEX_PRODUCTCOLAB_ENTERPRISE)osenvironr&   r0   r*   r(   is_colab_enterpriser   7  s    :>>*++/AAAr*   )brewhf_installerpipunknownc                  f    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
    r   r   r   r   )_is_hf_installer_installation_is_brew_installation_is_pip_availabler0   r*   r(   installation_methodr   ?  sB     %&& ~ v u9r*   c                  z    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   s    r(   r   r   S  s2     cj!!))++,,FF""r*   c                  f    t           j        } t          |           dz  }|                                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markers     r(   r   r   a  s*     :D$ZZ00F==??r*   c                  D    t           j                            d          duS )z>Return `True` if pip is importable in the current environment.r   N)	importlibutil	find_specr0   r*   r(   r   r   m  s    >##E**$66r*   c                     ddl m} m} ddlm}m}  |             }t                      t          j                    t                      d}	 t                      j
        }d|d<   |j        |d<   n# t          $ r d|d<   Y nw xY wt                      rdnd|d	<   t                      rdnd|d
<   t                      rdnd|d<   t           j        |d<   |du|d<   |%	  |            d         |d<   n# t$          $ r Y nw xY w	 d                     |                      |d<   n# t$          $ r Y nw xY w |            rdnd|d<   t)                      |d<   t+                      |d<   t-                      |d<   t/                      |d<   t1                      |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(<   tQ          d)           tQ          d*                    d+ |)                                D                       d*z              |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 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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_TOKENrb   HF_HUB_ETAG_TIMEOUTHF_HUB_DOWNLOAD_TIMEOUTHF_XET_HIGH_PERFORMANCEz5
Copy-and-paste the text below in your GitHub issue.

c                 $    g | ]\  }}d | d| S )z- z: r0   ).0propvals      r(   
<listcomp>z)dump_environment_info.<locals>.<listcomp>  s-    FFFID#'$''#''FFFr*   )*huggingface_hubr   r   huggingface_hub.utilsr   r   r4   platformr1   r   r   r   r   r   r   r   r   r   	Exceptionjoinr   r_   re   rT   r   r   r   r   r   r   r   r   r   r   r   r   rb   r   r   r   printitems)r   r   r   r   tokeninfor   s          r(   dump_environment_infor   r  sP    21111111GGGGGGGGIKKE $6#7#7%'',.. D,!mm-',#$ + 4_ , , ,'+#$$$,-8]]$DEED	 !1@1B1B(LD	$%<O<Q<Q3[55W[D	/0$2D %T 1D		!'&!1D 	 	 	D	48II>U>U>W>W4X4X011    *2 =D	 #6"7"7D	 &''DM$&&DN'))DN133D !)D$1D'7D	%3D$-$CD	 !&5D	'0'ID	#$+4+QD	'(&/&GD	"#.7.WD	*+2;2_D	./,5,SD	()!*!=D	"+"?D	&/&GD	"#&/&GD	"#	
CDDD	$))FFFFF
G
G$
NOOOKs6   "A. .B ?B C/ /
C<;C<  D! !
D.-D.)R__doc__importlib.metadatar   importlib.utilr   r   r   r~   pathlibr   typingr   r    r   r   versionsplitrstripr
   r   __annotations__r%   _CANDIDATESr   candidate_namepackage_namesr   metadataPackageNotFoundErrorr)   boolr-   r1   r4   r8   r;   r?   rB   rF   rH   rK   rN   rR   rT   rW   rY   r\   r_   rc   re   rh   rj   rm   ro   rr   rt   rw   ry   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   dictr   r0   r*   r(   <module>r      s   7 6 6         				  



                % % % % % % % % ;$$&&q)0055S 5 5 5 	{xj 	{ 	
 xj  xj hZ gY gY gY xj  gY M?  N#!"  #: gY; B &1%6%6%8%8  !NM(-n%  	090B0J0J40P0Pn-E!6 	 	 	D	6s 6s 6 6 6 6/s /t / / / /
C    
C    
+d + + + +#S # # # #
*T * * * *"C " " " "
+d + + + +#S # # # #
,t , , , ,$c $ $ $ $
*T * * * *"C " " " "
,t , , , ,$c $ $ $ $
)D ) ) ) )!3 ! ! ! !
*$ * * * *" " " " "
)D ) ) ) )!3 ! ! ! !
)D ) ) ) )!3 ! ! ! !
)D ) ) ) )!3 ! ! ! !
*T * * * *"C " " " "
t    0$c $ $ $ $
)D ) ) ) )!3 ! ! ! !
/$ / / / /' ' ' ' '
. . . . .& & & & &
)D ) ) ) )!3 ! ! ! !
/$ / / / /
 &[[]]););;   T         BT B B B BW%MN    (#t # # # #	t 	 	 	 	74 7 7 7 7
KtCH~ K K K K K Ks$   C77D	D	<H HH