
в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 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 m Z m Z d d l m Z m Z m Z m Z m Z d d l m Z d d l m  Z  m! Z! m" Z" m# Z# d d	 l$ m% Z% m& Z& m' Z' m( Z( m) Z) m* Z* m+ Z+ m, Z, m- Z- d d
 l. m/ Z/ m0 Z0 e j1 e2  Z3 e4 a5 e6 e d  rd Z7 n9 e j8 j9 d  rd Z7 n e j8 d k rd Z7 n d Z7 e j: d  Z; e; r*d e j< d  Z; n  d e; Z= e7 e; Z> e j$ j?   j@ d d  j@ d d  ZA e j: d  ZB eB oeB j9 d  reB j@ d d  ZB n d   ZC eC   ZB [C e jD d e jE e jF B ZG e jD d e jE e jF B ZH e jD d  ZI e jD d  ZJ d  ZK d! ZL e jM d" k r0d#   ZN n	 d$   ZN d% eO f d&     YZP eP   ZQ d' eO f d(     YZR d)   ZS eS   ZT [S e4 d*  ZU d S(+   i(   t   unicode_literalsN(   t   message_from_filei   (   t   __version__t   DistlibException(   t	   sysconfigt   ZipFilet   fsdecodet	   text_typet   filter(   t   InstalledDistribution(   t   Metadatat   METADATA_FILENAMEt   WHEEL_METADATA_FILENAMEt   LEGACY_METADATA_FILENAME(	   t   FileOperatort   convert_patht	   CSVReadert	   CSVWritert   Cachet   cached_propertyt   get_cache_baset   read_exportst   tempdir(   t   NormalizedVersiont   UnsupportedVersionErroru   pypy_version_infou   ppu   javau   jyu   cliu   ipu   cpu   py_version_nodotu   %s%si   u   pyu   -u   _u   .u   SOABIu   cpython-c          C  s|   d t  g }  t j d  r+ |  j d  n  t j d  rJ |  j d  n  t j d  d k ro |  j d  n  d	 j |   S(
   Nu   cpu   Py_DEBUGu   du   WITH_PYMALLOCu   mu   Py_UNICODE_SIZEi   u   uu    (   t
   VER_SUFFIXR   t   get_config_vart   appendt   join(   t   parts(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   _derive_abi<   s    uz   
(?P<nm>[^-]+)
-(?P<vn>\d+[^-]*)
(-(?P<bn>\d+[^-]*))?
-(?P<py>\w+\d+(\.\w+\d+)*)
-(?P<bi>\w+)
-(?P<ar>\w+(\.\w+)*)
\.whl$
u7   
(?P<nm>[^-]+)
-(?P<vn>\d+[^-]*)
(-(?P<bn>\d+[^-]*))?$
s   \s*#![^\r\n]*s   ^(\s*#!("[^"]+"|\S+))\s+(.*)$s   #!pythons	   #!pythonwu   /c         C  s   |  S(   N(    (   t   o(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   <lambda>^   t    c         C  s   |  j  t j d  S(   Nu   /(   t   replacet   ost   sep(   R   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyR    `   R!   t   Mounterc           B  s8   e  Z d    Z d   Z d   Z d d  Z d   Z RS(   c         C  s   i  |  _  i  |  _ d  S(   N(   t   impure_wheelst   libs(   t   self(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   __init__d   s    	c         C  s!   | |  j  | <|  j j |  d  S(   N(   R&   R'   t   update(   R(   t   pathnamet
   extensions(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   addh   s    c         C  sI   |  j  j |  } x0 | D]( \ } } | |  j k r |  j | =q q Wd  S(   N(   R&   t   popR'   (   R(   R+   R,   t   kt   v(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   removel   s    c         C  s"   | |  j  k r |  } n d  } | S(   N(   R'   t   None(   R(   t   fullnamet   patht   result(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   find_moduler   s    	c         C  s   | t  j k r t  j | } nx | |  j k rA t d |   n  t j | |  j |  } |  | _ | j d d  } t |  d k r | d | _	 n  | S(   Nu   unable to find extension for %su   .i   i    (
   t   syst   modulesR'   t   ImportErrort   impt   load_dynamict
   __loader__t   rsplitt   lent   __package__(   R(   R3   R5   R   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   load_moduley   s    	N(   t   __name__t
   __module__R)   R-   R1   R2   R6   R@   (    (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyR%   c   s
   			t   Wheelc           B  s  e  Z d  Z d Z d Z d e e d  Z e d    Z	 e d    Z
 e d    Z e d    Z d   Z e d	    Z d
   Z d d  Z d   Z d   Z d   Z d d d  Z d   Z d   Z d   Z d   Z d   Z d   Z e d  Z d   Z d   Z d d  Z RS(   u@   
    Class to build and install from Wheel files (PEP 427).
    i   u   sha256c         C  s  | |  _  | |  _ d |  _ t g |  _ d g |  _ d g |  _ t j   |  _	 | d k r{ d |  _ d |  _ |  j |  _ nEt j |  } | r | j d  } | d |  _ | d j d d	  |  _ | d
 |  _ |  j |  _ n t j j |  \ } } t j |  } | s!t d |   n  | r?t j j |  |  _	 n  | |  _ | j d  } | d |  _ | d |  _ | d
 |  _ | d j d  |  _ | d j d  |  _ | d j d  |  _ d S(   uB   
        Initialise an instance using a (valid) filename.
        u    u   noneu   anyu   dummyu   0.1u   nmu   vnu   _u   -u   bnu   Invalid name or filename: %ru   pyu   .u   biu   arN(   t   signt   should_verifyt   buildvert   PYVERt   pyvert   abit   archR#   t   getcwdt   dirnameR2   t   namet   versiont   filenamet	   _filenamet   NAME_VERSION_REt   matcht	   groupdictR"   R4   t   splitt   FILENAME_RER   t   abspath(   R(   RO   RD   t   verifyt   mt   infoRL   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyR)      sB    						c         C  s   |  j  r d |  j  } n d } d j |  j  } d j |  j  } d j |  j  } |  j j d d  } d |  j | | | | | f S(   uJ   
        Build and return a filename from the various components.
        u   -u    u   .u   _u   %s-%s%s-%s-%s-%s.whl(   RF   R   RH   RI   RJ   RN   R"   RM   (   R(   RF   RH   RI   RJ   RN   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyRO      s    	c         C  s+   t  j j |  j |  j  } t  j j |  S(   N(   R#   R4   R   RL   RO   t   isfile(   R(   R4   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   exists   s    c         c  sN   xG |  j  D]< } x3 |  j D]( } x |  j D] } | | | f Vq* Wq Wq
 Wd  S(   N(   RH   RI   RJ   (   R(   RH   RI   RJ   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   tags   s    c         C  s\  t  j j |  j |  j  } d |  j |  j f } d | } t j d  } t	 | d   } |  j
 |  } | d j d d  } t g  | D] } t |  ^ q  }	 t t g }
 d  } xu |
 D]m } yS t j | |  } | j |  , } | |  } t d |  } | rPn  Wd  QXWq t k
 r+q Xq W| sRt d	 d
 j |
    n  Wd  QX| S(   Nu   %s-%su   %s.dist-infou   utf-8u   ru   Wheel-Versionu   .i   t   fileobju8   Invalid wheel, because metadata is missing: looked in %su   , (   R#   R4   R   RL   RO   RM   RN   t   codecst	   getreaderR   t   get_wheel_metadataRT   t   tuplet   intR   R   R2   t	   posixpatht   openR
   t   KeyErrort
   ValueError(   R(   R+   t   name_vert   info_dirt   wrappert   zft   wheel_metadatat   wvt   it   file_versiont   fnsR5   t   fnt   metadata_filenamet   bft   wf(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   metadata   s0    
%c         C  su   d |  j  |  j f } d | } t j | d  } | j |  ( } t j d  |  } t |  } Wd  QXt |  S(   Nu   %s-%su   %s.dist-infou   WHEELu   utf-8(	   RM   RN   Rc   R   Rd   R^   R_   R   t   dict(   R(   Rj   Rg   Rh   Rq   Rr   Rs   t   message(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyR`      s    
c         C  sF   t  j j |  j |  j  } t | d   } |  j |  } Wd  QX| S(   Nu   r(   R#   R4   R   RL   RO   R   R`   (   R(   R+   Rj   R5   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyRY      s    c         C  s  t  j |  } | r | j   } | |  | | } } d | j   k rQ t } n t } t j |  } | r d | j   d } n d } | | } | | } ns | j d  } | j d  }	 | d k  s | |	 k r d }
 n& | | | d !d	 k r d	 }
 n d }
 t |
 | } | S(
   Nt   pythonwt    iR!   s   s   
i    i   s   
(	   t
   SHEBANG_RERR   t   endt   lowert   SHEBANG_PYTHONWt   SHEBANG_PYTHONt   SHEBANG_DETAIL_REt   groupst   find(   R(   t   dataRX   Rz   t   shebangt   data_after_shebangt   shebang_pythont   argst   crt   lft   term(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   process_shebang  s,    	
		c         C  s   | d  k r |  j } n  y t t |  } Wn! t k
 rN t d |   n X| |  j   } t j |  j	 d  j
 d  } | | f S(   Nu   Unsupported hash algorithm: %rt   =u   ascii(   R2   t	   hash_kindt   getattrt   hashlibt   AttributeErrorR   t   digestt   base64t   urlsafe_b64encodet   rstript   decode(   R(   R   R   t   hasherR5   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   get_hash%  s    !c         C  st   t  |  } t t j j | |   } | j | d d f  t |  % } x | D] } | j |  qS WWd  QXd  S(   Nu    (   t   listt   to_posixR#   R4   t   relpathR   R   t   writerow(   R(   t   recordst   record_patht   baset   pt   writert   row(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   write_record0  s    c         C  s   g  } | \ } } t  t |  j  } xs | D]k \ } }	 t |	 d   }
 |
 j   } Wd  QXd |  j |  } t j j |	  } | j	 | | | f  q+ Wt j j
 | d  }	 |  j | |	 |  t t j j
 | d   } | j	 | |	 f  d  S(   Nu   rbu   %s=%su   RECORD(   R   R   R   Rd   t   readR   R#   R4   t   getsizeR   R   R   R   (   R(   RY   t   libdirt   archive_pathsR   t   distinfoRh   R   t   apR   t   fR   R   t   size(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   write_records8  s    c      	   C  s\   t  | d t j  A } x7 | D]/ \ } } t j d | |  | j | |  q WWd  QXd  S(   Nu   wu   Wrote %s to %s in wheel(   R   t   zipfilet   ZIP_DEFLATEDt   loggert   debugt   write(   R(   R+   R   Rj   R   R   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt	   build_zipH  s    c   "   
     s  | d k r i  } n  t t   f d   d&   d } | d k rg d } t g } t g } t g } n! d } t g } d g } d g } | j d	 |  |  _ | j d
 |  |  _	 | j d |  |  _
   | }	 d |  j |  j f }
 d |
 } d |
 } g  } xKd' D]C} |   k r qn    | } t j j |  rxt j |  D] \ } } } x | D] } t t j j | |   } t j j | |  } t t j j | | |   } | j | | f  | d k rb| j d  rbt | d   } | j   } Wd QX|  j |  } t | d   } | j |  Wd QXqbqbWqLWqqW|	 } d } xt j |  D] \ } } } | | k rxU t |  D]G \ } } t |  } | j d  rt j j | |  } | | =PqqW| st d   n  xl | D]d } t |  j d(  rqn  t j j | |  } t t j j | |   } | j | | f  qWqkWt j |  } xf | D]^ } | d) k r|t t j j | |   } t t j j | |   } | j | | f  q|q|Wd | p|  j d t d  | g } x4 |  j  D]) \ } } } | j d! | | | f  qWt j j | d  } t | d"   } | j d# j |   Wd QXt t j j | d   } | j | | f  d$   }  t! | d% |  } |  j" | | f |	 |  t j j |  j# |  j$  }! |  j% |! |  |! S(*   u   
        Build a wheel from files in specified paths, and use any specified tags
        when determining the name of the wheel.
        c           s
   |    k S(   N(    (   R   (   t   paths(    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyR    V  R!   u   purelibu   platlibi    u   falseu   trueu   noneu   anyu   pyveru   abiu   archu   %s-%su   %s.datau   %s.dist-infou   datau   headersu   scriptsu   .exeu   rbNu   wbu
   .dist-infou(   .dist-info directory expected, not foundu   .pycu   .pyou   RECORDu	   INSTALLERu   SHAREDu   WHEELu   Wheel-Version: %d.%du   Generator: distlib %su   Root-Is-Purelib: %su   Tag: %s-%s-%su   wu   
c         S  s<   |  d } | j  d  } d | k r2 | d 7} n  | | f S(   Ni    u   /u
   .dist-infoi'  (   t   count(   t   tR   t   n(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   sorter  s
    
t   key(   u   purelibu   platlib(   u   datau   headersu   scripts(   u   .pycu   .pyo(   u   RECORDu	   INSTALLERu   SHAREDu   WHEEL(&   R2   R   R   t   IMPVERt   ABIt   ARCHRG   t   getRH   RI   RJ   RM   RN   R#   R4   t   isdirt   walkR   R   R   R   R   t   endswithRd   R   R   R   t	   enumeratet   AssertionErrort   listdirt   wheel_versionR   R\   t   sortedR   RL   RO   R   ("   R(   R   R\   R   t   libkeyt   is_puret   default_pyvert   default_abit   default_archR   Rg   t   data_dirRh   R   R   R4   t   roott   dirst   filesRp   R   t   rpR   R   R   R   Rm   t   dnRk   RH   RI   RJ   R   R+   (    (   R   s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   buildN  s    	"					



%	c         C  s   | j  d  S(   ul   
        Determine whether an archive entry should be skipped when verifying
        or installing.
        u   /u   /RECORD.jws(   u   /u   /RECORD.jws(   R   (   R(   t   arcname(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt
   skip_entry  s    c   D      K  s	  | j  } | j d  } | j d t  } | j d t  } t j j |  j |  j  } d |  j |  j	 f }	 d |	 }
 d |	 } t
 j | t  } t
 j | d  } t
 j | d  } t j d	  } t | d
  } | j |   } | |  } t |  } Wd QX| d j d d  } t g  | D] } t |  ^ q( } | |  j k rk| rk| |  j |  n  | d d k r| d } n
 | d } i  } | j |  D } t d |  , } x" | D] } | d } | | | <qWWd QXWd QXt
 j |
 d  } t
 j | d  } t
 j |
 d d  } t d |  }  t |  _ t j }! g  }" t j   }# |# | _ d | _ z9yx| j    D]}$ |$ j }% t! |% t"  r|% }& n |% j# d	  }& |  j$ |&  rqn  | |& } | d r
