3 (\@sddlmZddlZddlZddlZddlZddlZddlm Z m Z ddl m Z ddlmZddlmZddlmZddlmZmZdd lmZerddlZdd lmZmZdd lmZd Zej e!Z"Gd dde#Z$ddZ%ddZ&dS))absolute_importN)lockfile pkg_resources)version) PackageFinder)WINDOWS)check_path_owner) ensure_dirget_installed_version)MYPY_CHECK_RUNNING)AnyDict) PipSessionz%Y-%m-%dT%H:%M:%SZc@seZdZddZddZdS)SelfCheckStatecCsli|_d|_|rhtjj|d|_y,t|j}tj|tj |_WdQRXWnt t t fk rfYnXdS)Nzselfcheck.json) statestatefile_pathospathjoinopenjsonloadsysprefixIOError ValueErrorKeyError)self cache_dir statefiler o/private/var/folders/pf/wv4htv3x0qs2c2mp0dnn0kchsvlck3/T/pip-build-k1a8l1r5/pip/pip/_internal/utils/outdated.py__init__s  zSelfCheckState.__init__cCs|js dSttjj|js dSttjj|jtj|jztjj|jrpt |j}t j |}WdQRXni}|j t |d|tj<t |jd}t j||dddWdQRXWdQRXdS)N) last_check pypi_versionwT,:) sort_keys separators)r&r')rrrrdirnamer rLockFileexistsrrrstrftimeSELFCHECK_DATE_FMTrrdump)rr$ current_timerrr r r!save/s  zSelfCheckState.saveN)__name__ __module__ __qualname__r"r1r r r r!rsrc Cs>y"tj|}|jdo"d|jdkStjk r8dSXdS)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. INSTALLERpipFN)rget_distribution has_metadataget_metadata_linesDistributionNotFound)pkgdistr r r!was_installed_by_pipOs   r=c CsJtd}|sdStj|}d}yt|jd}tjj}d|jkrzd|jkrztjj|jdt }||j dkrz|jd}|dkrt |j |j g|jd |j|d }|jdj} | dkrdSt| j}|j||tj|} || kr|j| jkrtdrtr d } nd} tjd ||| Wn$tk rDtjd ddYnXdS)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. r6N)rr#r$<F) find_links index_urlsallow_all_prereleases trusted_hostssessionz 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 pipT)exc_infoi`'i: )r packaging_versionparserrdatetimeutcnowrstrptimer. total_secondsrrA index_urlextra_index_urlsrDZfind_candidatesZget_beststrrr1 base_versionr=rloggerwarning Exceptiondebug) rEoptionsinstalled_version pip_versionr$rr0r#finder candidateremote_versionpip_cmdr r r!pip_version_check^sP          r])' __future__rrJrloggingos.pathrr pip._vendorrrZpip._vendor.packagingrrHZpip._internal.indexrZpip._internal.utils.compatrZpip._internal.utils.filesystemrZpip._internal.utils.miscr r Zpip._internal.utils.typingr optparseZtypingr r Zpip._internal.downloadrr. getLoggerr2rRobjectrr=r]r r r r!s*        1