
    %e                         U d Z ddlZddlZddlmZ ddlmZ ddl	m
Z
  e
j        e          ZdZdZ ed          Zee         ed<   d	ej        j        fd
Zd	ej        j        fdZddZd ZdS )zStreamlit version utilities.    N)version)Finalz$https://pypi.org/pypi/streamlit/jsong?	streamlitSTREAMLIT_VERSION_STRINGreturnc                 @    t           j                            |           S N)	packagingr   Version)version_strs    1lib/python3.11/site-packages/streamlit/version.py_version_str_to_objr   $   s    $$[111    c                  *    t          t                    S )zReturn the streamlit version string from setup.py.

    Returns
    -------
    str
        The version string specified in setup.py.

    )r   r    r   r    _get_installed_streamlit_versionr   (   s     7888r   c                     ddl }|                    t          |           }	 |                                d         d         }n"# t          $ r}t          d|          d}~ww xY wt          |          S )a`  Request the latest streamlit version string from PyPI.

    NB: this involves a network call, so it could raise an error
    or take a long time.

    Parameters
    ----------
    timeout : float or None
        The request timeout.

    Returns
    -------
    str
        The version string for the latest version of streamlit
        on PyPI.

    r   Ntimeoutinfor   z!Got unexpected response from PyPI)requestsgetPYPI_STREAMLIT_URLjson	ExceptionRuntimeErrorr   )r   r   rspr   es        r   _get_latest_streamlit_versionr   4   s    $ OOO
,,)7,
;
;CChhjj(3 C C C>BBBC{+++s    A 
A"AA"c                  &   t          j                     t          k    rt                              d           dS 	 t	                      } t          d          }n4# t          $ r'}t                              d|           Y d}~dS d}~ww xY w|| k    S )a  True if streamlit should show a 'new version!' notice to the user.

    We need to make a network call to PyPI to determine the latest streamlit
    version. Since we don't want to do this every time streamlit is run,
    we'll only perform the check ~5% of the time.

    If we do make the request to PyPI and there's any sort of error,
    we log it and return False.

    Returns
    -------
    bool
        True if we should tell the user that their streamlit is out of date.

    zSkipping PyPI version checkF   r   zFailed PyPI version check.)exc_infoN)randomCHECK_PYPI_PROBABILITY_LOGGERdebugr   r   r   )installed_versionlatest_versionexs      r   should_show_new_version_noticer*   P   s      }0003444u<>>6qAAA   2R@@@uuuuu
 ---s   A 
B
#BB
r	   )__doc__r#   packaging.versionr
   importlib_metadatar   _versiontyping_extensionsr   streamlit.loggerlogger
get_logger__name__r%   r   r$   r   str__annotations__r   r   r   r   r*   r   r   r   <module>r6      s	   # " "      2 2 2 2 2 2 # # # # # # ! ! ! ! ! !
&
H
%
%; 
  '/x'<'< %* < < <2	(9(A 2 2 2 2	9)*;*C 	9 	9 	9 	9, , , ,8. . . . .r   