t% |$ j&  | d k r
t' d |&   n  | d r| d j d d  \ }' }( | j |%   } | j(   }) Wd QX|  j) |) |'  \ }* }+ |+ |( k rt' d |%   qn  | r|& j* | | f  rt+ j, d |&  qn  |& j* |  o|& j- d  }, |& j* |  r*|& j d d  \ }* }- }. t j j | |- t. |.   }/ n3 |& | | f k rBqn  t j j | t. |&   }/ |, so| j |%   } |  j/ | |/  Wd QX|" j0 |/  | r| d rt |/ d  J } | j(   }) |  j) |) |'  \ }* }0 |0 |+ k rt' d  |/   n  Wd QXn  |! r|/ j- d!  ry& |  j1 |/ d" | }1 |" j0 |1  Wqlt2 k
 rht+ j3 d# d$ t qlXqqt j j4 t. |%   }2 t j j |# |2  }3 | j |%   } |  j/ | |3  Wd QXt j j |/  \ }4 }2 |4 | _ | j5 |2  }5 |  j6 |5  |" j7 |5  qW| r.t+ j, d%  d }6 nCd }7 |  j8 d } | d& k rQt
 j | d'  }8 y | j |8   } t9 |  }9 Wd QXi  }7 x d: D] }: d* |: }; |; |9 k ri  |7 d+ |: <}< xd |9 |; j:   D]O }= d, |= j; |= j< f }> |= j= r|> d- d. j |= j=  7}> n  |> |< |= j <qWqqWWqt2 k
 rMt+ j3 d/  qXny yX | j |  C } | |  } t> j? |  j d0  }7 |7 r|7 j d1  }7 n  Wd QXWn t2 k
 rt+ j3 d2  n X|7 r|7 j d3 i   }? |7 j d4 i   }@ |? s |@ r| j d d  }A t j j@ |A  s3tA d5   n  |A | _ xF |? jB   D]8 \ }; }= d6 |; |= f }B | j5 |B  }5 |  j6 |5  qIW|@ ri t d) 6}C xL |@ jB   D]; \ }; }= d6 |; |= f }B | j5 |B |C  }5 |  j6 |5  qWqqn  t j j | |  } tC |  }6 tD |  } | d =| d =| | d7 <|6 jE | |  } | rZ	|" j0 |  n  |6 jF |" | d8 |  |6 SWn+ t2 k
 r	t+ jG d9  |  jH     n XWd tI jJ |#  XWd QXd S(;   u~  
        Install a wheel to the specified paths. If kwarg ``warner`` is
        specified, it should be a callable, which will be called with two
        tuples indicating the wheel version of this software and the wheel
        version in the file, if there is a discrepancy in the versions.
        This can be used to issue any warnings to raise any exceptions.
        If kwarg ``lib_only`` is True, only the purelib/platlib files are
        installed, and the headers, scripts, data and dist-info metadata are
        not written. If kwarg ``bytecode_hashed_invalidation`` is True, written
        bytecode will try to use file-hash based invalidation (PEP-552) on
        supported interpreter versions (CPython 2.7+).

        The return value is a :class:`InstalledDistribution` instance unless
        ``options.lib_only`` is True, in which case the return value is ``None``.
        u   warneru   lib_onlyu   bytecode_hashed_invalidationu   %s-%su   %s.datau   %s.dist-infou   WHEELu   RECORDu   utf-8u   rNu   Wheel-Versionu   .i   u   Root-Is-Purelibu   trueu   purelibu   platlibt   streami    u    u   scriptst   dry_runi   u   size mismatch for %su   =u   digest mismatch for %su   lib_only: skipping %su   .exeu   /u   rbu   digest mismatch on write for %su   .pyt   hashed_invalidationu   Byte-compilation failedt   exc_infou   lib_only: returning Noneu   1.0u   entry_points.txtu   consoleu   guiu
   %s_scriptsu   wrap_%su   %s:%su    [%s]u   ,uA   Unable to read legacy script metadata, so cannot generate scriptsu
   extensionsu   python.commandsu8   Unable to read JSON metadata, so cannot generate scriptsu   wrap_consoleu   wrap_guiu   Valid script path not specifiedu   %s = %su   libu   prefixu   installation failed.(   u   consoleu   gui(K   R   R   t   FalseR#   R4   R   RL   RO   RM   RN   Rc   R   R^   R_   R   Rd   R   RT   Ra   Rb   R   R   R   t   Truet   recordR7   t   dont_write_bytecodet   tempfilet   mkdtempt
   source_dirR2   t
   target_dirt   infolistt
   isinstanceR   R   R   t   strt	   file_sizeR   R   R   t
   startswithR   R   R   R   t   copy_streamR   t   byte_compilet	   Exceptiont   warningt   basenamet   maket   set_executable_modet   extendRY   R   t   valuest   prefixt   suffixt   flagst   jsont   loadR   Rf   t   itemsR	   Ru   t   write_shared_locationst   write_installed_filest	   exceptiont   rollbackt   shutilt   rmtree(D   R(   R   t   makert   kwargsR   t   warnert   lib_onlyt   bc_hashed_invalidationR+   Rg   R   Rh   t   metadata_namet   wheel_metadata_namet   record_nameRi   Rj   t   bwfRs   Rv   Rl   Rm   Rn   R   R   Rr   t   readerR   R   t   data_pfxt   info_pfxt
   script_pfxt   fileopt   bct   outfilest   workdirt   zinfoR   t	   u_arcnamet   kindt   valueR   t   _R   t	   is_scriptt   whereR   t   outfilet	   newdigestt   pycRp   t   worknameR   t	   filenamest   distt   commandst   ept   epdataR   R/   t   dR0   t   st   console_scriptst   gui_scriptst
   script_dirt   scriptt   options(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   install  sH   	

%

	
		 		
#
"			
		

c         C  sK   t  d  k rG t j j t   t d  d t j d   } t	 |  a  n  t  S(   Nu   dylib-cacheu   %s.%si   (
   t   cacheR2   R#   R4   R   R   R   R7   t   version_infoR   (   R(   R   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   _get_dylib_cache  s
    c         C  s  t  j j |  j |  j  } d |  j |  j f } d | } t j | d  } t j	 d  } g  } t
 | d  w} y\| j |  G} | |  }	 t j |	  }
 |  j   } | j |  } t  j j | j |  } t  j j |  s t  j |  n  x |
 j   D] \ } } t  j j | t |   } t  j j |  sHt } nQ t  j |  j } t j j |  } | j |  } t j | j   } | | k } | r| j | |  n  | j | | f  qWWd  QXWn t k
 rn XWd  QX| S(   Nu   %s-%su   %s.dist-infou
   EXTENSIONSu   utf-8u   r(    R#   R4   R   RL   RO   RM   RN   Rc   R^   R_   R   Rd   R   R   R!  t   prefix_to_dirR   R   t   makedirsR   R   R[   R   t   statt   st_mtimet   datetimet   fromtimestampt   getinfot	   date_timet   extractR   Re   (   R(   R+   Rg   Rh   R   Ri   R5   Rj   Rr   Rs   R,   R  R   t
   cache_baseRM   R   t   destR*  t	   file_timeRY   t
   wheel_time(    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   _get_extensions  s>    
	!
c         C  s
   t  |   S(   uM   
        Determine if a wheel is compatible with the running system.
        (   t   is_compatible(   R(   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyR0    s    c         C  s   t  S(   uP   
        Determine if a wheel is asserted as mountable by its metadata.
        (   R   (   R(   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   is_mountable  s    c         C  s
  t  j j t  j j |  j |  j   } |  j   sL d | } t |   n  |  j   sq d | } t |   n  | t	 j k r t
 j d |  ns | r t	 j j |  n t	 j j d |  |  j   } | rt t	 j k r t	 j j t  n  t j | |  n  d  S(   Nu)   Wheel %s not compatible with this Python.u$   Wheel %s is marked as not mountable.u   %s already in pathi    (   R#   R4   RV   R   RL   RO   R0  R   R1  R7   R   R   R   t   insertR/  t   _hookt	   meta_pathR-   (   R(   R   R+   t   msgR,   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   mount  s"    '

c         C  s   t  j j t  j j |  j |  j   } | t j k rI t j d |  n] t j j	 |  | t
 j k rx t
 j	 |  n  t
 j s t
 t j k r t j j	 t
  q n  d  S(   Nu   %s not in path(   R#   R4   RV   R   RL   RO   R7   R   R   R1   R3  R&   R4  (   R(   R+   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   unmount  s    '	c         C  s  t  j j |  j |  j  } d |  j |  j f } d | } d | } t j | t  } t j | d  } t j | d  } t	 j
 d  } t | d  }	 |	 j |   }
 | |
  } t |  } Wd  QX| d j d	 d
  } t g  | D] } t |  ^ q  } i  } |	 j |  D } t d |  , } x" | D] } | d } | | | <q8WWd  QXWd  QXxK|	 j   D]=} | j } t | t  r| } n | j d  } | j d  } d | k rt d |   n  |  j |  rqon  | | } | d r(t | j  | d k r(t d |   n  | d
 ro| d
 j d d
  \ } } |	 j |   } | j   } Wd  QX|  j | |  \ } } | | k rt d |   qqoqoWWd  QXd  S(   Nu   %s-%su   %s.datau   %s.dist-infou   WHEELu   RECORDu   utf-8u   ru   Wheel-Versionu   .i   R   i    u   /u   ..u   invalid entry in wheel: %ri   u   size mismatch for %su   =u   digest mismatch for %s(   R#   R4   R   RL   RO   RM   RN   Rc   R   R^   R_   R   Rd   R   RT   Ra   Rb   R   R   R   R   R   R   R   R   R   R   R   (   R(   R+   Rg   R   Rh   R   R   R   Ri   Rj   R   Rs   Rv   Rl   Rm   Rn   R   Rr   R   R   R   R  R   R  R	  R
  R   R  R   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyRW     sV    

%
		
#
c         K  s  d   } d   } t  j j |  j |  j  } d |  j |  j f } d | } t j | d  }	 t   (}
 t	 | d   } i  } x | j
   D] } | j } t | t  r | } n | j d  } | |	 k r q n  d | k r t d	 |   n  | j | |
  t  j j |
 t |   } | | | <q WWd
 QX| | |  \ } } | | |  } | r| | |  \ } } | r| | k r| | |  n  | d
 k rt j d d d d d |
  \ } } t  j |  n= t  j j |  st d |   n  t  j j | |  j  } t | j    } t  j j |
 |  } | | f } |  j | |
 |  |  j | |  | d
 k rt j | |  qn  Wd
 QX| S(   u  
        Update the contents of a wheel in a generic way. The modifier should
        be a callable which expects a dictionary argument: its keys are
        archive-entry paths, and its values are absolute filesystem paths
        where the contents the corresponding archive entries can be found. The
        modifier is free to change the contents of the files pointed to, add
        new entries and remove entries, before returning. This method will
        extract the entire contents of the wheel to a temporary location, call
        the modifier, and then use the passed (and possibly updated)
        dictionary to write a new wheel. If ``dest_dir`` is specified, the new
        wheel is written there -- otherwise, the original wheel is overwritten.

        The modifier should return True if it updated the wheel, else False.
        This method returns the same value the modifier returns.
        c         S  sh   d  } } d | t f } | |  k r3 d | } n  | |  k r^ |  | } t d |  j } n  | | f S(   Nu   %s/%su   %s/PKG-INFOR4   (   R2   R   R
   RN   (   t   path_mapRh   RN   R4   R   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   get_versionY  s    

c   	      S  s&  d  } y t |   } |  j d  } | d k  r= d |  } ng g  |  | d j d  D] } t |  ^ qU } | d c d 7<d |  |  d j d   | D  f } Wn! t k
 r t j d	 |   n X| r"t	 d
 |  } | | _
 | j t  } | j d
 | d |  t j d |  |  n  d  S(   Nu   -i    u   %s+1i   u   .iu   %s+%sc         s  s   |  ] } t  |  Vq d  S(   N(   R   (   t   .0Rm   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pys	   <genexpr>n  s    u0   Cannot update non-compliant (PEP-440) version %rR4   t   legacyu   Version updated from %r to %r(   R2   R   R   RT   Rb   R   R   R   R   R
   RN   R   R   R   (	   RN   R4   t   updatedR0   Rm   R  R   t   mdR;  (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   update_versionc  s(    0
!		u   %s-%su   %s.dist-infou   RECORDu   ru   utf-8u   ..u   invalid entry in wheel: %rNR   u   .whlR   u   wheel-update-t   diru   Not a directory: %r(   R#   R4   R   RL   RO   RM   RN   Rc   R   R   R   R   R   R   R   R*  R   R2   R   t   mkstempt   closeR   R   R   R   R   R   t   copyfile(   R(   t   modifiert   dest_dirR   R9  R>  R+   Rg   Rh   R   R  Rj   R8  R  R   R  R4   t   original_versionR  t   modifiedt   current_versiont   fdt   newpathR   R   RY   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyR*   H  sX    	
	
		(   i   i   N(    RA   RB   t   __doc__R   R   R2   R   R)   t   propertyRO   R[   R\   R   Rt   R`   RY   R   R   R   R   R   R   R   R  R!  R/  R0  R1  R6  R7  RW   R*   (    (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyRC      s4   ) 						t					"				8c          C  s  t  g }  t  d } xG t t j d d d d  D]( } |  j d j | t |  g   q1 Wg  } xL t j   D]> \ } } } | j	 d  rp | j | j
 d d  d  qp qp W| j   t d k r | j d t  n  | j d  g  } t g } t j d	 k r=t j d
 t  } | r=| j   \ }	 } } }
 t |  } |
 g } |
 d k rg| j d  n  |
 d k r| j d  n  |
 d k r| j d  n  |
 d k r| j d  n  |
 d k r| j d  n  x` | d k r6x@ | D]8 } d |	 | | | f } | t k r| j |  qqW| d 8} qWq=n  xH | D]@ } x7 | D]/ }
 | j d j t |  d f  | |
 f  qQWqDWxw t |   D]i \ } } | j d j t | f  d d f  | d k r| j d j t | d f  d d f  qqWxw t |   D]i \ } } | j d j d | f  d d f  | d k r| j d j d | d f  d d f  qqWt |  S(   uG   
    Return (pyver, abi, arch) tuples compatible with this Python.
    i    i   iu    u   .abiu   .i   u   noneu   darwinu   (\w+)_(\d+)_(\d+)_(\w+)$u   i386u   ppcu   fatu   x86_64u   fat3u   ppc64u   fat64u   intelu	   universalu   %s_%s_%s_%su   anyu   py(   u   i386u   ppc(   u   i386u   ppcu   x86_64(   u   ppc64u   x86_64(   u   i386u   x86_64(   u   i386u   x86_64u   intelu   ppcu   ppc64(   R   t   rangeR7   R   R   R   R   R:   t   get_suffixesR   RT   t   sortR   R2  R   t   platformt   reRR   R   Rb   t
   IMP_PREFIXR   t   set(   t   versionst   majort   minort   abisR   R  R5   t   archesRX   RM   RJ   t   matchesRR   R  RI   Rm   RN   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   compatible_tags  s`    	
$&$
		1%0%0c         C  s   t  |  t  s t |   }  n  t } | d  k r9 t } n  xN | D]F \ } } } | |  j k r@ | |  j k r@ | |  j k r@ t } Pq@ q@ W| S(   N(	   R   RC   R   R2   t   COMPATIBLE_TAGSRH   RI   RJ   R   (   t   wheelR\   R5   t   verRI   RJ   (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyR0    s    	-(V   t
   __future__R    R   R^   R&  t   distutils.utilt	   distutilst   emailR   R   R:   R   t   loggingR#   Rc   RP  R   R7   R   R   R!   R   R   t   compatR   R   R   R   R   t   databaseR	   Rt   R
   R   R   R   t   utilR   R   R   R   R   R   R   R   R   RN   R   R   t	   getLoggerRA   R   R2   R  t   hasattrRQ  RO  R   R   R   R   RG   R   t   get_platformR"   R   R   R   t   compilet
   IGNORECASEt   VERBOSERU   RQ   Ry   R~   R}   R|   R$   R   t   objectR%   R3  RC   RY  RZ  R0  (    (    (    s6   /tmp/pip-build-UPPWic/pip/pip/_vendor/distlib/wheel.pyt   <module>   s   ("@			

'				#	   '	>	