
b]c        	   @@  s  d  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 d d l m Z d d l m Z d d l m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z d d l m  Z  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- 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 d d l9 m: Z: e8 rd d l; m< Z< m= Z= m> Z> m? Z? m@ Z@ mA ZA mB ZB mC ZC mD ZD mE ZE d d lF mG ZG d d lH mI ZI d d l mJ ZJ d d lK mL ZL mM ZM d d lN mO ZO d d lP mQ ZQ d d lR mS ZS eA eT d f ZU n  d d f ZV e jW eX  ZY d    ZZ d d! >d"  Z[ d d! >d#  Z\ d$   Z] d%   Z^ d&   Z_ e
 j` d' e
 ja  Zb d(   Zc d)   Zd d*   Ze d+   Zf d,   Zg eh ei ei ej ei eh ei ej d-  Zk d.   Zl d/   Zm d0   Zn d1 eo f d2     YZp e
 j` d3 e
 jq  d4  Zr d5   Zs d6   Zt d7   Zu d8 eo f d9     YZv d S(:   sH   
Support for installing and building the "wheel" binary package format.
i    (   t   absolute_importN(   t   urlsafe_b64encode(   t   Parser(   t   pkg_resources(   t   ScriptMaker(   t   canonicalize_name(   t   StringIO(   t
   pep425tags(   t
   unpack_url(   t   InstallationErrort   InvalidWheelFilenamet   UnsupportedWheel(   t   distutils_scheme(   t   Link(   t
   indent_log(   t   PIP_DELETE_MARKER_FILENAME(   t   LOG_DIVIDERt   call_subprocesst   captured_stdoutt
   ensure_dirt   format_command_argst   path_to_urlt   read_chunks(   t   make_setuptools_shim_args(   t   TempDirectory(   t   MYPY_CHECK_RUNNING(   t   open_spinner(
   t   Dictt   Listt   Optionalt   Sequencet   Mappingt   Tuplet   IOt   Textt   Anyt   Iterable(   t   Requirement(   t   InstallRequirement(   t
   PipSession(   t   FormatControlt   PackageFinder(   t   RequirementPreparer(   t
   WheelCache(   t	   Pep425Tag.i   c         C@  s%   t  j j |  |  j t  j j d  S(   Nt   /(   t   ost   patht   relpatht   replacet   sep(   t   srct   p(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   normpathB   s    i   c         C@  sn   t  j   } d } t |  d  A } x7 t | d | D]# } | t |  7} | j |  q7 WWd QX| | f S(   s5   Return (hash, length) for path using hashlib.sha256()i    t   rbt   sizeN(   t   hashlibt   sha256t   openR   t   lent   update(   R/   t	   blocksizet   ht   lengtht   ft   block(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt	   hash_fileF   s    c         C@  sM   t  |  |  \ } } d t | j    j d  j d  } | t |  f S(   s?   Return (encoded_digest, length) for path using hashlib.sha256()s   sha256=t   latin1t   =(   RB   R   t   digestt   decodet   rstript   str(   R/   R=   R>   R?   RE   (    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   rehashR   s
    c         C@  sI   t  j d d k  r" i  } d } n i d d 6} d } t |  | | |  S(   Ni    i   t   bt    t   newline(   t   syst   version_infoR:   (   t   namet   modet   nlt   bin(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   open_for_csv]   s    	c         C@  s&   |  j  d  } | | d <d j |  S(   sB   Replace the Python tag in a wheel file name with a new value.
    t   -i(   t   splitt   join(   t	   wheelnamet   new_tagt   parts(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   replace_python_tagh   s    
c         C@  s   t  j j |   r t |  d  d } | j   } | j d  sC t St j j	 t j
    } d | t  j j	 d  } | j   } Wd QXt |  d  ! } | j |  | j |  Wd QXt Sd S(   sL   Replace #!python with #!/path/to/python
    Return True if file was changed.R6   s   #!pythons   #!t   asciiNt   wb(   R.   R/   t   isfileR:   t   readlinet
   startswitht   FalseRM   t
   executablet   encodet   getfilesystemencodingt   linesept   readt   writet   Truet   None(   R/   t   scriptt	   firstlinet   exenamet   rest(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt
   fix_scriptq   s    sX   ^(?P<namever>(?P<name>.+?)(-(?P<ver>.+?))?)
                                \.dist-info$c         C@  s   |  j  d d  } x t j |  D] } t j |  } | r" | j d  | k r" t t j j | | d   : } x0 | D]( } | j	   j
   } | d k rz t Sqz WWd QXq" q" Wt S(   sP   
    Return True if the extracted wheel in wheeldir should go into purelib.
    RT   t   _RO   t   WHEELs   root-is-purelib: trueN(   R1   R.   t   listdirt   dist_info_ret   matcht   groupR:   R/   RV   t   lowerRG   Rg   R`   (   RO   t   wheeldirt   name_foldedt   itemRr   t   wheelt   line(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   root_is_purelib   s    !c         @  s  t  j j |   s i  i  f St |   N } t   } x. | D]& } | j | j    | j d  q; W| j d  Wd  QXt j	 j
 |  } | j d i   } | j d i   } d     t   f d   | j   D  } t   f d   | j   D  } | | f S(   Ns   
i    t   console_scriptst   gui_scriptsc         S@  s   t  |   j d d  j d  S(   sR   get the string representation of EntryPoint, remove space and split
        on '='t    RK   RD   (   RH   R1   RU   (   t   s(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt	   _split_ep   s    c         3@  s   |  ] }   |  Vq d  S(   N(    (   t   .0t   v(   R   (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pys	   <genexpr>   s    c         3@  s   |  ] }   |  Vq d  S(   N(    (   R   R   (   R   (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pys	   <genexpr>   s    (   R.   R/   t   existsR:   R   Rf   t   stript   seekR   t
   EntryPointt	   parse_mapt   gett   dictt   values(   t   filenamet   fpt   dataRy   t   entry_pointst   consolet   gui(    (   R   s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   get_entrypoints   s    
		""c         @  s  |  s
 d St j t  } xC |  D]; } t j j |  } t j j |  } | | j |  q  Wg  t j	 j
 d d  j t j  D]$ } t j j |  j t j  ^ q     j t j j t j j t j      f d   | j   D } | s d Sg  } x | j   D] \ } }  t |   } t |  d k rLd j | d  }	 n( d j d j | d	   d
 | d	  }	 | j d j |	 |   qWd }
 t |  d k r| j |
 j d   n | j |
 j d   d j |  S(   s   Determine if any scripts are not on PATH and format a warning.

    Returns a warning message if one or more scripts are not on PATH,
    otherwise None.
    t   PATHRK   c         @  s7   i  |  ]- \ } } t  j j |    k r | |  q S(    (   R.   R/   t   normcase(   R   t
   parent_dirt   scripts(   t   not_warn_dirs(    s2   lib/python2.7/site-packages/pip/_internal/wheel.pys
   <dictcomp>   s   	 	i   s   script {} isi    s   scripts {} ares   , is    and s.   The {} installed in '{}' which is not on PATH.se   Consider adding {} to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.s   this directorys   these directoriess   
N(   Rh   t   collectionst   defaultdictt   setR.   R/   t   dirnamet   basenamet   addt   environR   RU   t   pathsepR   RG   R2   t   appendRM   Ra   t   itemst   sortedR;   t   formatRV   (   R   t   grouped_by_dirt   destfileR   t   script_namet   it   warn_fort	   msg_linest   sorted_scriptst
   start_textt   last_line_fmt(    (   R   s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt!   message_about_scripts_not_on_PATH   s8    I("c         C@  s   t  |  d d   S(   s;  
    Return the given rows of a RECORD file in sorted order.

    Each row is a 3-tuple (path, hash, size) and corresponds to a record of
    a RECORD file (see PEP 376 and PEP 427 for details).  For the rows
    passed to this function, the size can be an integer as an int or string,
    or the empty string.
    t   keyc         S@  s   t  d   |  D  S(   Nc         s@  s   |  ] } t  |  Vq d  S(   N(   RH   (   R   t   x(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pys	   <genexpr>	  s    (   t   tuple(   t   row(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   <lambda>	  RK   (   R   (   t   outrows(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   sorted_outrows   s    c         C@  s3  g  } x |  D] } t  |  d k r> t j d j |   n  t |  } | d } | j | |  } | | d <| | k r t |  \ }	 }
 |	 | d <|
 | d <n  | j t |   q WxE | D]= } t |  \ }	 }
 | j t	 | |  |	 t
 |
  f  q Wx( | D]  } | j | | d d f  qW| S(   s_   
    :param installed: A map from archive RECORD path to installation RECORD
        path.
    i   s,   RECORD line has more than three elements: {}i    i   i   RK   (   R;   t   loggert   warningR   t   listt   popRI   R   R   R5   RH   (   t   old_csv_rowst	   installedt   changedt	   generatedt   lib_dirt   installed_rowsR   t   old_patht   new_pathRE   R?   R@   (    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   get_csv_rows_for_installed  s(    


)c   +      @  s|  | s3 t  |  d | d | d | d | d |	 } n  t |  
  rO | d  n
 | d  g   g   
 j t j j  t j j } i   t     g  } | r t   @ } t j	   + t j
 d  t j | d	 t d
 t Wd QXWd QXt j | j    n  t     
 f d   d d    	 f d  } | |  t   s_t d 	   t j j  d d  } t |  \     f d   } x  D] } d } d } x t j t j j 
 |   D]e } d } | d k rt } | } n  t j j 
 | |  } | | } | | | t d | d | qWqWt d | d   t  _ d h  _ t  _  	 f d   } |  _ d  _  j d d  } | rd t j k rd | } | j   j! |   n  t j j" d d  d k r+d t# j$ d  | f } | j   j! |   n  d t# j$ d  | f } | j   j! |   g   D] } t% j& d |  r_| ^ q_} x | D] }  | =qWn   j d  d  } | r[d t j k rd! | } | j   j! |   n  d" t# j$ d  | f } | j   j! |   g   D] } t% j& d# |  r| ^ q} x | D] }  | =qGWn  t'   d k r j( g   j)   D] } d$ | ^ q } | j  |  |
 rt* |  } | d k	 rt j+ |  qqn  t'   d k r,| j   j( g   j)   D] } d$ | ^ qi t d% 6  n  t j j  d d&  }  t j j  d d'  }! t, |! d(   }" |" j- d)  Wd QXt. j/ |! |   | j0 |   t j j  d d*  }# t j j  d d+  }$ t1 |# d,   }% t1 |$ d-  m }& t2 j3 |%  }' t4 |' d.  d/   d0 | d1  }( t2 j5 |&  }) x! t6 |(  D] }* |) j7 |*  qEWWd QXWd QXt. j/ |$ |#  d S(2   s   Install a wheelt   usert   homet   roott   isolatedt   prefixt   purelibt   platlibt   ignoret   forcet   quietNc         @  sB   t  |    } t  |   } |  | <| r>   j |  n  d S(   s6   Map archive RECORD paths to installation RECORD paths.N(   R5   R   (   t   srcfileR   t   modifiedt   oldpatht   newpath(   R   R   R   Ru   (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   record_installedb  s
    
c         @  s  t  |  xt j |   D]\ } } } | t |   j t j j  } t j j | |  }	 | r | j t j j d  d j	 d  r q n  x | D] }
 t j j | | |
  } | r | d k r | j	 d  r   j
 |
  q q | r |
 j	 d  r t |
  j t  j   r  sBt d | d d j      j
 |  q q WxL| D]D} | r{| |  r{q]n  t j j | |  } t j j | | |  } t  |	  t j j |  rt j |  n  t j | |  t j |  } t t d  r!t j | | j | j f  n  t j | t j  rvt j |  } | j t j Bt j Bt j B} t j | |  n  t } | r| |  } n   | | |  q]Wq Wd  S(	   Ni   i    s   .dataRK   s
   .dist-infos!   Multiple .dist-info directories: s   , t   utime(    R   R.   t   walkR;   t   lstripR/   R2   RV   RU   t   endswithR   R   R_   RO   t   AssertionErrorR   t   unlinkt   shutilt   copyfilet   statt   hasattrR   t   st_atimet   st_mtimet   accesst   X_OKt   st_modet   S_IXUSRt   S_IXGRPt   S_IXOTHt   chmodR`   (   t   sourcet   destt   is_baset   fixert   filtert   dirt   subdirst   filest   basedirt   destdirR~   t
   destsubdirR@   R   R   t   stt   permissionsR   (   t	   data_dirst   info_dirR   t   req(    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   clobberj  sN    
+!


s!   %s .dist-info directory not foundi    s   entry_points.txtc         @  s   |  j    j d  r" |  d  } nJ |  j    j d  rD |  d  } n( |  j    j d  rf |  d  } n |  } |   k p |  k S(   Ns   .exeis
   -script.pyis   .pya(   Rt   R   (   RO   t	   matchname(   R   R   (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   is_entrypoint_wrapper  s    R   R   R   RK   c         @  s^   |  j  d  k r( t d |   f   n    j i |  j d 6|  j  j d  d d 6|  j  d 6S(   Ns   Invalid script entry point: %s for req: %s - A callable suffix is required. Cf https://packaging.python.org/en/latest/distributing.html#console-scripts for more information.t   modulet   .i    t   import_namet   func(   t   suffixRh   R	   t   script_templateR   RU   (   t   entry(   t   makerR   (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   _get_script_text  s    	
s   # -*- coding: utf-8 -*-
import re
import sys

from %(module)s import %(import_name)s

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(%(func)s())
t   pipt   ENSUREPIP_OPTIONSs   pip = t
   altinstalls
   pip%s = %si   i   s   pip(\d(\.\d)?)?$t   easy_installs   easy_install = s   easy_install-%s = %ss   easy_install(-\d\.\d)?$s   %s = %sR   t	   INSTALLERs   INSTALLER.pipR\   s   pip
t   RECORDs
   RECORD.pipt   rs   w+R   R   R   R   (8   R   Rz   RG   R.   R/   R2   R   R   t   warningst   catch_warningst   filterwarningst
   compileallt   compile_dirRg   R   t   debugt   getvalueR`   Rh   R   RV   R   Rp   Rm   R   R   t   variantst   set_modeR   R   R   R   t   extendt   makeR   RM   t   versiont   reRr   R;   t   make_multipleR   R   R   R:   Rf   R   t   moveR   RS   t   csvt   readerR   t   writerR   t   writerow(+   RO   R   Ru   R   R   R   t	   pycompilet   schemeR   R   t   warn_script_locationR   R   t   stdoutR   t   ep_fileR   t   datadirR   R   t   subdirR   R   t
   pip_scriptt   spect   kt   pip_ept   easy_install_scriptt   easy_install_ept   kvt   generated_console_scriptst   msgt	   installert   temp_installert   installer_filet   recordt   temp_recordt	   record_int
   record_outR  R   R  R   (    (   R   R   R   R   R   R   R   R   R   R   Ru   s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   move_wheel_files0  s    
	%F%	
$			
	#
+
+& c         C@  s   y g  t  j d |   D] } | ^ q d } | j d  } t   j |  } | d j   } t t t	 | j
 d    } | SWn t k
 r d SXd S(   s   
    Return the Wheel-Version of an extracted wheel, if possible.

    Otherwise, return None if we couldn't parse / extract it.
    i    Ro   s   Wheel-VersionR   N(   R   t   find_on_pathRh   t   get_metadataR   t   parsestrR   R   t   mapt   intRU   t	   Exception(   t
   source_dirt   dt   distt
   wheel_dataR  (    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   wheel_versionn  s    )c         C@  s   |  s t  d |   n  |  d t d k rX t  d | d j t t |    f   n1 |  t k r t j d d j t t |     n  d S(   s  
    Raises errors or warns if called with an incompatible Wheel-Version.

    Pip should refuse to install a Wheel-Version that's a major series
    ahead of what it's compatible with (e.g 2.0 > 1.1); and warn when
    installing a version only minor version ahead (e.g 1.2 > 1.1).

    version: a 2-tuple representing a Wheel-Version (Major, Minor)
    name: name of wheel or package to raise exception about

    :raises UnsupportedWheel: when an incompatible Wheel-Version is given
    s(   %s is in an unsupported or invalid wheeli    sB   %s's Wheel-Version (%s) is not compatible with this version of pipR   s*   Installing from a newer Wheel-Version (%s)N(   R   t   VERSION_COMPATIBLERV   R3  RH   R   R   (   R  RO   (    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   check_compatibility  s    %c         C@  s   d j  |   S(   s   
    Format three tags in the form "<python_tag>-<abi_tag>-<platform_tag>".

    :param file_tag: A 3-tuple of tags (python_tag, abi_tag, platform_tag).
    RT   (   RV   (   t   file_tag(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt
   format_tag  s    t   Wheelc           B@  sM   e  Z d  Z e j d e j  Z d   Z d   Z d d  Z
 d d  Z RS(   s   A wheel files   ^(?P<namever>(?P<name>.+?)-(?P<ver>.*?))
        ((-(?P<build>\d[^-]*?))?-(?P<pyver>.+?)-(?P<abi>.+?)-(?P<plat>.+?)
        \.whl|\.dist-info)$c         @  s     j  j |  } | s+ t d |   n  |   _ | j d  j d d    _ | j d  j d d    _ | j d    _ | j d  j	 d    _
 | j d	  j	 d    _ | j d
  j	 d    _   f d     j
 D   _ d S(   sX   
        :raises InvalidWheelFilename: when the filename is invalid for a wheel
        s!   %s is not a valid wheel filename.RO   Rn   RT   t   vert   buildt   pyverR   t   abit   platc         @  s?   h  |  ]5 }   j  D]% }   j D] } | | | f  q  q q S(    (   t   abist   plats(   R   R   t   yt   z(   t   self(    s2   lib/python2.7/site-packages/pip/_internal/wheel.pys	   <setcomp>  s   	 N(   t   wheel_file_reRr   R
   R   Rs   R1   RO   R  t	   build_tagRU   t
   pyversionsRE  RF  t	   file_tags(   RI  R   t
   wheel_info(    (   RI  s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   __init__  s    	c         C@  s   t  d   |  j D  S(   sF   
        Return the wheel's tags as a sorted list of strings.
        c         s@  s   |  ] } t  |  Vq d  S(   N(   R>  (   R   t   tag(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pys	   <genexpr>  s    (   R   RM  (   RI  (    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   get_formatted_file_tags  s    c         C@  s`   | d k r t j   } n  g  |  j D]! } | | k r% | j |  ^ q% } | r\ t |  Sd S(   s"  
        Return the lowest index that one of the wheel's file_tag combinations
        achieves in the supported_tags list e.g. if there are 8 supported tags,
        and one of the file tags is first in the list, then return 0.  Returns
        None is the wheel is not supported.
        N(   Rh   R   t   get_supportedRM  t   indext   min(   RI  t   tagst   ct   indexes(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   support_index_min  s    1c         C@  s7   | d k r t j   } n  t t |  j |  j   S(   s'   Is this wheel supported on this system?N(   Rh   R   RR  t   boolR   t   intersectionRM  (   RI  RU  (    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt	   supported  s    N(   t   __name__t
   __module__t   __doc__R  t   compilet   VERBOSERJ  RO  RQ  Rh   RX  R[  (    (    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyR?    s   		s   ([a-z0-9_.]+)-([a-z0-9_.!+-]+)c         C@  s   t  | j |    S(   sj   Determine whether the string looks like an egg_info.

    :param s: The string to parse. E.g. foo-2.1
    (   RY  t   search(   R~   t   _egg_info_re(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   _contains_egg_info  s    c         C@  s   |  j  r d S|  j r6 | s2 t j d |  j  n  d S| s@ t S|  j sS |  j rW d Sd | j	 t
 |  j   k r t j d |  j  d S|  j r |  j j r t S|  j } | j   \ } } | r t |  r t St S(   sZ  
    Return whether to build an InstallRequirement object using the
    ephemeral cache.

    :param cache_available: whether a cache directory is available for the
        autobuilding=True case.

    :return: True or False to build the requirement with ephem_cache=True
        or False, respectively; or None not to build the requirement.
    s(   Skipping %s, due to already being wheel.t   binarysC   Skipping bdist_wheel for %s, due to binaries being disabled for it.N(   t
   constraintRh   t   is_wheelR   t   infoRO   R`   t   editableR6  t   get_allowed_formatsR   t   linkt   is_artifactRg   t   splitextRc  (   R   t   format_controlt   autobuildingt   cache_availableRj  t   baset   ext(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   should_use_ephemeral_cache  s0    			
	c         C@  s   t  |   } d j |  } | s. | d 7} nT t j   t j k rP | d 7} n2 | j d  sl | d 7} n  | d j | t  7} | S(   s1   
    Format command information for logging.
    s   Command arguments: {}
s   Command output: Nones'   Command output: [use --verbose to show]s   
s   Command output:
{}{}(   R   R   R   t   getEffectiveLevelt   loggingt   DEBUGR   R   (   t   command_argst   command_outputt   command_desct   text(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   format_command_result,  s    c         C@  s   t  |   }  |  sH d j | j  } | t | |  7} t j |  d St |   d k r d j | j |   } | t | |  7} t j |  n  t j	 j
 | |  d  S(   sH   
    Return the path to the wheel in the temporary build directory.
    s1   Legacy build of wheel for {!r} created no files.
i   sZ   Legacy build of wheel for {!r} created more than one file.
Filenames (choosing first): {}
i    N(   R   R   RO   Rz  R   R   Rh   R;   R.   R/   RV   (   t   namest   temp_dirR   Rv  Rw  R'  (    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   get_legacy_build_wheel_pathC  s    t   WheelBuilderc           B@  sn   e  Z d  Z d	 d	 e d  Z d	 d  Z d	 d  Z d   Z d	 d  Z	 d	 d  Z
 d   Z e d  Z RS(
   s#   Build wheels from a RequirementSet.c         C@  sR   | |  _  | |  _ | |  _ | j |  _ | p0 g  |  _ | p? g  |  _ | |  _ d  S(   N(   t   findert   preparert   wheel_cachet   wheel_download_dirt
   _wheel_dirt   build_optionst   global_optionst   no_clean(   RI  R  R  R  R  R  R  (    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyRO  f  s    
			c      	   C@  s*   | j   |  j | | d | SWd QXd S(   si   Build one wheel.

        :return: The filename of the built wheel, or None if the build failed.
        t
   python_tagN(   t	   build_envt   _build_one_inside_env(   RI  R   t
   output_dirR  (    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt
   _build_onez  s    
c      
   C@  s	  t  d d   } | j r' |  j } n	 |  j } | | | j d | } | d  k	 r t j j |  } t j j | |  } y\ t	 |  \ }	 }
 t
 j | |  t j d | j | |
 |	 j    t j d |  | SWq t k
 r q Xn  |  j |  d  SWd  QXd  S(   Nt   kindRx   R  s3   Created wheel for %s: filename=%s size=%d sha256=%ss   Stored in directory: %s(   R   t
   use_pep517t   _build_one_pep517t   _build_one_legacyR/   Rh   R.   R   RV   RB   R   R  R   Rg  RO   t	   hexdigestR5  t
   _clean_one(   RI  R   R  R  R|  t   buildert
   wheel_patht
   wheel_namet	   dest_patht
   wheel_hashR?   (    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyR    s(    			c         C@  s&   t  | j d t } | t |  j  S(   Nt   unbuffered_output(   R   t   setup_py_pathRg   R   R  (   RI  R   t   base_cmd(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   _base_setup_args  s    	c         C@  s  | j  d k	 s t  |  j r9 t j d | j f  d Sy d | j f | _ t j d |  | j	 j
 | d | j  } | r t | |  } t j t j j | |  t j j | |   | } n  Wn% t k
 r t j d | j  d SXt j j | |  S(   s   Build one InstallRequirement using the PEP 517 build process.

        Returns path to wheel if successfully built. Otherwise, returns None.
        sG   Cannot build wheel for %s using PEP 517 when --build-options is presents   Building wheel for %s (PEP 517)s   Destination directory: %st   metadata_directorys   Failed building wheel for %sN(   R  Rh   R   R  R   t   errorRO   t   spin_messageR
  t   pep517_backendt   build_wheelRZ   R.   t   renameR/   RV   R5  (   RI  R   t   tempdR  R  t   new_name(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyR    s*    			c         C@  s  |  j  |  } d | j f } t |   } t j d |  | d d | g |  j } | d k	 rw | d | g 7} n  y t | d | j d | } Wn2 t	 k
 r | j
 d  t j d	 | j  d SXt j |  }	 t d
 |	 d | d | d | d |  }
 |
 SWd QXd S(   s   Build one InstallRequirement using the "legacy" build process.

        Returns path to wheel if successfully built. Otherwise, returns None.
        s    Building wheel for %s (setup.py)s   Destination directory: %st   bdist_wheels   -ds   --python-tagt   cwdt   spinnerR  s   Failed building wheel for %sR{  R|  R   Rv  Rw  N(   R  RO   R   R   R
  R  Rh   R   t   setup_py_dirR5  t   finishR  R.   Rp   R}  (   RI  R   R  R  t	   base_argsR  R  t
   wheel_argst   outputR{  R  (    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyR    s,    	c         C@  sy   |  j  |  } t j d | j  | d d g } y t | d | j t SWn% t k
 rt t j d | j  t	 SXd  S(   Ns   Running setup.py clean for %st   cleans   --allR  s    Failed cleaning build dir for %s(
   R  R   Rg  RO   R   R6  Rg   R5  R  R`   (   RI  R   R  t
   clean_args(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyR    s    c         C@  s2  g  } |  j  j } t |  j p' |  j j  } xQ | D]I } t | d | d | d | } | d k rj q4 n  | j | | f  q4 W| s g  St	 d   | D  r |  j p | o |  j j }	 |	 s t
  n  t j d d j g  | D] \ } }
 | j ^ q   |  j } t   g  g  } } x| D]\ } } d } | rt j } | rc| j | j  } n | j | j  } y t |  Wqt k
 r} t j d | j |  | j |  q'qXn	 |  j } |  j | | d | } | r| j |  | r| j r9t j j t j j | j t   r9t
 d	   n  | j   | j |  j  j!  | _ t" t# |   | _ | j j$ st
  t% | j | j d t& d
 | qq'| j |  q'WWd QX| rt j d d j g  | D] } | j ^ q  n  | r.t j d d j g  | D] } | j ^ q  n  | S(   s   Build wheels.

        :param unpack: If True, replace the sdist we built from with the
            newly built wheel, in preparation for installation.
        :return: True if all the wheels built correctly.
        Rm  Rn  Ro  c         s@  s   |  ] \ } } | Vq d  S(   N(    (   R   Rn   t   ephem_cache(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pys	   <genexpr>  s    s*   Building wheels for collected packages: %ss   , s    Building wheel for %s failed: %sR  s   bad source dir - missing markert   sessionNs   Successfully built %sR}   s   Failed to build %s('   R  Rm  RY  R  R  t	   cache_dirRr  Rh   R   t   anyR   R   Rg  RV   RO   R   R   t   implementation_tagt   get_ephem_path_for_linkRj  t   get_path_for_linkR   t   OSErrorR   R  R6  R.   R/   R   R   t   remove_temporary_sourcet   build_locationR  t	   build_dirR   R   Rf  R   R`   (   RI  t   requirementsR  Rn  t   buildsetRm  Ro  R   R  t   have_directory_for_buildRn   t   _cachet   build_successt   build_failuret   ephemR  R  t   et
   wheel_file(    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyRA    s    		,	
		
			
))N(   R\  R]  R^  Rh   R`   RO  R  R  R  R  R  R  RA  (    (    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyR~  c  s   
		"!	(w   R^  t
   __future__R    R   R  R  R8   Rt  t   os.pathR.   R  R   R   RM   R  t   base64R   t   email.parserR   t   pip._vendorR   t   pip._vendor.distlib.scriptsR   t   pip._vendor.packaging.utilsR   t   pip._vendor.sixR   t   pip._internalR   t   pip._internal.downloadR   t   pip._internal.exceptionsR	   R
   R   t   pip._internal.locationsR   t   pip._internal.models.linkR   t   pip._internal.utils.loggingR   t    pip._internal.utils.marker_filesR   t   pip._internal.utils.miscR   R   R   R   R   R   R   t$   pip._internal.utils.setuptools_buildR   t   pip._internal.utils.temp_dirR   t   pip._internal.utils.typingR   t   pip._internal.utils.uiR   t   typingR   R   R   R   R   R    R!   R"   R#   R$   t"   pip._vendor.packaging.requirementsR%   t   pip._internal.req.req_installR&   R'   t   pip._internal.indexR(   R)   t    pip._internal.operations.prepareR*   t   pip._internal.cacheR+   t   pip._internal.pep425tagsR,   RH   t   InstalledCSVRowR;  t	   getLoggerR\  R   R5   RB   RI   RS   RZ   Rm   R_  R`  Rq   Rz   R   R   R   R   R`   Rh   Rg   R/  R:  R<  R>  t   objectR?  t   IRc  Rr  Rz  R}  R~  (    (    (    s2   lib/python2.7/site-packages/pip/_internal/wheel.pyt   <module>   s   4F							 	=		( 4			
D	6		 