ó
ä™L]c           @@  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	 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 Z d  d l m Z d  d l m Z d  d l m Z d  d l m Z m Z d  d l m Z 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) d  d l* m+ Z+ m, Z, d  d l- m. Z. m/ Z/ m0 Z0 m1 Z1 m2 Z2 d  d l3 m4 Z4 d  d l5 m6 Z6 d  d l7 m8 Z8 m9 Z9 e r÷d  d l m: Z; n d  d l m; Z; e6 r†d  d l< m= Z= m> Z> m? Z? m@ Z@ mA ZA mB ZB mC ZC mD ZD mE ZE mF ZF d  d lG mH ZH d  d lI mJ ZJ d  d lK mL ZL n  y- d  d l< mM ZM mN ZN eN eO eO eO f ZP Wn  eQ k
 rÕd „  ZM d ZP n Xd d d d d d d  d! d" d# d$ d% d& d' d( d) d* d+ d, d- d. d/ d0 d1 d2 g ZS e jT eU ƒ ZV e jT d3 ƒ ZW d4 ZX d5 ZY d‡ ZZ dˆ Z[ d= eY f Z\ d‰ Z] e\ eZ e] e[ Z^ e\ e] Z_ y d  d l` Z` e_ eZ 7Z_ Wn eQ k
 rÅeV ja dA ƒ n Xy d  d lb Zb e_ e[ 7Z_ Wn eQ k
 r eV ja dB ƒ n XdC „  Zc dD „  Zd dE „  Ze dF „  Zf e dG dH dI dJ ƒ eg dK „ ƒ Zh dL „  Zi dM „  Zj dN „  Zk dO dP „ Zl dQ „  Zm dR „  Zn dS „  Zo dT „  Zp dU „  Zq dV „  Zr dW „  Zs dX „  Zt dY „  Zu e jv dZ „ Zw d[ „  Zx d\ „  Zy ez d] „ Z{ d^ „  Z| d_ „  Z} d` „  Z~ da „  Z db „  Z€ dc „  Z� dd „  Z‚ ez e1 ez eg eg d de „ Zƒ df „  Z„ dg „  Z… dh „  Z† ez di „ Z‡ dj „  Zˆ dk „  Z‰ dl „  ZŠ dm „  Z‹ eg d dn d d d d d do „ ZŒ dp „  Z� dq eŽ f dr „  ƒ  YZ� ds e; f dt „  ƒ  YZ� e j‘ du „  ƒ Z’ dv „  Z“ dw „  Z” dx eŽ f dy „  ƒ  YZ• d dz „ Z– d{ „  Z— d| „  Z˜ d} „  Z™ d~ „  Zš d „  Z› d€ „  Zœ d� „  Z� d‚ „  Zž dƒ „  ZŸ d„ „  Z  d… „  Z¡ d† „  Z¢ d S(Š   i    (   t   absolute_importN(   t   deque(   t   pkg_resources(   t   retry(   t   PY2t	   text_type(   t   inputt   shlex_quote(   t   parse(   t   request(   t   unquote(   t   __version__(   t   CommandErrort   InstallationError(   t   site_packagest	   user_site(   t   WINDOWSt   console_to_strt
   expandusert   stdlib_pkgst   str_to_display(   t   write_delete_marker_file(   t   MYPY_CHECK_RUNNING(   t   running_under_virtualenvt   virtualenv_no_global(   t   BytesIO(   t   StringIO(
   t   Anyt   AnyStrt	   Containert   Iterablet   Listt   Mappingt   Matcht   Optionalt   Textt   Union(   t   Distribution(   t   Link(   t   SpinnerInterface(   t   castt   Tuplec         C@  s   | S(   N(    (   t   typt   val(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR(   ?   s    t   rmtreet   display_patht
   backup_dirt   askt   splitextt   format_sizet   is_installable_dirt   is_svn_paget   file_contentst   split_leading_dirt   has_leading_dirt   normalize_patht   renamest   get_progt
   unzip_filet
   untar_filet   unpack_filet   call_subprocesst   captured_stdoutt
   ensure_dirt   ARCHIVE_EXTENSIONSt   SUPPORTED_EXTENSIONSt   WHEEL_EXTENSIONt   get_installed_versiont   remove_auth_from_urls   pip.subprocessors(   ----------------------------------------s   .whls   .tar.bz2s   .tbzs   .tar.xzs   .txzs   .tlzs   .tar.lzs	   .tar.lzmas   .zips   .tar.gzs   .tgzs   .tars   bz2 module is not availables   lzma module is not availablec          C@  sP   t  j j t  j j t ƒ d d ƒ }  t  j j |  ƒ }  d j t |  t j	 d  ƒ S(   Ns   ..s   pip {} from {} (python {})i   (
   t   ost   patht   joint   dirnamet   __file__t   abspatht   formatR   t   syst   version(   t   pip_pkg_dir(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   get_pip_versionm   s    $c         C@  sY   t  |  ƒ d k  r- |  d t  |  ƒ d 7}  n t  |  ƒ d k rL |  d  }  n  t t |  ƒ S(   sx  
    Convert a tuple of ints representing a Python version to one of length
    three.

    :param py_version_info: a tuple of ints representing a Python version,
        or None to specify no version. The tuple can have any length.

    :return: a tuple of length three if `py_version_info` is non-None.
        Otherwise, return `py_version_info` unchanged (i.e. None).
    i   i    (   i    (   t   lenR(   t   VersionInfo(   t   py_version_info(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   normalize_version_infoy   s
    c         C@  sC   y t  j |  ƒ Wn+ t k
 r> } | j t j k r? ‚  q? n Xd S(   s    os.path.makedirs without EEXIST.N(   RE   t   makedirst   OSErrort   errnot   EEXIST(   RF   t   e(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR?   �   s
    c          C@  sY   y8 t  j j t j d ƒ }  |  d k r3 d t j S|  SWn t t t f k
 rT n Xd S(   Ni    s   __main__.pys   -cs	   %s -m pipt   pip(   s   __main__.pys   -c(	   RE   RF   t   basenameRL   t   argvt
   executablet   AttributeErrort	   TypeErrort
   IndexError(   t   prog(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR9   —   s    t   stop_max_delayi¸  t
   wait_fixediô  c         C@  s   t  j |  d | d t ƒd  S(   Nt   ignore_errorst   onerror(   t   shutilR,   t   rmtree_errorhandler(   t   dirRc   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR,   ¥   s    c         C@  sA   t  j | ƒ j t j @r: t  j | t j ƒ |  | ƒ d S‚  d S(   sÑ   On Windows, the files in .svn are read-only, so when rmtree() tries to
    remove them, an exception is thrown.  We catch that here, remove the
    read-only attribute, and hopefully continue without problems.N(   RE   t   statt   st_modet   S_IREADt   chmodt   S_IWRITE(   t   funcRF   t   exc_info(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyRf   ¬   s
    
c         C@  s�   |  d k r d St |  t ƒ r# |  Sy |  j t j ƒ  d ƒ } Wn; t k
 r| t rm t d j	 |  ƒ ƒ } q} t
 |  ƒ } n X| S(   sû   
    Convert a bytes (or text) path to text (unicode in Python 2) for display
    and logging purposes.

    This function should never error out. Also, this function is mainly needed
    for Python 2 since in Python 3 str paths are already text.
    t   stricts   b{!r}N(   t   Nonet
   isinstanceR   t   decodeRL   t   getfilesystemencodingt   UnicodeDecodeErrorR   R   RK   t   ascii(   RF   R-   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   path_to_display»   s    	c         C@  s¤   t  j j t  j j |  ƒ ƒ }  t j d d k rd |  j t j ƒ  d ƒ }  |  j t j	 ƒ  d ƒ }  n  |  j
 t  j ƒ  t  j j ƒ r  d |  t t  j ƒ  ƒ }  n  |  S(   sT   Gives the display value for a given path, making it relative to cwd
    if possible.i    i   t   replacet   .(   RE   RF   t   normcaseRJ   RL   t   version_infoRr   Rs   t   encodet   getdefaultencodingt
   startswitht   getcwdt   sepRP   (   RF   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR-   Ý   s    s   .bakc         C@  sK   d } | } x4 t  j j |  | ƒ rB | d 7} | t | ƒ } q W|  | S(   s\   Figure out the name of a directory to back up the given dir to
    (adding .bak, .bak2, etc)i   (   RE   RF   t   existst   str(   Rg   t   extt   nt	   extension(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR.   ê   s    
c         C@  sC   x3 t  j j d d ƒ j ƒ  D] } | | k r | Sq Wt |  | ƒ S(   Nt   PIP_EXISTS_ACTIONt    (   RE   t   environt   gett   splitR/   (   t   messaget   optionst   action(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   ask_path_existsö   s    "c         C@  s)   t  j j d ƒ r% t d |  ƒ ‚ n  d S(   s&   Raise an error if no input is allowed.t   PIP_NO_INPUTs7   No input was expected ($PIP_NO_INPUT set); question: %sN(   RE   R‡   Rˆ   t	   Exception(   RŠ   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   _check_no_inputþ   s    c         C@  s^   xW t  |  ƒ t |  ƒ } | j ƒ  j ƒ  } | | k rR d | d j | ƒ f GHq | Sq Wd S(   s@   Ask the message interactively, with the given possible responsess<   Your response (%r) was not one of the expected responses: %ss   , N(   R�   R   t   stript   lowerRG   (   RŠ   R‹   t   response(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR/     s    
c         C@  s   t  |  ƒ t |  ƒ S(   s   Ask for input interactively.(   R�   R   (   RŠ   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt	   ask_input  s    
c         C@  s   t  |  ƒ t j |  ƒ S(   s!   Ask for a password interactively.(   R�   t   getpass(   RŠ   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   ask_password  s    
c         C@  sX   |  d k r d |  d d S|  d	 k r4 d |  d S|  d k rL d |  d Sd |  Sd  S(
   Niè  s   %.1fMBg     @�@i
   s   %ikBs   %.1fkBs   %ibytesi@B i'  (    (   t   bytes(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR1   &  s    c         C@  sp   t  j j |  ƒ s t St  j j |  d ƒ } t  j j | ƒ rA t St  j j |  d ƒ } t  j j | ƒ rl t St S(   sB   Is path is a directory containing setup.py or pyproject.toml?
    s   setup.pys   pyproject.toml(   RE   RF   t   isdirt   FalseRG   t   isfilet   True(   RF   t   setup_pyt   pyproject_toml(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR2   2  s    c         C@  s(   t  j d |  ƒ o' t  j d |  t  j ƒ S(   sT   
    Returns true if the page appears to be the index page of an svn repository
    s   <title>[^<]*Revision \d+:s#   Powered by (?:<a[^>]*?>)?Subversion(   t   ret   searcht   I(   t   html(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR3   A  s    c         C@  s/   t  |  d ƒ � } | j ƒ  j d ƒ SWd  QXd  S(   Nt   rbs   utf-8(   t   opent   readRr   (   t   filenamet   fp(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR4   J  s    c         c@  s/   x( t  r* |  j | ƒ } | s" Pn  | Vq Wd S(   s7   Yield pieces of data from a file-like object until EOF.N(   R›   R¤   (   t   filet   sizet   chunk(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   read_chunksP  s
    	c         C@  s”   |  j  d ƒ j  d ƒ }  d |  k rj d |  k rN |  j d ƒ |  j d ƒ k  sZ d |  k rj |  j d d ƒ Sd |  k r† |  j d d ƒ S|  d g Sd  S(   Nt   /s   \i   R†   (   t   lstript   findR‰   (   RF   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR5   Y  s    6c         C@  s\   d } xO |  D]G } t | ƒ \ } } | s/ t S| d k rD | } q | | k r t Sq Wt S(   sy   Returns true if all the paths have the same leading path name
    (i.e., everything is in one subdirectory in an archive)N(   Rp   R5   R™   R›   (   t   pathst   common_prefixRF   t   prefixt   rest(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR6   e  s    	c         C@  sI   t  |  ƒ }  | r' t j j |  ƒ }  n t j j |  ƒ }  t j j |  ƒ S(   sN   
    Convert a path to its canonical, case-normalized, absolute version.

    (   R   RE   RF   t   realpathRJ   Ry   (   RF   t   resolve_symlinks(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR7   u  s
    c         C@  sO   t  j |  ƒ \ } } | j ƒ  j d ƒ rE | d | } | d  } n  | | f S(   s,   Like os.path.splitext, but take off .tar toos   .tariüÿÿÿ(   t	   posixpathR0   R’   t   endswith(   RF   t   baseR‚   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR0   ƒ  s
    c         C@  s§   t  j j | ƒ \ } } | rG | rG t  j j | ƒ rG t  j | ƒ n  t j |  | ƒ t  j j |  ƒ \ } } | r£ | r£ y t  j | ƒ Wq£ t k
 rŸ q£ Xn  d S(   s7   Like os.renames(), but handles renaming across devices.N(	   RE   RF   R‰   R€   RT   Re   t   movet
   removedirsRU   (   t   oldt   newt   headt   tail(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR8   �  s    c         C@  s)   t  ƒ  s t St |  ƒ j t t j ƒ ƒ S(   s›   
    Return True if path is within sys.prefix, if we're running in a virtualenv.

    If we're not in a virtualenv, all paths are considered "local."

    (   R   R›   R7   R}   RL   R°   (   RF   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   is_localŸ  s    	c         C@  s   t  t |  ƒ ƒ S(   s�   
    Return True if given Distribution object is installed locally
    (i.e. within current virtualenv).

    Always True if we're not in a virtualenv.

    (   R½   t   dist_location(   t   dist(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   dist_is_local¬  s    	c         C@  s%   t  t |  ƒ ƒ } | j t  t ƒ ƒ S(   sF   
    Return True if given Distribution is installed in user site.
    (   R7   R¾   R}   R   (   R¿   t	   norm_path(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   dist_in_usersite¸  s    c         C@  s   t  t |  ƒ ƒ j t  t ƒ ƒ S(   s[   
    Return True if given Distribution is installed in
    sysconfig.get_python_lib().
    (   R7   R¾   R}   R   (   R¿   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   dist_in_site_packagesÁ  s    c         C@  sJ   xC t  j D]8 } t j j | |  j d ƒ } t j j | ƒ r
 t Sq
 Wt S(   sC   
    Return True if given Distribution is an editable install.
    s	   .egg-link(   RL   RF   RE   RG   t   project_nameRš   R›   R™   (   R¿   t	   path_itemt   egg_link(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   dist_is_editableÌ  s
    c         C@  sÝ   | r t  j | ƒ } n	 t  j } |  r0 t } n	 d „  } | rK d „  } n	 d „  } | rf d „  }	 n	 d „  }	 | r~ t }
 n	 d „  }
 g  | D]K } | | ƒ rŽ | j | k rŽ | | ƒ rŽ |	 | ƒ rŽ |
 | ƒ rŽ | ^ qŽ S(   s^  
    Return a list of installed Distribution objects.

    If ``local_only`` is True (default), only return installations
    local to the current virtualenv, if in a virtualenv.

    ``skip`` argument is an iterable of lower-case project names to
    ignore; defaults to stdlib_pkgs

    If ``include_editables`` is False, don't report editables.

    If ``editables_only`` is True , only report editables.

    If ``user_only`` is True , only report installations in the user
    site directory.

    If ``paths`` is set, only report the distributions present at the
    specified list of locations.
    c         S@  s   t  S(   N(   R›   (   t   d(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt
   local_testü  s    c         S@  s   t  S(   N(   R›   (   RÈ   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   editable_test   s    c         S@  s   t  |  ƒ S(   N(   RÇ   (   RÈ   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyRÊ     s    c         S@  s
   t  |  ƒ S(   N(   RÇ   (   RÈ   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   editables_only_test  s    c         S@  s   t  S(   N(   R›   (   RÈ   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyRË   
  s    c         S@  s   t  S(   N(   R›   (   RÈ   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt	   user_test  s    (   R   t
   WorkingSett   working_setRÀ   RÂ   t   key(   t
   local_onlyt   skipt   include_editablest   editables_onlyt	   user_onlyR®   RÎ   RÉ   RÊ   RË   RÌ   RÈ   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   get_installed_distributionsØ  s*    							c         C@  s¸   g  } t  ƒ  rN t ƒ  r( | j t ƒ qq | j t ƒ t rq | j t ƒ qq n# t rd | j t ƒ n  | j t ƒ x@ | D]8 } t j j | |  j ƒ d } t j j	 | ƒ rx | Sqx Wd S(   s  
    Return the path for the .egg-link file if it exists, otherwise, None.

    There's 3 scenarios:
    1) not in a virtualenv
       try to find in site.USER_SITE, then site_packages
    2) in a no-global virtualenv
       try to find in site_packages
    3) in a yes-global virtualenv
       try to find in site_packages, then site.USER_SITE
       (don't look in global location)

    For #1 and #3, there could be odd cases, where there's an egg-link in 2
    locations.

    This method will just return the first one found.
    s	   .egg-linkN(   R   R   t   appendR   R   RE   RF   RG   RÄ   Rš   Rp   (   R¿   t   sitest   sitet   egglink(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   egg_link_path  s    		c         C@  s   t  |  ƒ } | r | S|  j S(   sÿ   
    Get the site-packages location of this distribution. Generally
    this is dist.location, except in the case of develop-installed
    packages, where dist.location is the source code location, and we
    want to know where the egg-link file is.

    (   RÚ   t   location(   R¿   RÆ   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR¾   D  s    	c          C@  s    t  j d ƒ }  t  j |  ƒ |  S(   sB   Get the current umask which involves having to set it temporarily.i    (   RE   t   umask(   t   mask(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   current_umaskS  s    c         C@  sŠ  t  | ƒ t |  d ƒ } z_t j | d t ƒ} t | j ƒ  ƒ oF | } x+| j ƒ  D]} | j } | } | r„ t	 | ƒ d } n  t
 j j | | ƒ } t
 j j | ƒ }	 | j d ƒ sÉ | j d ƒ rÖ t  | ƒ qV t  |	 ƒ | j | ƒ }
 z, t | d ƒ � } t j |
 | ƒ Wd QXWd |
 j ƒ  | j d ?} | rrt j | ƒ rr| d	 @rrt
 j | d
 t ƒ  d	 Bƒ n  XqV WWd | j ƒ  Xd S(   sŸ  
    Unzip the file (with path `filename`) to the destination `location`.  All
    files are written based on system defaults and umask (i.e. permissions are
    not preserved), except that regular file members with any execute
    permissions (user, group, or world) have "chmod +x" applied after being
    written. Note that for windows, any execute changes using os.chmod are
    no-ops per the python docs.
    R¢   t
   allowZip64i   R«   s   \t   wbNi   iI   iÿ  (   R?   R£   t   zipfilet   ZipFileR›   R6   t   namelistt   infolistR¥   R5   RE   RF   RG   RH   Rµ   Re   t   copyfileobjt   closet   external_attrRh   t   S_ISREGRk   RÞ   (   R¥   RÛ   t   flattent   zipfpt   zipt   leadingt   infot   namet   fnRg   R¦   t   destfpt   mode(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR:   Z  s0    

	

'c         C@  s‡  t  | ƒ |  j ƒ  j d ƒ s4 |  j ƒ  j d ƒ r= d } np |  j ƒ  j t ƒ r[ d } nR |  j ƒ  j t ƒ ry d } n4 |  j ƒ  j d ƒ r— d } n t j d |  ƒ d	 } t j |  | ƒ } z¶t	 g  | j
 ƒ  D] } | j ^ qÒ ƒ } x‡| j
 ƒ  D]y} | j } | rt | ƒ d
 } n  t j j | | ƒ } | j ƒ  rMt  | ƒ q÷ | j ƒ  r¢y | j | | ƒ Wqpt k
 rž} t j d |  | j | ƒ q÷ qpXq÷ y | j | ƒ }	 Wn5 t t f k
 rì} t j d |  | j | ƒ q÷ n Xt  t j j | ƒ ƒ t | d ƒ � }
 t j |	 |
 ƒ Wd QX|	 j ƒ  | j | | ƒ | j d @r÷ t j | d t ƒ  d Bƒ q÷ q÷ WWd | j ƒ  Xd S(   sŸ  
    Untar the file (with path `filename`) to the destination `location`.
    All files are written based on system defaults and umask (i.e. permissions
    are not preserved), except that regular file members with any execute
    permissions (user, group, or world) have "chmod +x" applied after being
    written.  Note that for windows, any execute changes using os.chmod are
    no-ops per the python docs.
    s   .gzs   .tgzs   r:gzs   r:bz2s   r:xzs   .tart   rs-   Cannot determine compression type for file %ss   r:*i   s/   In the tar file %s the member %s is invalid: %sRà   NiI   iÿ  (   R?   R’   Rµ   t   BZ2_EXTENSIONSt   XZ_EXTENSIONSt   loggert   warningt   tarfileR£   R6   t
   getmembersRî   R5   RE   RF   RG   R˜   t   issymt   _extract_memberR�   t   extractfilet   KeyErrorR]   RH   Re   Rå   Ræ   t   utimeRñ   Rk   RÞ   (   R¥   RÛ   Rñ   t   tart   memberRì   Rï   RF   t   excR¦   Rð   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR;   ˆ  s\    

*				
%	

&c         C@  s1  t  j j |  ƒ }  | d k sB |  j ƒ  j t ƒ sB t j |  ƒ rb t |  | d |  j d ƒ ƒnË | d k sš t	 j
 |  ƒ sš |  j ƒ  j t t t ƒ rª t |  | ƒ nƒ | r| j d ƒ rt t |  ƒ ƒ rd d l m } d | j } | ƒ  j | d	 | ƒn& t j d
 |  | | ƒ t d | ƒ ‚ d  S(   Ns   application/zipRé   s   .whls   application/x-gzips	   text/htmli    (   t
   Subversions   svn+t   urlsZ   Cannot unpack file %s (downloaded from %s, content-type: %s); cannot detect archive formats%   Cannot determine archive format of %s(   RE   RF   R²   R’   Rµ   t   ZIP_EXTENSIONSRá   t
   is_zipfileR:   R÷   t
   is_tarfilet   TAR_EXTENSIONSRó   Rô   R;   R}   R3   R4   t   pip._internal.vcs.subversionR  R  t   unpackRõ   t   criticalR   (   R¥   RÛ   t   content_typet   linkR  R  (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR<   Ô  s.    c         C@  s   d j  d „  |  Dƒ ƒ S(   s/   
    Format command arguments for display.
    t    c         s@  s   |  ] } t  | ƒ Vq d  S(   N(   R   (   t   .0t   arg(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pys	   <genexpr>  s    (   RG   (   t   args(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   format_command_argsü  s    c   	      C@  ss   t  |  ƒ } t | d d ƒ} t | ƒ } d j | ƒ } d j d | d | d | d t | ƒ d	 | d
 t ƒ } | S(   s§   
    Create and return the error message to use to log a subprocess error
    with command output.

    :param lines: A list of lines, each ending with a newline.
    t   descs   command bytesR†   uŸ   Command errored out with exit status {exit_status}:
 command: {command_display}
     cwd: {cwd_display}
Complete output ({line_count} lines):
{output}{divider}t   exit_statust   command_displayt   cwd_displayt
   line_countt   outputt   divider(   R  R   Rv   RG   RK   RP   t   LOG_DIVIDER(	   t   cmd_argst   cwdt   linesR  t   commandR  R  R  t   msg(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   make_subprocess_output_error  s    		t   raisec	         C@  s  | d	 k r g  } n  | d	 k r* g  } n  | rE t j }	 t j }
 n t j }	 t j }
 t j ƒ  |
 k } | oy | d	 k	 } | d	 k r— t |  ƒ } n  |	 d | ƒ t	 j
 j ƒ  } | rÉ | j | ƒ n  x | D] } | j | d	 ƒ qÐ WyG t j |  d t j d t j d t j d | d | ƒ} | j j ƒ  Wn) t k
 r\} t j d | | ƒ ‚  n Xg  } xc t rÈt | j j ƒ  ƒ } | s‹Pn  | j ƒ  } | j | d ƒ |	 | ƒ | rf| j ƒ  qfqfWz | j ƒ  Wd	 | j ró| j j ƒ  n  X| j o	| j | k } | r8| r(| j d
 ƒ q8| j d ƒ n  | rø| d k r¨| s„t  d |  d | d | d | j ƒ } t j! | ƒ n  d j" | j | ƒ } t# | ƒ ‚ qø| d k rÐt j$ d | | j | ƒ qø| d k rßqøt% d t& | ƒ ƒ ‚ n  d j' | ƒ S(   s   
    Args:
      show_stdout: if true, use INFO to log the subprocess's stderr and
        stdout streams.  Otherwise, use DEBUG.  Defaults to False.
      extra_ok_returncodes: an iterable of integer return codes that are
        acceptable, in addition to 0. Defaults to None, which means [].
      unset_environ: an iterable of environment variable names to unset
        prior to calling subprocess.Popen().
    s   Running command %st   stderrt   stdint   stdoutR  t   envs#   Error %s while executing command %ss   
Nt   errort   doneR  R  R  R  sS   Command errored out with exit status {}: {} Check the logs for full command output.t   warns$   Command "%s" had error code %s in %st   ignores   Invalid value: on_returncode=%sR†   ((   Rp   t   subprocess_loggerRí   t   std_loggingt   INFOt   debugt   DEBUGt   getEffectiveLevelR  RE   R‡   t   copyt   updatet   popt
   subprocesst   Popent   STDOUTt   PIPER!  Ræ   R�   R	  R›   R   R"  t   readlinet   rstripRÖ   t   spint   waitt
   returncodet   finishR  R$  RK   R   Rö   t
   ValueErrort   reprRG   (   t   cmdt   show_stdoutR  t   on_returncodet   extra_ok_returncodest   command_desct   extra_environt   unset_environt   spinnert   log_subprocesst
   used_levelt   showing_subprocesst   use_spinnerR#  Rî   t   procR   t
   all_outputt   linet   proc_had_errorR  t   exc_msg(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR=   .  sˆ    						
	c         C@  s   t  j |  ƒ t |  ƒ d  S(   N(   RE   RT   R   (   t	   build_dir(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   _make_build_dir´  s    t   FakeFilec           B@  s)   e  Z d  Z d „  Z d „  Z d „  Z RS(   sQ   Wrap a list of lines in an object with readline() to make
    ConfigParser happy.c         C@  s   d „  | Dƒ |  _  d  S(   Nc         s@  s   |  ] } | Vq d  S(   N(    (   R  t   l(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pys	   <genexpr>½  s    (   t   _gen(   t   selfR  (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   __init__¼  s    c         C@  sL   y3 y t  |  j ƒ SWn t k
 r1 |  j j  ƒ  SXWn t k
 rG d SXd  S(   NR†   (   t   nextRR  t	   NameErrort   StopIteration(   RS  (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR5  ¿  s    c         C@  s   |  j  S(   N(   RR  (   RS  (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   __iter__È  s    (   t   __name__t
   __module__t   __doc__RT  R5  RX  (    (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyRP  ¹  s   			t   StreamWrapperc           B@  s&   e  Z e d  „  ƒ Z e d „  ƒ Z RS(   c         C@  s   | |  _  |  ƒ  S(   N(   t   orig_stream(   t   clsR]  (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   from_streamÎ  s    	c         C@  s
   |  j  j S(   N(   R]  t   encoding(   RS  (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR`  Ô  s    (   RY  RZ  t   classmethodR_  t   propertyR`  (    (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR\  Ì  s   c         c@  sR   t  t |  ƒ } t t |  t j | ƒ ƒ z t  t |  ƒ VWd t t |  | ƒ Xd S(   sË   Return a context manager used by captured_stdout/stdin/stderr
    that temporarily replaces the sys stream *stream_name* with a StringIO.

    Taken from Lib/support/__init__.py in the CPython repo.
    N(   t   getattrRL   t   setattrR\  R_  (   t   stream_namet   orig_stdout(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   captured_outputÙ  s
    c           C@  s
   t  d ƒ S(   sÜ   Capture the output of sys.stdout:

       with captured_stdout() as stdout:
           print('hello')
       self.assertEqual(stdout.getvalue(), 'hello
')

    Taken from Lib/support/__init__.py in the CPython repo.
    R"  (   Rg  (    (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyR>   è  s    	c           C@  s
   t  d ƒ S(   s    
    See captured_stdout().
    R   (   Rg  (    (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   captured_stderrô  s    t   cached_propertyc           B@  s    e  Z d  Z d „  Z d „  Z RS(   sô   A property that is only computed once per instance and then replaces
       itself with an ordinary attribute. Deleting the attribute resets the
       property.

       Source: https://github.com/bottlepy/bottle/blob/0.11.5/bottle.py#L175
    c         C@  s   t  | d ƒ |  _ | |  _ d  S(   NR[  (   Rc  R[  Rm   (   RS  Rm   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyRT    s    c         C@  s4   | d  k r |  S|  j | ƒ } | j |  j j <| S(   N(   Rp   Rm   t   __dict__RY  (   RS  t   objR^  t   value(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   __get__  s     (   RY  RZ  R[  RT  Rm  (    (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyRi  û  s   	c         C@  sM   t  j j |  ƒ } | d k r- t  j ƒ  } n  | j | ƒ } | rI | j Sd S(   sC   Get the installed version of dist_name avoiding pkg_resources cacheN(   R   t   RequirementR   Rp   RÍ   R­   RM   (   t	   dist_nameRÎ   t   reqR¿   (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyRC     s
    c         C@  s   t  |  d d ƒd S(   s   Consume an iterable at C speed.t   maxleni    N(   R   (   t   iterator(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   consume!  s    c          O@  sT   t  t |  t t |  ƒ ƒ ƒ | � } d „  | j ƒ  Dƒ } | | d <t d d | ƒ S(   Nc         S@  s   i  |  ] \ } } | | “ q S(    (    (   R  RÏ   Rl  (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pys
   <dictcomp>)  s   	 t   reverse_mappingt   Enum(    (   t   dictRë   t   rangeRP   t   itemst   type(   t
   sequentialt   namedt   enumst   reverse(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   enum'  s    $
c         C@  s=   t  j j t  j j |  ƒ ƒ }  t j d t j |  ƒ ƒ } | S(   sh   
    Convert a path to a file: URL.  The path will be made absolute and have
    quoted path parts.
    s   file:(   RE   RF   t   normpathRJ   t   urllib_parset   urljoint   urllib_requestt   pathname2url(   RF   R  (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   path_to_url.  s    c         C@  s{   d |  k r |  d f S|  j d d ƒ \ } }  d | k rO | j d d ƒ } n | d f } t d „  | Dƒ ƒ } |  | f S(   sp   
    Parse out and remove the auth information from a netloc.

    Returns: (netloc, (username, password)).
    t   @i   t   :c         s@  s-   |  ]# } | d  k r d  n	 t | ƒ Vq d  S(   N(   Rp   t   urllib_unquote(   R  t   x(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pys	   <genexpr>O  s    N(   NN(   Rp   t   rsplitR‰   t   tuple(   t   netloct   autht	   user_pass(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   split_auth_from_netloc9  s    
c         C@  se   t  |  ƒ \ }  \ } } | d k r( |  S| d k r: d n d } d j d t j | ƒ d | d |  ƒ S(   s�   
    Replace the password in a netloc with "****", if it exists.

    For example, "user:pass@example.com" returns "user:****@example.com".
    R†   s   :****s   {user}{password}@{netloc}t   usert   passwordR‹  N(   RŽ  Rp   RK   R€  t   quote(   R‹  R�  R�  (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   redact_netlocU  s    c         C@  s\   t  j |  ƒ } | | j ƒ } | j | d | j | j | j f } t  j | ƒ } | | f S(   sR  Transform and replace netloc in a url.

    transform_netloc is a function taking the netloc and returning a
    tuple. The first element of this tuple is the new netloc. The
    entire tuple is returned.

    Returns a tuple containing the transformed url as item 0 and the
    original tuple returned by transform_netloc as item 1.
    i    (   R€  t   urlsplitR‹  t   schemeRF   t   queryt   fragmentt
   urlunsplit(   R  t   transform_netloct   purlt   netloc_tuplet
   url_piecest   surl(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   _transform_urle  s
    
%c         C@  s
   t  |  ƒ S(   N(   RŽ  (   R‹  (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   _get_netlocy  s    c         C@  s   t  |  ƒ f S(   N(   R’  (   R‹  (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   _redact_netloc}  s    c         C@  s(   t  |  t ƒ \ } \ } } | | | f S(   s†   
    Parse a url into separate netloc, auth, and url with no auth.

    Returns: (url_without_auth, netloc, (username, password))
    (   R�  Rž  (   R  t   url_without_authR‹  RŒ  (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   split_auth_netloc_from_url�  s    c         C@  s   t  |  t ƒ d S(   s7   Return a copy of url with 'username:password@' removed.i    (   R�  Rž  (   R  (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyRD   Œ  s    c         C@  s   t  |  t ƒ d S(   s.   Replace the password in a given url with ****.i    (   R�  RŸ  (   R  (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   redact_password_from_url”  s    c         C@  s¢   d d j  t j d ƒ d j  t j d  Œ  g } |  oW t oW t j j t j d ƒ | k } | rž t j d d g t j d } t	 d	 j  d
 j
 | ƒ ƒ ƒ ‚ n  d S(   s�   Protection of pip.exe from modification on Windows

    On Windows, any operation modifying pip should be run as:
        python -m pip ...
    s   pip.exes	   pip{}.exei    s   pip{}.{}.exei   s   -mRY   i   s3   To modify pip, please run the following command:
{}R  N(   RK   RL   Rz   R   RE   RF   RZ   R[   R\   R   RG   (   t   modifying_pipt	   pip_namest   should_show_use_python_msgt   new_command(    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt(   protect_pip_from_modification_on_windowsš  s    (   s   .tar.bz2s   .tbz(   s   .tar.xzs   .txzs   .tlzs   .tar.lzs	   .tar.lzma(   s   .tar.gzs   .tgzs   .tar(£   t
   __future__R    t
   contextlibRV   R•   t   iot   loggingR)  RE   R´   Rž   Re   Rh   R1  RL   R÷   Rá   t   collectionsR   t   pip._vendorR   t   pip._vendor.retryingR   t   pip._vendor.sixR   R   t   pip._vendor.six.movesR   R   t   pip._vendor.six.moves.urllibR   R€  R	   R‚  t"   pip._vendor.six.moves.urllib.parseR
   R‡  RY   R   t   pip._internal.exceptionsR   R   t   pip._internal.locationsR   R   t   pip._internal.utils.compatR   R   R   R   R   t    pip._internal.utils.marker_filesR   t   pip._internal.utils.typingR   t   pip._internal.utils.virtualenvR   R   R   R   t   typingR   R   R   R   R   R    R!   R"   R#   R$   t   pip._vendor.pkg_resourcesR%   t   pip._internal.models.linkR&   t   pip._internal.utils.uiR'   R(   R)   t   intRQ   t   ImportErrorRp   t   __all__t	   getLoggerRY  Rõ   R(  R  RB   Ró   Rô   R  R  R@   RA   t   bz2R+  t   lzmaRO   RS   R?   R9   R™   R,   Rf   Rv   R-   R.   R�   R�   R/   R”   R–   R1   R2   R3   R4   t   DEFAULT_BUFFER_SIZERª   R5   R6   R›   R7   R0   R8   R½   RÀ   RÂ   RÃ   RÇ   RÕ   RÚ   R¾   RÞ   R:   R;   R<   R  R  R=   RO  t   objectRP  R\  t   contextmanagerRg  R>   Rh  Ri  RC   Rs  R~  R„  RŽ  R’  R�  Rž  RŸ  R¡  RD   R¢  R§  (    (    (    s5   /tmp/pip-build-sZz8gW/pip/pip/_internal/utils/misc.pyt   <module>   s$  (F	
		
			
			"			
												
							?	'		.	L	(		,}														