ó
ä™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 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" 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. m/ Z/ e j0 e1 ƒ Z2 e3 a4 e5 e d ƒ rÁd Z6 n9 e j7 j8 d ƒ rÜd Z6 n e j7 d k rôd Z6 n d Z6 e j9 d ƒ Z: e: r$d e j; d  Z: n  d e: Z< e6 e: Z= e j# j> ƒ  j? d d ƒ j? d d ƒ Z@ e j9 d ƒ ZA eA o€eA j8 d ƒ r˜eA j? d d ƒ ZA n d „  ZB eB ƒ  ZA [B e jC d e jD e jE Bƒ ZF e jC d e jD e jE Bƒ ZG e jC d ƒ ZH e jC d ƒ ZI d  ZJ d! ZK e jL d" k r*d# „  ZM n	 d$ „  ZM d% eN f d& „  ƒ  YZO eO ƒ  ZP d' eN f d( „  ƒ  YZQ d) „  ZR eR ƒ  ZS [R e3 d* „ ZT 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_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-sZz8gW/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-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt   <lambda>]   s    c         C  s   |  j  t j d ƒ S(   Nu   /(   t   replacet   ost   sep(   R   (    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyR   _   s    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-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt   __init__c   s    	c         C  s!   | |  j  | <|  j j | ƒ d  S(   N(   R$   R%   t   update(   R&   t   pathnamet
   extensions(    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt   addg   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-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt   removek   s    c         C  s"   | |  j  k r |  } n d  } | S(   N(   R%   t   None(   R&   t   fullnamet   patht   result(    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt   find_moduleq   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&   R1   R3   R   (    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt   load_modulex   s    	N(   t   __name__t
   __module__R'   R+   R/   R0   R4   R>   (    (    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyR#   b   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   dirnameR0   t   namet   versiont   filenamet	   _filenamet   NAME_VERSION_REt   matcht	   groupdictR    R2   t   splitt   FILENAME_RER   t   abspath(   R&   RM   RB   t   verifyt   mt   infoRJ   (    (    s6   /tmp/pip-build-sZz8gW/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(   RD   R   RF   RG   RH   RL   R    RK   (   R&   RD   RF   RG   RH   RL   (    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyRM   ¹   s    	c         C  s+   t  j j |  j |  j ƒ } t  j j | ƒ S(   N(   R!   R2   R   RJ   RM   t   isfile(   R&   R2   (    (    s6   /tmp/pip-build-sZz8gW/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(   RF   RG   RH   (   R&   RF   RG   RH   (    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt   tagsÏ   s    c         C  sz  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‹ ƒ }	 |	 d k  rÄ t t d g }
 n t t g }
 d  } xu |
 D]m } yS t j | | ƒ } | j | ƒ �, } | | ƒ } t d	 | ƒ } | r/Pn  Wd  QXWqÝ t k
 rIqÝ XqÝ W| spt d
 d j |
 ƒ ƒ ‚ n  Wd  QX| S(   Nu   %s-%su   %s.dist-infou   utf-8u   ru   Wheel-Versionu   .i   u   METADATAt   fileobju8   Invalid wheel, because metadata is missing: looked in %su   , (   i   i   (   R!   R2   R   RJ   RM   RK   RL   t   codecst	   getreaderR   t   get_wheel_metadataRR   t   tuplet   intR   R   R0   t	   posixpatht   openR
   t   KeyErrort
   ValueError(   R&   R)   t   name_vert   info_dirt   wrappert   zft   wheel_metadatat   wvt   it   file_versiont   fnsR3   t   fnt   metadata_filenamet   bft   wf(    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt   metadataÖ   s4    
%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(	   RK   RL   Ra   R   Rb   R\   R]   R   t   dict(   R&   Rh   Re   Rf   Ro   Rp   Rq   t   message(    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyR^   ô   s    
c         C  sF   t  j j |  j |  j ƒ } t | d ƒ � } |  j | ƒ } Wd  QX| S(   Nu   r(   R!   R2   R   RJ   RM   R   R^   (   R&   R)   Rh   R3   (    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyRW   ý   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    iÿÿÿÿt    s   s   
i    i   s   
(	   t
   SHEBANG_RERP   t   endt   lowert   SHEBANG_PYTHONWt   SHEBANG_PYTHONt   SHEBANG_DETAIL_REt   groupst   find(   R&   t   dataRV   Ry   t   shebangt   data_after_shebangt   shebang_pythont   argst   crt   lft   term(    (    s6   /tmp/pip-build-sZz8gW/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(   R0   t	   hash_kindt   getattrt   hashlibt   AttributeErrorR   t   digestt   base64t   urlsafe_b64encodet   rstript   decode(   R&   R€   RŠ   t   hasherR3   (    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt   get_hash"  s    !c         C  s~   t  | ƒ } t t j j | | ƒ ƒ } | j | d d f ƒ | j ƒ  t | ƒ �% } x | D] } | j | ƒ q] WWd  QXd  S(   Nu    (	   t   listt   to_posixR!   R2   t   relpathR   t   sortR   t   writerow(   R&   t   recordst   record_patht   baset   pt   writert   row(    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt   write_record-  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Š   Rb   t   readR”   R!   R2   t   getsizeR   R   R    R–   (   R&   RW   t   libdirt   archive_pathsRš   t   distinfoRf   R“   t   apR�   t   fR€   RŽ   t   size(    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt   write_records6  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¤   Rh   R¦   R�   (    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt	   build_zipF  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 ƒ |  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-sZz8gW/pip/pip/_vendor/distlib/wheel.pyR   T  s    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   
(   u   purelibu   platlib(   u   datau   headersu   scripts(   u   .pycu   .pyo(   u   RECORDu	   INSTALLERu   SHAREDu   WHEEL(%   R0   R•   R   t   IMPVERt   ABIt   ARCHRE   t   getRF   RG   RH   RK   RL   R!   R2   t   isdirt   walkR   R   R—   R–   R   t   endswithRb   R¡   Rˆ   R®   t	   enumeratet   AssertionErrort   listdirt   wheel_versionR   RZ   R©   RJ   RM   R¯   (!   R&   R°   RZ   R»   t   libkeyt   is_puret   default_pyvert   default_abit   default_archR£   Re   t   data_dirRf   R¤   t   keyR2   t   roott   dirst   filesRn   R�   t   rpR¦   R§   R€   R¥   Rk   t   dnRi   RF   RG   RH   R)   (    (   R°   s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt   buildL  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-sZz8gW/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 | _ z0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 n:d }7 |  j8 d } | d& k rHt
 j | d' ƒ }8 yÅ | j |8 ƒ � } t9 | ƒ }9 Wd QXi  }7 x” d9 D]Œ }: d* |: }; |; |9 k r“i  |7 d+ |: <}< x[ |9 |; j: ƒ  D]F }= d, |= j; |= j< f }> |= j= r|> d- |= j= 7}> n  |> |< |= j <qÒWq“q“WWqÁt2 k
 rDt+ j3 d. ƒ qÁXny yX | j | ƒ �C } | | ƒ } t> j? | ƒ j d/ ƒ }7 |7 r™|7 j d0 ƒ }7 n  Wd QXWn t2 k
 rÀt+ j3 d1 ƒ n X|7 rä|7 j d2 i  ƒ }? |7 j d3 i  ƒ }@ |? s÷|@ rä| j d d ƒ }A t j j@ |A ƒ s*tA d4 ƒ ‚ n  |A | _ xF |? jB ƒ  D]8 \ }; }= d5 |; |= f }B | j5 |B ƒ }5 |  j6 |5 ƒ q@W|@ rái t d) 6}C xL |@ jB ƒ  D]; \ }; }= d5 |; |= f }B | j5 |B |C ƒ }5 |  j6 |5 ƒ qœWqáqän  t j j | | ƒ } tC | ƒ }6 tD | ƒ } | d =| d =| | d6 <|6 jE | | ƒ } | rQ	|" j0 | ƒ n  |6 jF |" | d7 | ƒ |6 SWn+ t2 k
 rš	t+ jG d8 ƒ |  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    %suA   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!   R2   R   RJ   RM   RK   RL   Ra   R   R\   R]   R   Rb   R   RR   R_   R`   R»   R   R   t   Truet   recordR5   t   dont_write_bytecodet   tempfilet   mkdtempt
   source_dirR0   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   extendRW   R   t   valuest   prefixt   suffixt   flagst   jsont   loadRµ   Rd   t   itemsR	   Rs   t   write_shared_locationst   write_installed_filest	   exceptiont   rollbackt   shutilt   rmtree(D   R&   R°   t   makert   kwargsRÌ   t   warnert   lib_onlyt   bc_hashed_invalidationR)   Re   RÁ   Rf   t   metadata_namet   wheel_metadata_namet   record_nameRg   Rh   t   bwfRq   Rt   Rj   Rk   Rl   R£   Rš   Rp   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   pycRn   t   worknameRÇ   t	   filenamest   distt   commandst   ept   epdataRÂ   R-   t   dR.   t   st   console_scriptst   gui_scriptst
   script_dirt   scriptt   options(    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt   installÄ  sH   	

%

	
		 		
#
"			
		

c         C  sG   t  d  k rC t j j t ƒ  t d ƒ t j d  ƒ } t	 | ƒ a  n  t  S(   Nu   dylib-cachei   (
   t   cacheR0   R!   R2   R   R   RÙ   R5   RL   R   (   R&   Rœ   (    (    s6   /tmp/pip-build-sZz8gW/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!   R2   R   RJ   RM   RK   RL   Ra   R\   R]   R   Rb   Rè   Ré   R  t   prefix_to_dirRœ   Rµ   t   makedirsRê   R   RY   RÐ   t   statt   st_mtimet   datetimet   fromtimestampt   getinfot	   date_timet   extractR   Rc   (   R&   R)   Re   Rf   RÉ   Rg   R3   Rh   Rp   Rq   R*   R  Rå   t
   cache_baseRK   R—   t   destR$  t	   file_timeRW   t
   wheel_time(    (    s6   /tmp/pip-build-sZz8gW/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-sZz8gW/pip/pip/_vendor/distlib/wheel.pyR*  Õ  s    c         C  s   t  S(   uP   
        Determine if a wheel is asserted as mountable by its metadata.
        (   RÐ   (   R&   (    (    s6   /tmp/pip-build-sZz8gW/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!   R2   RT   R   RJ   RM   R*  R   R+  R5   R¬   R­   R   t   insertR)  t   _hookt	   meta_pathR+   (   R&   R   R)   t   msgR*   (    (    s6   /tmp/pip-build-sZz8gW/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!   R2   RT   R   RJ   RM   R5   R¬   R­   R/   R-  R$   R.  (   R&   R)   (    (    s6   /tmp/pip-build-sZz8gW/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!   R2   R   RJ   RM   RK   RL   Ra   R   R\   R]   R   Rb   R   RR   R_   R`   R   R×   RØ   R   R’   R   RÊ   RÙ   RÚ   R¡   R”   (   R&   R)   Re   RÁ   Rf   Rö   R÷   Rø   Rg   Rh   Rù   Rq   Rt   Rj   Rk   Rl   Rš   Rp   Rú   RŸ   R�   R  RÉ   R  R  R  R€   R  RŽ   (    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyRU     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-INFOR2   (   R0   R   R
   RL   (   t   path_mapRf   RL   R2   RÂ   (    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt   get_versionK  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   .iÿÿÿÿu   %s+%sc         s  s   |  ] } t  | ƒ Vq d  S(   N(   RÙ   (   t   .0Rk   (    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pys	   <genexpr>`  s    u0   Cannot update non-compliant (PEP-440) version %rR2   t   legacyu   Version updated from %r to %r(   R0   R   R   RR   R`   R   R   R¬   R­   R
   RL   R·   R   R®   (	   RL   R2   t   updatedR.   Rk   R  R   t   mdR5  (    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt   update_versionU  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!   R2   R   RJ   RM   RK   RL   Ra   R   R   R×   RØ   R   R’   R   R$  R   R0   RÓ   t   mkstempt   closeRµ   R•   Rê   R©   R¯   Rï   t   copyfile(   R&   t   modifiert   dest_dirRò   R3  R8  R)   Re   Rf   Rø   R  Rh   R2  R  RÉ   R  R2   t   original_versionR  t   modifiedt   current_versiont   fdt   newpathR¤   R¥   RW   (    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyR(   :  sX    	
	
		(   i   i   N(    R?   R@   t   __doc__R»   RŠ   R0   RÏ   R'   t   propertyRM   RY   RZ   R   Rr   R^   RW   Rˆ   R”   R    R©   R¯   RÈ   RÊ   R  R  R)  R*  R+  R0  R1  RU   R(   (    (    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyRA   ˆ   s4   )							h		æ			"				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   iÿÿÿÿu    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   rangeR5   t   version_infoR   R   RÙ   R8   t   get_suffixesRÛ   RR   R˜   R²   R,  R³   t   platformt   reRP   R~   R`   t
   IMP_PREFIXR¸   t   set(   t   versionst   majort   minort   abisRæ   R  R3   t   archesRV   RK   RH   t   matchesRP   R  RG   Rk   RL   (    (    s6   /tmp/pip-build-sZz8gW/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Ø   RA   RÏ   R0   t   COMPATIBLE_TAGSRF   RG   RH   RÐ   (   t   wheelRZ   R3   t   verRG   RH   (    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyR*  â  s    	-(U   t
   __future__R    R�   R\   R   t   distutils.utilt	   distutilst   emailR   RŒ   R8   Rè   t   loggingR!   Ra   RJ  Rï   R5   RÓ   Rª   Rw   R   R   t   compatR   R   R   R   R   t   databaseR	   Rr   R
   R   R   t   utilR   R   R   R   R   R   R   R   R   RL   R   R   t	   getLoggerR?   R¬   R0   R  t   hasattrRK  RI  RÛ   R   R   RG  RE   R±   t   get_platformR    R³   R²   R   t   compilet
   IGNORECASEt   VERBOSERS   RO   Rx   R}   R|   R{   R"   R–   t   objectR#   R-  RA   RS  RT  R*  (    (    (    s6   /tmp/pip-build-sZz8gW/pip/pip/_vendor/distlib/wheel.pyt   <module>   s€   (@			

'				#	ÿ ÿ ÿ 	>	