σ
Π²Ebc           @@  s  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l	 m
 Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z m Z m Z d  d	 l m Z m Z m Z d  d
 l m Z d  d l m Z e rGd  d l  Z  d  d l! m" Z" m# Z# m$ Z$ m% Z% d  d l& m' Z' n  d Z( e j) e*  Z+ d   Z, d e- f d     YZ. d   Z/ d   Z0 d S(   i    (   t   absolute_importN(   t   version(   t   ensure_binary(   t   LinkCollector(   t   PackageFinder(   t   SelectionPreferences(   t   adjacent_tmp_filet   check_path_ownert   replace(   t
   ensure_dirt   get_distributiont   get_installed_version(   t   get_installer(   t   MYPY_CHECK_RUNNING(   t   Anyt   Dictt   Textt   Union(   t
   PipSessions   %Y-%m-%dT%H:%M:%SZc         C@  s%   t  |   } t j |  j   } | S(   N(   R   t   hashlibt   sha224t	   hexdigest(   t   keyt	   key_bytest   name(    (    s>   /tmp/pip-build-UPPWic/pip/pip/_internal/self_outdated_check.pyt   _get_statefile_name"   s    t   SelfCheckStatec           B@  s)   e  Z d    Z e d    Z d   Z RS(   c         C@  s   i  |  _  d  |  _ | r t j j | d t |  j   |  _ y. t |  j   } t	 j
 |  |  _  Wd  QXWq t t t f k
 r q Xn  d  S(   Nt	   selfcheck(   t   statet   Nonet   statefile_patht   ost   patht   joinR   R   t   opent   jsont   loadt   IOErrort
   ValueErrort   KeyError(   t   selft	   cache_dirt	   statefile(    (    s>   /tmp/pip-build-UPPWic/pip/pip/_internal/self_outdated_check.pyt   __init__*   s    			c         C@  s   t  j S(   N(   t   syst   prefix(   R(   (    (    s>   /tmp/pip-build-UPPWic/pip/pip/_internal/self_outdated_check.pyR   <   s    c         C@  sα   |  j  s d  St t j j |  j    s, d  St t j j |  j    i |  j d 6| j t  d 6| d 6} t	 j
 | d t d d } t |  j    } | j t |   Wd  QXy t | j |  j   Wn t k
 rά n Xd  S(	   NR   t
   last_checkt   pypi_versiont	   sort_keyst
   separatorst   ,t   :(   R2   R3   (   R   R   R   R    t   dirnameR	   R   t   strftimet   SELFCHECK_DATE_FMTR#   t   dumpst   TrueR   t   writeR   R   R   t   OSError(   R(   R/   t   current_timeR   t   textt   f(    (    s>   /tmp/pip-build-UPPWic/pip/pip/_internal/self_outdated_check.pyt   saveA   s     	

(   t   __name__t
   __module__R+   t   propertyR   R>   (    (    (    s>   /tmp/pip-build-UPPWic/pip/pip/_internal/self_outdated_check.pyR   )   s   	c         C@  s&   t  |   } | s t Sd t |  k S(   s΅   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.
    t   pip(   R
   t   FalseR   (   t   pkgt   dist(    (    s>   /tmp/pip-build-UPPWic/pip/pip/_internal/self_outdated_check.pyt   was_installed_by_pipe   s    c         C@  sα  t  d  } | s d St j |  } d } yt d | j  } t j j   } d | j k r² d | j k r² t j j	 | j d t
  } | | j   d k  r² | j d } q² n  | d k rJt j |  d	 | d
 t } t d t d t  }	 t j d | d |	  }
 |
 j d  j } | d k r(d St | j  } | j | |  n  t j |  } | | k  o| j | j k ot d  } | sd Sd j t j  } t j d | | |  Wn$ t k
 rάt j d d t n Xd S(   sΫ   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.
    RB   NR)   R.   R/   i   i   i<   t   optionst   suppress_no_indext   allow_yankedt   allow_all_prereleasest   link_collectort   selection_prefss	   {} -m pips   You are using pip version %s; however, version %s is available.
You should consider upgrading via the '%s install --upgrade pip' command.s5   There was an error checking the latest version of pipt   exc_infoi¨   i`'  i:	 (    R   t   packaging_versiont   parseR   R   R)   t   datetimet   utcnowR   t   strptimeR6   t   total_secondsR   t   createR8   R   RC   R   t   find_best_candidatet   best_candidatet   strR   R>   t   base_versionRF   t   formatR,   t
   executablet   loggert   warningt	   Exceptiont   debug(   t   sessionRG   t   installed_versiont   pip_versionR/   R   R;   R.   RK   RL   t   finderRV   t   remote_versiont   local_version_is_oldert   pip_cmd(    (    s>   /tmp/pip-build-UPPWic/pip/pip/_internal/self_outdated_check.pyt   pip_self_version_checkr   sX    	
					(1   t
   __future__R    RP   R   R#   t   loggingt   os.pathR   R,   t   pip._vendor.packagingR   RN   t   pip._vendor.sixR   t   pip._internal.index.collectorR   t"   pip._internal.index.package_finderR   t$   pip._internal.models.selection_prefsR   t   pip._internal.utils.filesystemR   R   R   t   pip._internal.utils.miscR	   R
   R   t   pip._internal.utils.packagingR   t   pip._internal.utils.typingR   t   optparset   typingR   R   R   R   t   pip._internal.network.sessionR   R6   t	   getLoggerR?   R[   R   t   objectR   RF   Rf   (    (    (    s>   /tmp/pip-build-UPPWic/pip/pip/_internal/self_outdated_check.pyt   <module>   s2   "	<	