a [f@sddlZddlZddlZddlZddlZddlZddlZddlm Z m Z ddl m Z ddlmZddlmZddlmZddlmZddlmZdd lmZmZmZdd lmZd Zee Z!e"e"d d dZ#GdddZ$e"e%dddZ&eej'ddddZ(dS)N)AnyDict)parse) LinkCollector) PackageFinder)get_default_environment)SelectionPreferences) PipSession)adjacent_tmp_filecheck_path_ownerreplace) ensure_dirz%Y-%m-%dT%H:%M:%SZ)keyreturncCs|}t|}|SN)encodehashlibZsha224Z hexdigest)rZ key_bytesnamerE/usr/lib/python3.9/site-packages/pip/_internal/self_outdated_check.py_get_statefile_namesrc@sBeZdZeddddZeedddZeejddd d ZdS) SelfCheckStateN) cache_dirrc Csi|_d|_|rtj|dt|j|_z>t|jdd}t ||_Wdn1sZ0YWnt t t fy~Yn0dS)NZ selfcheckzutf-8)encoding) statestatefile_pathospathjoinrropenjsonloadOSError ValueErrorKeyError)selfrZ statefilerrr__init__!s .zSelfCheckState.__init__)rcCstjSr)sysprefix)r%rrrr2szSelfCheckState.key) pypi_version current_timercCs|js dSttj|js dSttj|j|j|t|d}t j |ddd}t |j}| | Wdn1s0Yzt|j|jWntyYn0dS)N)r last_checkr)T),:)Z sort_keysZ separators)rr rrdirnamer rstrftimeSELFCHECK_DATE_FMTr dumpsr writerr rr")r%r)r*rtextfrrrsave6s  , zSelfCheckState.save) __name__ __module__ __qualname__strr&propertyrdatetimer5rrrrr sr)pkgrcCst|}|duod|jkS)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. Npip)rget_distributionZ installer)r<Zdistrrrwas_installed_by_pipYs r?)sessionoptionsrcCsRtd}|sdS|j}d}z t|jd}tj}d|jvrzd|jvrztj|jdt }|| dkrz|jd}|durt j ||dd}t d d d } tj || d } | dj} | durWdSt| j}|||t|} || ko|j| jkotd} | s WdStjd }td |||Wn"tyLtjdddYn0dS)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. r=N)rr+r)i: T)rAZsuppress_no_indexF)Z allow_yankedZallow_all_prereleases)link_collectorselection_prefsz -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)rr>versionrrr;Zutcnowrstrptimer0Z total_secondsrZcreaterrZfind_best_candidatebest_candidater9r5 parse_versionZ base_versionr?r' executableloggerZwarning Exceptiondebug)r@rAZinstalled_distZ pip_versionr)rr*r+rBrCfinderrGZremote_versionZlocal_version_is_olderZpip_cmdrrrpip_self_version_checkcsj          rN))r;rr ZloggingZoptparseZos.pathrr'typingrrZpip._vendor.packaging.versionrrHZpip._internal.index.collectorrZ"pip._internal.index.package_finderrZpip._internal.metadatarZ$pip._internal.models.selection_prefsrZpip._internal.network.sessionr Zpip._internal.utils.filesystemr r r Zpip._internal.utils.miscr r0Z getLoggerr6rJr9rrboolr?ZValuesrNrrrrs*        9