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/e0e1Z2dddZ3ddZ4Gddde5Z6ddZ7ddZ8dS))absolute_importN) pkg_resources)version) ensure_binary) LinkCollector) PackageFinder) SearchScope)SelectionPreferences)WINDOWS)adjacent_tmp_filecheck_path_ownerreplace) ensure_dirget_installed_versionredact_auth_from_url) get_installer)MYPY_CHECK_RUNNING)Values)AnyDictTextUnion) PipSessionz%Y-%m-%dT%H:%M:%SZFcCs`|jg|j}|jr8|s8tdddd|Dg}|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|VqdSN)r).0ZurlrE/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_indexloggerdebugjoinrrcreater)r!optionssuppress_no_indexr rr"link_collectorrrrmake_link_collector1s    r*cCst|}t|}|Sr)rhashlibZsha224Z hexdigest)keyZ key_bytesnamerrr_get_statefile_namePsr.c@s(eZdZddZeddZddZdS)SelfCheckStatec Csni|_d|_|rjtj|dt|j|_z&t|j}t ||_W5QRXWnt t t fk rhYnXdS)NZ selfcheck) statestatefile_pathospathr%r.r,openjsonloadIOError ValueErrorKeyError)self cache_dirZ statefilerrr__init__Xs zSelfCheckState.__init__cCstjSr)sysprefix)r:rrrr,jszSelfCheckState.keyc Cs|js dSttj|js dSttj|j|j|t|d}t j |ddd}t |j}| t |W5QRXzt|j|jWntk rYnXdS)N)r, last_check pypi_versionT)r:)Z sort_keysZ separators)r1r r2r3dirnamerr,strftimeSELFCHECK_DATE_FMTr5dumpsr writerr r-OSError)r:r@ current_timer0textfrrrsavens  zSelfCheckState.saveN)__name__ __module__ __qualname__r<propertyr,rKrrrrr/Ws r/cCs6zt|}dt|kWStjk r0YdSXdS)zChecks 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)ZpkgZdistrrrwas_installed_by_pips  rQcCsXtd}|sdSt|}d}zt|jd}tj}d|jkrzd|jkrztj|jdt }|| dkrz|jd}|dkrt ||dd}t d d d } t j|| d } | dj} | dkrWdSt| j}|||t|} || ko|j| jkotd} | s WdStrd }nd}td |||Wn$tk rRtjdddYnXdS)zCheck 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 pipzYou 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)rpackaging_versionparser/r;datetimeZutcnowr0strptimerDZ total_secondsr*r rr&Zfind_best_candidatebest_candidatestrrrKZ base_versionrQr r#Zwarning Exceptionr$)r!r'Zinstalled_versionZ pip_versionr@r0rHr?r)rRfinderrXZremote_versionZlocal_version_is_olderZpip_cmdrrrpip_self_version_checksp         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.typingrZoptparsertypingrrrrZpip._internal.network.sessionrrDZ getLoggerrLr#r*r.objectr/rQr\rrrrs>               ;