
^Wc           @@  s  d  d l  m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l	 Z	 d  d l
 Z
 d  d l m Z d  d l m Z d  d l m Z d  d l m Z m Z d  d l m Z d  d l m Z d  d	 l m Z m Z d  d
 l m Z d  d l m Z d  d l m  Z  d  d l! Z" d  d l# m$ Z$ m% Z% m& Z& d  d l' m( Z( m) Z) m* Z* m+ Z+ d  d l, m- Z- m. Z. d  d l/ m0 Z0 m1 Z1 m2 Z2 m3 Z3 d  d l4 m5 Z5 m6 Z6 m7 Z7 m8 Z8 m9 Z9 m: Z: m; Z; m< Z< m= Z= m> Z> m? Z? m@ Z@ mA ZA mB ZB mC ZC mD ZD d  d lE mF ZF d  d lG mH ZH mI ZI d  d lJ mK ZK d  d lL mM ZM d  d lN mO ZO d  d lP mQ ZQ d  d lR mS ZS d  d l! mT ZT mU ZU e jV eW  ZX e jY jZ j[   Z\ d   Z] d e^ f d     YZ_ d   Z` d   Za eb d  Zc d S(    i    (   t   absolute_importN(   t	   sysconfig(   t   change_root(   t
   FeedParser(   t   pkg_resourcest   six(   t
   specifiers(   t   Marker(   t   InvalidRequirementt   Requirement(   t   canonicalize_name(   t   Version(   t   configparser(   t
   native_strt
   get_stdlibt   WINDOWS(   t   is_urlt   url_to_patht   path_to_urlt   is_archive_file(   t   InstallationErrort   UninstallationError(   t   bin_pyt   running_under_virtualenvt   PIP_DELETE_MARKER_FILENAMEt   bin_user(   t   display_patht   rmtreet   ask_path_existst
   backup_dirt   is_installable_dirt   dist_in_usersitet   dist_in_site_packagest   egg_link_patht   call_subprocesst   read_text_filet   FakeFilet   _make_build_dirt
   ensure_dirt   get_installed_versiont   normalize_patht   dist_is_local(   t   Hashes(   t   RemovedInPip9Warningt   RemovedInPip10Warning(   t
   indent_log(   t   SETUPTOOLS_SHIM(   t   open_spinner(   t   UninstallPathSet(   t   vcs(   t   move_wheel_filest   Wheelc         C@  sO   t  j d |   } d  } | r? | j d  } | j d  } n |  } | | f S(   Ns   ^(.+)(\[[^\]]+\])$i   i   (   t   ret   matcht   Nonet   group(   t   patht   mt   extrast   path_no_extras(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   _strip_extras9   s    t   InstallRequirementc           B@  s   e  Z d& e d& e e e d& e d& d& e d   Z e d& d& e d& d& e d   Z e d& e d& d& e d   Z d   Z	 d   Z
 d   Z e d    Z e d    Z d   Z d	   Z d
   Z e d    Z e d    Z e d    Z d   Z d   Z d   Z d   Z e j d  Z e d    Z d   Z e d  Z e d  Z d   Z  d   Z! d   Z" d   Z# d   Z$ g  d& d& d  Z% d   Z& d   Z' d' d& d  Z( d    Z) e d!    Z* d& d& d"  Z+ d#   Z, e d$    Z- e d%  Z. RS((   c         @  s  d |  _  t   t j  r y t      Wn t k
 r t j j   k rV d } n> d   k r t	   f d   t
 D  r d } n t j   } t d   | f   n X  j  |  _  n    |  _ | |  _ | |  _ | |  _ | |  _ | |  _ | |  _ |  _ | |  _ |	 |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ | |  _ d  |  _ d  |  _  t! |  _" t! |  _# d  |  _$ | r| n i  |  _% | |  _& t! |  _' |
 |  _( d  S(   Ns%   It looks like a path. Does it exist ?t   =c         3@  s   |  ] } |   k Vq d  S(   N(    (   t   .0t   op(   t   req(    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pys	   <genexpr>R   s    s,   = is not a valid operator. Did you mean == ?s   Invalid requirement: '%s'
%s(    ()   R:   t
   isinstanceR   t   string_typesR	   R   t   osR8   t   sept   anyt	   operatorst	   tracebackt
   format_excR   RA   t
   comes_fromt
   constraintt
   source_dirt   editablet   _wheel_cachet   linkt   original_linkt   as_eggt   markersR6   t   _egg_info_patht   satisfied_byt   conflicts_witht   _temp_build_dirt   _ideal_build_dirt   updatet   install_succeededt   uninstalledt   Falset   nothing_to_uninstallt   use_user_sitet
   target_dirt   optionst	   pycompilet   preparedt   isolated(   t   selfRA   RJ   RL   RM   RO   RQ   RX   R`   RR   Rb   R_   t   wheel_cacheRK   t   add_msg(    (   RA   sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   __init__G   sJ    		)																						c         C@  s   d d l  m } t | |  \ }	 }
 } |
 j d  rF t |
  } n d  } |  |	 | d | d t d | |
  d | d | d	 | r | n i  d
 | } | d  k	 r | | _ n  | S(   Ni    (   t   Links   file:RL   RM   RO   RK   Rb   R_   Rd   (   t	   pip.indexRg   t   parse_editablet
   startswithR   R6   t   TrueR:   (   t   clst   editable_reqRJ   t   default_vcsRb   R_   Rd   RK   Rg   t   namet   urlt   extras_overrideRL   t   res(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   from_editable   s     	c         C@  s  d d l  m } t |  r% d } n d } | | k rm | j | d  \ } }	 |	 j   }	 |	 ss d }	 qs n d }	 | j   } d }
 t j j t j j	 |   } d } d } t |  r | |  } n t
 |  \ } } t j j |  rCt j j | k s| j d  rCt |  s.t d |   n  | t |   } nF t |  rt j j |  stt j d |  n  | t |   } n  | r | j d	 k rt j d
 | j  r| t t j j t j j	 | j     } n  | j rt | j  } d | j | j f }
 q&| j }
 n | }
 | r2| n i  } |  |
 | d | d |	 d | d | d | d | } | rt d |  j  | _  n  | S(   s   Creates an InstallRequirement from a name, which might be a
        requirement, directory containing 'setup.py', filename, or URL.
        i    (   Rg   s   ; t   ;i   t   .s;   Directory %r is not installable. File 'setup.py' not found.sA   Requirement %r looks like a filename, but the file does not existt   files   \.\./s   %s==%sRO   RR   Rb   R_   Rd   RK   t   placeholderN(!   Rh   Rg   R   t   splitt   stripR6   RD   R8   t   normpatht   abspathR<   t   isdirRE   Rj   R   R   R   R   t   isfilet   loggert   warningt   schemeR4   t   searchRp   t   is_wheelR3   t   filenameRo   t   versiont   egg_fragmentR	   R:   (   Rl   Ro   RJ   Rb   R_   Rd   RK   Rg   t
   marker_sepRR   RA   R8   RO   R:   t   pt   wheelRr   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt	   from_line   s^    	!
$-	c         C@  s   |  j  r; t |  j   } |  j rV | d |  j j 7} qV n |  j rP |  j j n d  } |  j d  k	 r | d t |  j j  7} n  |  j r t	 |  j t
 j  r |  j } n |  j j   } | r | d | 7} q n  | S(   Ns    from %ss    in %ss
    (from %s)(   RA   t   strRO   Rp   R6   RT   R   t   locationRJ   RB   R   RC   t	   from_path(   Rc   t   sRJ   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   __str__   s    			c         C@  s    d |  j  j t |   |  j f S(   Ns   <%s object: %s editable=%r>(   t	   __class__t   __name__R   RM   (   Rc   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   __repr__   s    c         C@  s   |  j  d k r' | j |  |  |  _  n  |  j d k	 r | r |  j  } |  j j |  j  |  j  |  _  | |  j  k r t j d |  j   q n  d S(   s  Ensure that if a link can be found for this, that it is found.

        Note that self.link may still be None - if Upgrade is False and the
        requirement is already installed.

        If require_hashes is True, don't use the wheel cache, because cached
        wheels, always built locally, have different hashes than the files
        downloaded from the index server and thus throw false hash mismatches.
        Furthermore, cached wheels at present have undeterministic contents due
        to file modification times.
        s   Using cached wheel link: %sN(   RO   R6   t   find_requirementRN   t   cached_wheelRo   R~   t   debug(   Rc   t   findert   upgradet   require_hashest   old_link(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   populate_link   s    	c         C@  s
   |  j  j S(   N(   RA   t	   specifier(   Rc   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyR     s    c         C@  s4   |  j  } t |  d k o3 t t |   j d k S(   s   Return whether I am pinned to an exact version.

        For example, some-package==1.2 is pinned; some-package>1.2 is not.
        i   s   ==s   ===(   s   ==s   ===(   R   t   lent   nextt   itert   operator(   Rc   R   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt	   is_pinned  s    	c         C@  sy   |  j  d  k r d  St |  j   } |  j ru t |  j t j  rL |  j } n |  j j   } | ru | d | 7} qu n  | S(   Ns   ->(   RA   R6   R   RJ   RB   R   RC   R   (   Rc   R   RJ   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyR   !  s    	c         C@  s   |  j  d  k	 r |  j  S|  j d  k rJ t j d d  |  _  | |  _ |  j  S|  j re |  j j   } n	 |  j } t	 j
 j |  s t j d |  t |  n  t	 j
 j | |  S(   Ns   -builds   pip-s   Creating directory %s(   RV   R6   RA   t   tempfilet   mkdtempRW   RM   Ro   t   lowerRD   R8   t   existsR~   R   R%   t   join(   Rc   t	   build_dirRo   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   build_location.  s    			c         C@  s   |  j  d k	 r d S|  j d k	 s( t  |  j s7 t  |  j sF t  |  j } d |  _ |  j |  j  } t j j	 |  r t
 d t |    n  t j d |  t |  t |   t j | |  | |  _ d |  _ | |  _  d |  _ d S(   s  Move self._temp_build_dir to self._ideal_build_dir/self.req.name

        For some requirements (e.g. a path to a directory), the name of the
        package is not available until we run egg_info, so the build_location
        will return a temporary directory and store the _ideal_build_dir.

        This is only called by self.egg_info_path to fix the temporary build
        directory.
        Ns<   A package already exists in %s; please remove it to continues,   Moving package %s from %s to new location %s(   RL   R6   RA   t   AssertionErrorRV   RW   R   RD   R8   R   R   R   R~   R   t   shutilt   moveRS   (   Rc   t   old_locationt   new_location(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   _correct_build_locationD  s(    
					c         C@  s,   |  j  d  k r d  St t j |  j  j   S(   N(   RA   R6   R   R   t	   safe_nameRo   (   Rc   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyRo   d  s    c         C@  s+   t  j j |  j |  j r$ |  j j p' d  S(   Nt    (   RD   R8   R   RL   RO   t   subdirectory_fragment(   Rc   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   setup_py_dirj  s    	c         C@  s   |  j  s t d |    y d d  l } WnH t k
 rs t d  d  k rT d } n t j   } t d |   n Xt	 j
 j |  j d  } t j r t | t j  r | j t j    } n  | S(   Ns   No source dir for %si    t
   setuptoolss   Please install setuptools.sW   Could not import setuptools which is required to install from a source distribution.
%ss   setup.py(   RL   R   R   t   ImportErrorR'   R6   RH   RI   R   RD   R8   R   R   R   t   PY2RB   t	   text_typet   encodet   syst   getfilesystemencoding(   Rc   R   Re   t   setup_py(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyR   p  s    	c         C@  s  |  j  s t  |  j r4 t j d |  j |  j  n t j d |  j |  j  t    t |  j } t	 j
 d | g } |  j r | d g 7} n  | d g } |  j r g  } n. t j j |  j d  } t |  d d g } t | | d |  j d	 t d
 t j d d Wd  QX|  j st t j |  j   d  t  rBd } n d } t d j |  j   d | |  j   d g   |  _ |  j   nb t |  j   d  } t |  j j  | k rt j d |  j |  j | |  j  t |  |  _ n  d  S(   Ns2   Running setup.py (path:%s) egg_info for package %ss7   Running setup.py (path:%s) egg_info for package from %ss   -cs   --no-user-cfgt   egg_infos   pip-egg-infos
   --egg-baset   cwdt   show_stdoutt   command_levelt   command_descs   python setup.py egg_infoR   s   ==s   ===R   t   Namesu   Running setup.py (path:%s) egg_info for package %s produced metadata for project name %s. Fix your #egg=%s fragments.(    RL   R   Ro   R~   R   R   RO   R-   R.   R   t
   executableRb   RM   RD   R8   R   R   R&   R"   R[   t   loggingt   DEBUGRA   RB   R   t   parse_versiont   pkg_infoR   R	   R   R
   R   (   Rc   t   scriptt   base_cmdt   egg_info_cmdt   egg_base_optiont   egg_info_dirR@   t   metadata_name(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   run_egg_info  sV    	
			

					c         C@  sy   |  j  d  k	 r5 |  j  j |  s% d  S|  j  j |  S|  j sD t  |  j |  } t j j	 |  si d  St
 |  } | S(   N(   RT   R6   t   has_metadatat   get_metadataRL   R   t   egg_info_pathRD   R8   R   R#   (   Rc   R   t   data(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   egg_info_data  s    c   	      C@  s<  |  j  d  k r&|  j r$ |  j } n t j j |  j d  } t j |  } |  j rg  } xt j	 |  D]\ } } } x- t
 j D]" } | | k r | j |  q q Wx t |  D] } t j j t j j | | d d   s
t j j t j j | | d d   r| j |  q | d k s2| d k r | j |  q q W| j g  | D] } t j j | |  ^ qS qj Wg  | D] } | j d  r| ^ q} n  | st d	 | | f   n  | st d	 | | f   t |  d
 k r| j d d    n  t j j | | d  |  _  n  t j j |  j  |  S(   Ns   pip-egg-infot   bint   pythont   Scriptss
   Python.exet   testt   testss	   .egg-infos$   No files/directories in %s (from %s)i   t   keyc         S@  s8   |  j  t j j  t j j r3 |  j  t j j  p6 d S(   Ni    (   t   countRD   R8   RE   t   altsep(   t   x(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   <lambda>  s   i    (   RS   R6   RM   RL   RD   R8   R   R   t   listdirt   walkR1   t   dirnamest   removet   listR   t   extendt   endswithR   R   R   t   sort(	   Rc   R   t   baset	   filenamest   roott   dirst   filest   dirt   f(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyR     sB    						*+		c         C@  s]   t    } |  j d  } | s@ t j d t |  j d    n  | j | pO d  | j   S(   Ns   PKG-INFOs   No PKG-INFO file found in %sR   (   R   R   R~   R   R   R   t   feedt   close(   Rc   R   R   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyR     s    	s	   \[(.*?)\]c         C@  s   t  |  j  S(   N(   R'   Ro   (   Rc   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   installed_version  s    c         C@  sy   |  j  s t  |  j   d } |  j j rV | |  j j k rV t j d |  |  j  n t j d t	 |  j   | |   d  S(   NR   s'   Requested %s, but installing version %ss;   Source in %s has version %s, which satisfies requirement %s(
   RL   R   R   RA   R   R~   R   R   R   R   (   Rc   R   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   assert_source_matches_version  s    c         C@  s  |  j  s  t j d |  j  d  S|  j s/ t  |  j s> t  |  j  j d k rT d  Sd |  j  j k s| t d |  j  j   |  j s d  S|  j  j j	 d d  \ } } t
 j |  } | r | |  j  j  } | r | j |  j  q| j |  j  n d st d |  j  | f   d  S(   Ns>   Cannot update repository at %s; repository location is unknownRv   t   +s   bad url: %ri   i    s+   Unexpected version control type (in %s): %s(   RO   R~   R   RL   RM   R   R   Rp   RX   Rx   R1   t   get_backendt   obtaint   export(   Rc   R   t   vc_typeRp   t   backendt   vcs_backend(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   update_editable)  s,    	
(		c         C@  s  |  j    s% t d |  j f   n  |  j p4 |  j } t | j  } t |  s{ t j	 d | j
 | t j  t |  _ d S| t   k r t j	 d | j
 |  t |  _ d St |  } t |  } d j t j | j   } | j o t j j | j  } t | j d d  } | r| j j d  r| j j |  r| j | j  | j d  rx'| j  d  j!   D]7 }	 t j j" t j j# | j |	   }
 | j |
  qsWq;| j d	  r;| j d
  r| j  d
  } n g  } x g  | j  d	  j!   D] } | r | | k r | ^ q D]^ } t j j# | j |  }
 | j |
  | j |
 d  | j |
 d  | j |
 d  q"Wq;n| rt$ j% d j |  j  t&  | j |  n| j j d  r2| j | j  t j j' | j  d } t j j# t j j( | j  d  } | j) | d |  n	| rt* | d  % } t j j+ | j,   j-    } Wd QX| | j k st. d | |  j | j f   | j |  t j j# t j j( |  d  } | j) | | j  n[ | r%| j j d  r%x@ t/ j0 j1 |  D] }
 | j |
  qWn t j2 d | | j  | j d  r| j3 d  rxz | j4 d  D]f } t5 |  rt6 } n t7 } | j t j j# | |   t8 ri| j t j j# | |  d  qiqiWn  | j d  rt9 j: ri  } n i d  d 6} t; j< |   } | j= t> | j? d    | j@ d  rx | jA d  D] \ } } t5 |  rot6 } n t7 } | j t j j# | |   t8 rN| j t j j# | |  d  | j t j j# | |  d  | j t j j# | |  d  qNqNWqn  | jB |  | |  _C d S(!   s  
        Uninstall the distribution currently satisfying this requirement.

        Prompts before removing or modifying files unless
        ``auto_confirm`` is True.

        Refuses to delete or modify files outside of ``sys.prefix`` -
        thus uninstallation within a virtual environment can only
        modify that virtual environment, even if the virtualenv is
        linked to global site-packages.

        s.   Cannot uninstall requirement %s, not installeds1   Not uninstalling %s at %s, outside environment %sNs<   Not uninstalling %s at %s, as it is in the standard library.s   {0}.egg-infoR8   s	   .egg-infos   installed-files.txts   top_level.txts   namespace_packages.txts   .pys   .pycs   .pyos   Uninstalling a distutils installed project ({0}) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project.s   .eggi   s   easy-install.pths   ./t   rs;   Egg-link %s does not match installed location of %s (at %s)s
   .dist-infos)   Not sure how to uninstall: %s - Check: %st   scriptss   .bats   entry_points.txtR>   t
   delimiterst   console_scriptss   .exes   .exe.manifests
   -script.py(   R>   (D   t   check_if_existsR   Ro   RT   RU   R(   R   R)   R~   t   infoR   R   t   prefixRk   R\   R   R0   R!   t   formatR   t   to_filenamet   project_nameR   RD   R8   R   t   getattrt	   _providerR6   R   t   addR   R   t
   splitlinesRz   R   t   warningst   warnR,   Rx   t   dirnamet   add_ptht   opent   normcaset   readlineRy   R   t   pipR   t   uninstallation_pathsR   t   metadata_isdirt   metadata_listdirR   R   R   R   R   R   R   t   SafeConfigParsert   readfpR$   t   get_metadata_linest   has_sectiont   itemsR   RZ   (   Rc   t   auto_confirmt   distt	   dist_patht   paths_to_removet   develop_egg_linkt   develop_egg_link_egg_infot   egg_info_existst   distutils_egg_infot   installed_fileR8   t
   namespacesR   t   top_level_pkgt   easy_install_eggt   easy_install_ptht   fht   link_pointerR   t   bin_dirR_   t   configRo   t   value(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt	   uninstallF  s    
				"		$		*			'c         C@  s0   |  j  r |  j  j   n t j d |  j  d  S(   Ns'   Can't rollback %s, nothing uninstalled.(   RZ   t   rollbackR~   t   errorRo   (   Rc   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   rollback_uninstall  s    	c         C@  s<   |  j  r |  j  j   n |  j s8 t j d |  j  n  d  S(   Ns%   Can't commit %s, nothing uninstalled.(   RZ   t   commitR\   R~   R'  Ro   (   Rc   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   commit_uninstall  s
    		c         C@  s  |  j  s t  t } d |  j |  j   d f } t j j | |  } t j j |  rt	 d t
 |  d  } | d k r t } q| d k r t j d t
 |   t j |  q| d k rt |  } t j d t
 |  t
 |   t j | |  qn  | rt j | d t j d	 t } t j j t j j |  j   } xt j |  D] \ }	 }
 } d
 |
 k r|
 j d
  n  xl |
 D]d } t j j |	 |  } |  j | |  } t j |  j d | d  } d | _ | j | d  qWxb | D]Z } | t k rqn  t j j |	 |  } |  j | |  } | j | |  j d |  qWq[W| j   t j  d t
 |   n  d  S(   Ns	   %s-%s.zipR   s/   The file %s exists. (i)gnore, (w)ipe, (b)ackup t   it   wt   bs   Deleting %ss   Backing up %s to %st
   allowZip64s   pip-egg-infot   /i  i   R   s   Saved %s(   R+  R,  R-  i  (!   RL   R   Rk   Ro   R   RD   R8   R   R   R   R   R[   R~   R   R   R   R   R   t   zipfilet   ZipFilet   ZIP_DEFLATEDR  R{   R   R   t   _clean_zip_namet   ZipInfot   external_attrt   writestrR   t   writeR   R   (   Rc   R   t   create_archivet   archive_namet   archive_patht   responset	   dest_filet   zipR   t   dirpathR   R   R  Ro   t   zipdirR   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   archive  sT    			!	#
c         C@  s_   | j  | t j j  s/ t d | | f   | t |  d } | j t j j d  } | S(   Ns$   name %r doesn't start with prefix %ri   R/  (   Rj   RD   R8   RE   R   R   t   replace(   Rc   Ro   R   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyR3  '  s
    c         C@  s*   |  j  d  k	 r" t |  j   j   St Sd  S(   N(   RR   R6   R   t   evaluateRk   (   Rc   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   match_markers/  s    c         @  s  |  j  r# |  j | | d | d  S|  j r t j j |  j  } t j j | |  j  |  j	 |  j d   d | t
 |  _ d  S| |  j j d g   7} | |  j j d g   7} |  j r t |  d g } n  t j d d  } t j j | d  } zt j d	 g } | j d
  | j t |  j  | t |  d d | g 7} |  j sa| d g 7} n    d  k	 r| d   g 7} n  | d  k	 r| d | g 7} n  |  j r| d g 7} n | d g 7} t   rd t j   }	 | d t j j t j  d d |	 |  j  g 7} n  d |  j f }
 t! |
  : } t"   ( t# | | d |  j$ d t% d | Wd  QXWd  QXt j j& |  st' j( d |  d  St
 |  _ |  j rd  S  f d   } t) |  ] } xS | D]7 } t j j* |  } | j+ d  r| |  } PqqWt' j, d |   d  SWd  QXg  } t) |  k } xa | D]Y } | j-   } t j j. |  rp| t j j/ 7} n  | j t j j0 | |  |   q9WWd  QXt j j | d  } t) | d  ! } | j1 d  j |  d   Wd  QXWd  t j j& |  r	t j2 |  n  t3 |  Xd  S(!   NR   R   t   global_optionst   install_optionss   --no-user-cfgs   -records   pip-s   install-record.txts   -us   -ct   installs   --records#   --single-version-externally-manageds   --roots   --prefixs	   --compiles   --no-compileR   s   --install-headerst   includet   sites   Running setup.py install for %sR   R   t   spinners   Record file %s not foundc         @  s4     d  k s t j j |   r# |  St   |   Sd  S(   N(   R6   RD   R8   t   isabsR   (   R8   (   R   (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   prepend_root|  s    s	   .egg-infos;   Could not find .egg-info directory in install record for %ss   installed-files.txtR,  s   
(4   RM   t   install_editableR   R
  R   t   wheel_versionRL   t   check_compatibilityRo   R2   Rk   RY   R_   t   getRb   R   R   R   RD   R8   R   R   R   t   appendR.   R   RQ   R6   R`   R   R   t   get_python_versionR   R/   R-   R"   R   R[   R   R~   R   R  R  R   R   Ry   R|   RE   t   relpathR7  R   R   (   Rc   RE  RD  R   R   R   t   temp_locationt   record_filenamet   install_argst
   py_ver_strt   msgRI  RK  R   t   linet	   directoryR   t	   new_linesR   t   inst_files_path(    (   R   sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyRF  5  s    							

			
	$c         C@  s+   |  j  d k r$ |  j |  |  _  n  |  j  S(   sA  Ensure that a source_dir is set.

        This will create a temporary build dir if the name of the requirement
        isn't known yet.

        :param parent_dir: The ideal pip parent_dir for the source_dir.
            Generally src_dir for editables and build_dir for sdists.
        :return: self.source_dir
        N(   RL   R6   R   (   Rc   t
   parent_dir(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   ensure_has_source_dir  s    
c         C@  s   |  j  rP t j j t j j |  j  t   rP t j d |  j   t |  j   n  d |  _  |  j
 r t j j |  j
  r t |  j
  n  d |  _
 d S(   sV   Remove the source files from this requirement, if they are marked
        for deletions   Removing source in %sN(   RL   RD   R8   R   R   R   R~   R   R   R6   RV   (   Rc   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   remove_temporary_source  s    	c      
   C@  s   t  j d |  j  |  j r2 t |  d g } n  | r] d j |  g } t |  | } n  t   O t t j	 d t
 |  j g t |  d d g t |  d |  j d t Wd  QXt |  _ d  S(	   Ns   Running setup.py develop for %ss   --no-user-cfgs   --prefix={0}s   -ct   develops	   --no-depsR   R   (   R~   R   Ro   Rb   R   R   R-   R"   R   R   R.   R   R   R[   Rk   RY   (   Rc   RE  RD  R   t   prefix_param(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyRL    s    	
*	c         C@  s   |  j  d k r t Sy: t t |  j    } d | _ t j t |   |  _ Wn t j	 k
 rd t St j
 k
 r t j |  j  j  } |  j r t |  r | |  _ q t   r t |  r t d | j | j f   q q | |  _ n Xt S(   s   Find an installed distribution that satisfies or conflicts
        with this requirement, and set self.satisfied_by or
        self.conflicts_with appropriately.
        sV   Will not install to the user site because it will lack sys.path precedence to %s in %sN(   RA   R6   R[   R	   R   t   markerR   t   get_distributionRT   t   DistributionNotFoundt   VersionConflictRo   R]   R   RU   R   R    R   R   R   Rk   (   Rc   t	   no_markert   existing_dist(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyR     s*    			c         C@  s   |  j  o |  j  j S(   N(   RO   R   (   Rc   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyR     s    c         C@  sJ   t  |  j |  j | d |  j d |  j d | d | d |  j d |  j d  S(   Nt   usert   homeR   R   R`   Rb   (   R2   Ro   RA   R]   R^   R`   Rb   (   Rc   t   wheeldirR   R   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyR2      s    			c         C@  s   |  j  d  j d  } t j j |  } t j | |  } t j j t j j |   d } t j	 t j j |  d | d | S(   sA   Return a pkg_resources.Distribution built from self.egg_info_pathR   R/  i    R   t   metadata(
   R   t   rstripRD   R8   R  R   t   PathMetadatat   splitextt   basenamet   Distribution(   Rc   R   t   base_dirRj  t	   dist_name(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   get_dist  s    "c         C@  s   t  |  j j d i    S(   s   Return whether any known-good hashes are specified as options.

        These activate --require-hashes mode; hashes specified as part of a
        URL do not.

        t   hashes(   t   boolR_   RO  (   Rc   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   has_hash_options  s    c         C@  sn   |  j  j d i   j   } | r* |  j n |  j } | rd | j rd | j | j g   j | j  n  t	 |  S(   s  Return a hash-comparer that considers my option- and URL-based
        hashes to be known-good.

        Hashes in URLs--ones embedded in the requirements file, not ones
        downloaded from an index server--are almost peers with ones from
        flags. They satisfy --require-hashes (whether it was implicitly or
        explicitly activated) but do not activate it. md5 and sha224 are not
        allowed in flags, which should nudge people toward good algos. We
        always OR all hashes together, even ones from URLs.

        :param trust_internet: Whether to trust URL-based (#md5=...) hashes
            downloaded from the internet, as by populate_link()

        Rs  (
   R_   RO  t   copyRO   RP   t   hasht
   setdefaultt	   hash_nameRP  R*   (   Rc   t   trust_internett   good_hashesRO   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyRs     s
    "N(    (/   R   t
   __module__R6   R[   Rk   Rf   t   classmethodRs   R   R   R   R   t   propertyR   R   R   R   R   Ro   R   R   R   R   R   R   R4   t   compilet   _requirements_section_reR   R   R   R%  R(  R*  R@  R3  RC  RF  R]  R^  RL  R   R   R2   Rr  Ru  Rs  (    (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyR=   E   s^   	8		J			
			 	=		6					.		m			#	
c         C@  s.   t  j d |   } | r* | j d  }  n  |  S(   s2   
        Strip req postfix ( -dev, 0.2, etc )
    s   ^(.*?)(?:-dev|-\d.*)$i   (   R4   R   R7   (   RA   R5   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   _strip_postfix6  s    c         C@  s   g  |  j  d d  d j  d  D] } | r  | ^ q  } d  } t |  d k rm | d d k rm | d } n/ t |  d k r | d d k r | d } n  | r t j d t d d n  | S(   Nt   #i   i    R/  i   it   tagst   branchest   tagt   branchiit   trunks   Sniffing the requirement name from the url is deprecated and will be removed in the future. Please specify an #egg segment instead.t
   stacklevel(   s   tagss   branchess   tags   branch(   Rx   R6   R   R  R  R+   (   Rp   R   t   partsRA   (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   _build_req_from_urlB  s    8""
c         C@  s:  d d l  m } |  } d } t j d |  } | rU | j d  } | j d  } n | } t j j |  r t j j	 t j j
 | d   s t d |   n  t |  } n  | j   j d  r| |  j } | r | | t d	 |  j f S| | d f Sn  x; t D]3 } | j   j d
 |  rd | | f } PqqWd | k rx| re| d | } qxt d |    n  | j d d  d j   }	 t j |	  sd |  d j
 g  t j D] }
 |
 j d ^ q d } t |   n  | |  j } | st |   } n  | s't d |    n  t |  | d f S(   s   Parses an editable requirement into:
        - a requirement name
        - an URL
        - extras
        - editable options
    Accepted requirements:
        svn+http://blahblah@rev#egg=Foobar[baz]&subdirectory=version_subdir
        .[some_extra]
    i    (   Rg   s   ^(.+)(\[[^\]]+\])$i   i   s   setup.pys;   Directory %r is not installable. File 'setup.py' not found.s   file:Rw   s   %s:s   %s+%sR   sb   %s should either be a path to a local project or a VCS url beginning with svn+, git+, hg+, or bzr+s   For --editable=%s only s   , s   +URLs    is currently supporteds@   --editable=%s is not the right format; it must have #egg=PackageN(   Rh   Rg   R6   R4   R5   R7   RD   R8   R|   R   R   R   R   R   Rj   R   R	   R:   R1   Rx   R   t   backendsRo   R  R  (   Rm   Rn   Rg   Rp   R:   R9   t   url_no_extrast   package_namet   version_controlR   R   t   error_message(    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyRi   T  sX    !1(d   t
   __future__R    R   RD   R4   R   R   R   RH   R  R0  t	   distutilsR   t   distutils.utilR   t   email.parserR   t   pip._vendorR   R   t   pip._vendor.packagingR   t   pip._vendor.packaging.markersR   t"   pip._vendor.packaging.requirementsR   R	   t   pip._vendor.packaging.utilsR
   t   pip._vendor.packaging.versionR   t   pip._vendor.six.movesR   t	   pip.wheelR
  t
   pip.compatR   R   R   t   pip.downloadR   R   R   R   t   pip.exceptionsR   R   t   pip.locationsR   R   R   R   t	   pip.utilsR   R   R   R   R   R   R    R!   R"   R#   R$   R%   R&   R'   R(   R)   t   pip.utils.hashesR*   t   pip.utils.deprecationR+   R,   t   pip.utils.loggingR-   t   pip.utils.setuptools_buildR.   t   pip.utils.uiR/   t   pip.req.req_uninstallR0   t   pip.vcsR1   R2   R3   t	   getLoggerR   R~   t	   Specifiert
   _operatorst   keysRG   R<   t   objectR=   R  R  R6   Ri   (    (    (    sd   /private/var/folders/3n/6h2rwf155rn1m71wwyxn79n80000gn/T/pip-build-IcAT_k/pip/pip/req/req_install.pyt   <module>   sV   ""j	   		