U ��.e��@s^ddlmZddlZddlZddlZddlZddlZddlZddl m Z ddl m Z ddlmZddlmZddlmZddlmZdd lmZdd lmZdd lmZmZmZdd lmZm Z m!Z!dd l"m#Z#ddl$m%Z%e%�rddl&Z&ddl&m'Z'ddl(m)Z)m*Z*m+Z+m,Z,ddl-m.Z.dZ/e�0e1�Z2ddd�Z3dd�Z4Gdd�de5�Z6dd�Z7dd�Z8dS)�)�absolute_importN)� pkg_resources)�version)� ensure_binary)� LinkCollector)� PackageFinder)� SearchScope)�SelectionPreferences)�WINDOWS)�adjacent_tmp_file�check_path_owner�replace)� ensure_dir�get_installed_version�redact_auth_from_url)� get_installer)�MYPY_CHECK_RUNNING)�Values)�Any�Dict�Text�Union)� PipSessionz%Y-%m-%dT%H:%M:%SZFcCs`|jg|j}|jr8|s8t�dd�dd�|D���g}|jp@g}tj||d�}t ||d�}|S)z� :param session: The Session to use to make requests. :param suppress_no_index: Whether to ignore the --no-index option when constructing the SearchScope object. zIgnoring indexes: %s�,css|]}t|�VqdS�N)r)�.0Zurl�r�E/usr/lib/python3.8/site-packages/pip/_internal/self_outdated_check.py� @sz&make_link_collector..)� find_links� index_urls)�session� search_scope) Z index_urlZextra_index_urlsZno_index�logger�debug�joinrr�creater)r!�options�suppress_no_indexr rr"�link_collectorrrr�make_link_collector1s  � � r*cCst|�}t�|���}|Sr)r�hashlibZsha224Z hexdigest)�keyZ key_bytes�namerrr�_get_statefile_namePsr.c@s(eZdZdd�Zedd��Zdd�ZdS)�SelfCheckStatec Csni|_d|_|rjtj�|dt|j��|_z&t|j��}t� |�|_W5QRXWnt t t fk rhYnXdS)NZ selfcheck) �state�statefile_path�os�pathr%r.r,�open�json�load�IOError� ValueError�KeyError)�self� cache_dirZ statefilerrr�__init__Xs� zSelfCheckState.__init__cCstjSr)�sys�prefix)r:rrrr,jszSelfCheckState.keyc Cs�|js dSttj�|j��s dSttj�|j��|j|�t�|d�}t j |ddd�}t |j��}|� t |��W5QRXzt|j|j�Wntk r�YnXdS)N)r,� last_check� pypi_versionT)r�:)Z sort_keysZ separators)r1r r2r3�dirnamerr,�strftime�SELFCHECK_DATE_FMTr5�dumpsr �writerr r-�OSError)r:r@� current_timer0�text�frrr�savens � zSelfCheckState.saveN)�__name__� __module__� __qualname__r<�propertyr,rKrrrrr/Ws r/cCs6zt�|�}dt|�kWStjk r0YdSXdS)z�Checks whether pkg was installed by pip This is used not to display the upgrade message when pip is in fact installed by system package manager, such as dnf on Fedora. �pipFN)rZget_distributionrZDistributionNotFound)ZpkgZdistrrr�was_installed_by_pip�s  rQcCsXtd�}|sdSt�|�}d}�zt|jd�}tj��}d|jkrzd|jkrztj�|jdt �}||� �dkrz|jd}|dkr�t ||dd�}t d d d �} t j|| d �} | �d�j} | dkr�WdSt| j�}|�||�t�|�} || ko�|j| jko�td�} | �s WdSt�rd }nd}t�d |||�Wn$tk �rRtjddd�YnXdS)z�Check for an update for pip. Limit the frequency of checks to once per week. State is stored either in the active virtualenv or in the user's USER_CACHE_DIR keyed off the prefix of the pip script path. rPN)r;r?r@i�: T)r'r(F)Z allow_yankedZallow_all_prereleases)r)�selection_prefsz python -m pipz�You are using pip version %s; however, version %s is available. You should consider upgrading via the '%s install --upgrade pip' command.z5There was an error checking the latest version of pip)�exc_info)r�packaging_version�parser/r;�datetimeZutcnowr0�strptimerDZ total_secondsr*r rr&Zfind_best_candidate�best_candidate�strrrKZ base_versionrQr r#Zwarning� Exceptionr$)r!r'Zinstalled_versionZ pip_versionr@r0rHr?r)rR�finderrXZremote_versionZlocal_version_is_olderZpip_cmdrrr�pip_self_version_check�sp   � ���     ����r\)F)9Z __future__rrVr+r5ZloggingZos.pathr2r=Z pip._vendorrZpip._vendor.packagingrrTZpip._vendor.sixrZpip._internal.collectorrZpip._internal.indexrZ!pip._internal.models.search_scoperZ$pip._internal.models.selection_prefsr Zpip._internal.utils.compatr Zpip._internal.utils.filesystemr r r Zpip._internal.utils.miscrrrZpip._internal.utils.packagingrZpip._internal.utils.typingrZoptparser�typingrrrrZpip._internal.network.sessionrrDZ getLoggerrLr#r*r.�objectr/rQr\rrrr�s>              � ;