
.Wc           @   sI  d  Z  d d l m Z d d l m Z d d l m Z m Z d d l m Z m Z m	 Z	 m
 Z
 d d l m Z m Z d d l m Z m Z d d l m Z d d	 l m Z d d
 l Z d d
 l Z d d
 l Z d d
 l Z d d
 l Z d d
 l Z d d
 l Z d d
 l Z d d
 l Z d d
 l Z d d
 l Z d d
 l  Z  d d
 l! Z! d d
 l" Z" d d
 l# Z# d d
 l$ Z$ d d
 l% 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/ m0 Z0 m1 Z1 d d l2 m3 Z3 d d l4 m5 Z5 d d l6 m7 Z7 d d l6 m8 Z8 d d l2 m9 Z9 m: Z: d d l; m< Z< m= Z= m> Z> m? Z? m@ Z@ mA ZA mB ZB mC ZC mD ZD mE ZE mF ZF mG ZG mH ZH mI ZI mJ ZJ d d
 l; Z; e jK d d e; jL d d d d d d g ZM d   ZN d   ZO e' jP rd    ZQ d!   ZR n d"   ZQ d#   ZR d$   ZS d e, f d%     YZT d&   ZU d'   ZV d(   ZW d)   ZX d*   ZY d eB f d+     YZZ d, eZ f d-     YZ[ e j\ j] d. d/  d0 k re[ ZZ n  d1   Z^ d2   Z_ d3   Z` d4   Za eb d5  Zc d6   Zd d7   Ze d8 e jf k ree Zg n	 d9   Zg d: d;  Zh d<   Zi d=   Zj d>   Zk y d d? l ml Zm Wn en k
 r^d@   Zm n XdA   Zl dB eo f dC     YZp ep jq   Zr dD ep f dE     YZs dF et f dG     YZu dH eu f dI     YZv dJ ev f dK     YZw eu jx Zx eu jy Zy dL   Zz dM   Z{ e| e_ dN  Z} dO   Z~ dP   Z eb dQ  Z e" j dR    Z d
 S(S   s  
Easy Install
------------

A tool for doing automatic download/extract/build of distutils-based Python
packages.  For detailed documentation, see the accompanying EasyInstall.txt
file, or visit the `EasyInstall home page`__.

__ https://pythonhosted.org/setuptools/easy_install.html

i(   t   glob(   t   get_platform(   t   convert_patht
   subst_vars(   t   DistutilsArgErrort   DistutilsOptionErrort   DistutilsErrort   DistutilsPlatformError(   t   INSTALL_SCHEMESt   SCHEME_KEYS(   t   logt   dir_util(   t   first_line_re(   t   find_executableN(   t   six(   t   configparsert   map(   t   Command(   t	   run_setup(   t   get_patht   get_config_vars(   t   setopt(   t   unpack_archive(   t   PackageIndex(   t
   URL_SCHEME(   t	   bdist_eggt   egg_info(   t   yield_linest   normalize_patht   resource_stringt   ensure_directoryt   get_distributiont   find_distributionst   Environmentt   Requirementt   Distributiont   PathMetadatat   EggMetadatat
   WorkingSett   DistributionNotFoundt   VersionConflictt   DEVELOP_DISTt   defaultt   categoryt   samefilet   easy_installt   PthDistributionst   extract_wininst_cfgt   maint   get_exe_prefixesc           C   s   t  j d  d k S(   Nt   Pi   (   t   structt   calcsize(    (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   is_64bitI   s    c         C   s   t  j j |   o! t  j j |  } t t  j d  o9 | } | rU t  j j |  |  St  j j t  j j |    } t  j j t  j j |   } | | k S(   s   
    Determine if two paths reference the same file.

    Augments os.path.samefile to work on Windows and
    suppresses errors if the path doesn't exist.
    R,   (   t   ost   patht   existst   hasattrR,   t   normpatht   normcase(   t   p1t   p2t
   both_existt   use_samefilet   norm_p1t   norm_p2(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR,   M   s    $c         C   s   |  S(   N(    (   t   s(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt	   _to_ascii^   s    c         C   s1   y t  j |  d  t SWn t k
 r, t SXd  S(   Nt   ascii(   R   t	   text_typet   Truet   UnicodeErrort   False(   RB   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   isasciia   s
    c         C   s   |  j  d  S(   NRD   (   t   encode(   RB   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRC   h   s    c         C   s.   y |  j  d  t SWn t k
 r) t SXd  S(   NRD   (   RJ   RF   RG   RH   (   RB   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRI   k   s
    c         C   s   t  j |   j   j d d  S(   Ns   
s   ; (   t   textwrapt   dedentt   stript   replace(   t   text(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   <lambda>s   s    c           B   sW  e  Z d  Z d Z e Z d d d d d d d d d d d d d d d d d d d d d g Z d d d d
 d d- d0 d6 d9 g	 Z e	 j
 r d= e	 j Z e j d> d~ e f  e j d>  n  i d d' 6Z e Z d?   Z d@   Z dA   Z e dB    Z dC   Z dD   Z dE   Z dF   Z dG   Z dH   Z dI   Z dJ   Z dK   Z e j  dL  j!   Z" e j  dM  j!   Z# e j  dN  j!   Z$ dO   Z% dP   Z& dQ   Z' dR   Z( dS   Z) dT   Z* e+ dU  Z, e+ dV  Z- dW   Z. e dX  Z/ dY   Z0 dZ   Z1 d[   Z2 d~ d\  Z3 e d]    Z4 d^ d d_  Z5 d`   Z6 da   Z7 db   Z8 dc   Z9 dd   Z: e j  de  j!   Z; e j  df  Z< dg dh  Z= e j  di  j!   Z> dj   Z? dk   Z@ dl   ZA dm   ZB dn   ZC do   ZD dp   ZE dq   ZF e j  dr  j!   ZG ds   ZH dt   ZI du   ZJ eK dv eK dw dx dy dz   ZL eK dw d{ dy d|  ZM d}   ZN RS(   s'   Manage a download/build/install processs    Find/get/install Python packagess   prefix=s   installation prefixs   zip-okt   zs   install package as a zipfiles   multi-versiont   ms%   make apps have to require() a versiont   upgradet   Us1   force upgrade (searches PyPI for latest versions)s   install-dir=t   ds   install package to DIRs   script-dir=RB   s   install scripts to DIRs   exclude-scriptst   xs   Don't install scriptss   always-copyt   as'   Copy all needed packages to install dirs
   index-url=t   is    base URL of Python Package Indexs   find-links=t   fs(   additional URL(s) to search for packagess   build-directory=t   bs/   download/extract/build in DIR; keep the resultss	   optimize=t   Osl   also compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0]s   record=s3   filename in which to record list of installed filess   always-unzipt   Zs*   don't install as a zipfile, no matter whats
   site-dirs=t   Ss)   list of directories where .pth files workt   editablet   es+   Install specified packages in editable forms   no-depst   Ns   don't install dependenciess   allow-hosts=t   Hs$   pattern(s) that hostnames must matchs   local-snapshots-okt   ls(   allow building eggs from local checkoutst   versions"   print version information and exits   no-find-linkss9   Don't load find-links defined in packages being installeds!   install in user site-package '%s't   userc         C   s  d |  _  d  |  _ |  _ d  |  _ |  _ |  _ d  |  _ d  |  _ d  |  _	 d  |  _
 d  |  _ |  _ d  |  _ |  _ |  _ d  |  _ |  _ |  _ d  |  _ |  _ |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ t j  rt j! |  _" t j# |  _$ n d  |  _" d  |  _$ d  |  _% d  |  _& d  |  _' |  _( d  |  _) i  |  _* t+ |  _, d  |  _- |  j. j/ |  _/ |  j. j0 |  |  j. j1 d   d  S(   Ni    R-   (2   Rd   t   Nonet   zip_okt   local_snapshots_okt   install_dirt
   script_dirt   exclude_scriptst	   index_urlt
   find_linkst   build_directoryt   argst   optimizet   recordRS   t   always_copyt   multi_versionR^   t   no_depst   allow_hostst   roott   prefixt	   no_reportRc   t   install_purelibt   install_platlibt   install_headerst   install_libt   install_scriptst   install_datat   install_baset   install_platbaset   sitet   ENABLE_USER_SITEt	   USER_BASEt   install_userbaset	   USER_SITEt   install_usersitet   no_find_linkst   package_indext   pth_filet   always_copy_fromt	   site_dirst   installed_projectsRH   t   sitepy_installedt   _dry_runt   distributiont   verboset   _set_command_optionst   get_option_dict(   t   self(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   initialize_options   sF    																								c         C   s*   d   | D } t  t |  j |   d  S(   Nc         s   s9   |  ]/ } t  j j |  s- t  j j |  r | Vq d  S(   N(   R6   R7   R8   t   islink(   t   .0t   filename(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pys	   <genexpr>   s    (   t   listR   t   _delete_path(   R   t   blockerst   extant_blockers(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   delete_blockers   s    c         C   se   t  j d |  |  j r d  St j j |  o? t j j |  } | rN t n t j } | |  d  S(   Ns   Deleting %s(	   R
   t   infot   dry_runR6   R7   t   isdirR   t   rmtreet   unlink(   R   R7   t   is_treet   remover(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR      s    	%c          C   s=   t  j d  }  t d  } d } | j t     GHt    d S(   sT   
        Render the Setuptools version and installation details, then exit.
        i   t
   setuptoolss=   setuptools {dist.version} from {dist.location} (Python {ver})N(   t   sysRc   R   t   formatt   localst
   SystemExit(   t   vert   distt   tmpl(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   _render_version   s
    c   
      C   s  |  j  o |  j   t j  j   d } t d d  \ } } i |  j j   d 6|  j j   d 6|  j j   d 6| d 6| d d !d	 6| d | d
 d 6| d 6| d 6| d 6| d 6t	 t d d  d 6|  _
 t j r |  j |  j
 d <|  j |  j
 d <n  |  j   |  j   |  j   |  j d d d d  |  j d  k rI|  j |  _ n  |  j d  k rdt |  _ n  |  j d d%  |  j d d&  |  j r|  j r|  j |  _ |  j |  _ n  |  j d d'  t t t j  } t   |  _  |  j! d  k	 rg  |  j! j d  D] } t" j j# | j$    ^ q} xq | D]f } t" j j% |  sWt& j' d |  q,t |  | k r|t( | d   q,|  j  j) t |   q,Wn  |  j* s|  j+   n  |  j, pd |  _, |  j  |  _- xE |  j t |  j  f D]+ } | |  j- k r|  j- j. d |  qqW|  j/ d  k	 rSg  |  j/ j d  D] } | j$   ^ q8}	 n	 d g }	 |  j0 d  k r|  j1 |  j, d |  j- d  |	 |  _0 n  t2 |  j- t j  |  _3 |  j4 d  k	 rt5 |  j4 t6 j7  r|  j4 j   |  _4 qn	 g  |  _4 |  j8 r|  j0 j9 |  j- t j  n  |  j s5|  j0 j: |  j4  n  |  j d d(  t5 |  j; t<  sy> t< |  j;  |  _; d |  j; k od
 k n st=  n  Wqt= k
 rt( d"   qXn  |  j* r|  j> rt? d#   n  |  j@ st? d$   n  g  |  _A d  S()   Ni    Rv   t   exec_prefixt	   dist_namet   dist_versiont   dist_fullnamet
   py_versioni   t   py_version_shorti   t   py_version_nodott
   sys_prefixt   sys_exec_prefixt   abiflagst    t   userbaset   usersiteRh   Ri   Rm   R   R{   R|   t   installRp   t   ,s"   %s (in --site-dirs) does not exists$    (in --site-dirs) is not on sys.paths   https://pypi.python.org/simplet   *t   search_patht   hostsRo   s   --optimize must be 0, 1, or 2s9   Must specify a build directory (-b) when using --editables:   No urls, filenames, or requirements specified (see --help)(   s   install_dirs   install_dir(   s   install_dirs
   script_dir(   s   records   record(   s   optimizes   optimize(B   Rc   R   R   t   splitR   R   t   get_namet   get_versiont   get_fullnamet   getattrt   config_varsR   R   R   R   t   _fix_install_dir_for_user_sitet   expand_basedirst   expand_dirst   _expandRi   Re   Rh   R   RH   t   set_undefined_optionsRd   Rx   R|   R   R   R7   t   get_site_dirst   all_site_dirsR   R6   t
   expanduserRM   R   R
   t   warnR   t   appendR^   t   check_site_dirRk   t   shadow_patht   insertRt   R   t   create_indexR!   t   local_indexRl   t
   isinstanceR   t   string_typesRg   t   scan_egg_linkst   add_find_linksRo   t   intt
   ValueErrorRm   R   Rn   t   outputs(
   R   R   Rv   R   R:   RB   R   RU   t	   path_itemR   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   finalize_options   s    	


	

4	.	!				c         C   s   |  j  s t j r d S|  j   |  j d k rF d } t |   n  |  j |  _ |  _ t	 j
 j d d  d } |  j |  d S(   s;   
        Fix the install_dir if "--user" was used.
        Ns$   User base directory is not specifiedt   posixt   unixt   _user(   Rd   R   R   t   create_home_pathR   Re   R   R~   R   R6   t   nameRN   t   select_scheme(   R   t   msgt   scheme_name(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR   k  s    
c         C   s   x | D]y } t  |  |  } | d  k	 r t j d k sF t j d k r[ t j j |  } n  t | |  j  } t |  | |  q q Wd  S(   NR   t   nt(	   R   Re   R6   R   R7   R   R   R   t   setattr(   R   t   attrst   attrt   val(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   _expand_attrsz  s    c         C   s   |  j  d d d g  d S(   sN   Calls `os.path.expanduser` on install_base, install_platbase and
        root.R~   R   Ru   N(   R   (   R   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR     s    c         C   s)   d d d d d d g } |  j  |  d S(   s+   Calls `os.path.expanduser` on install dirs.Rx   Ry   R{   Rz   R|   R}   N(   R   (   R   t   dirs(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR     s    	c         C   s  |  j  |  j j  k r( t j |  j   n  z x% |  j D] } |  j | |  j  q5 W|  j r |  j } |  j	 r t
 |  j	  } x/ t t
 |   D] } | | | | | <q Wn  d d l m } |  j | j |  j | f d |  j  n  |  j   Wd  t j |  j j   Xd  S(   Ni(   t	   file_utils'   writing list of installed files to '%s'(   R   R   R
   t   set_verbosityRn   R-   Rs   Rp   R   Ru   t   lent   ranget	   distutilsR   t   executet
   write_filet   warn_deprecated_options(   R   t   specR   t   root_lent   counterR   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   run  s$    			c         C   sS   y t  j   } Wn& t k
 r8 t j d t j  } n Xt  j j |  j	 d |  S(   s   Return a pseudo-tempname base in the install directory.
        This code is intentionally naive; if a malicious party can write to
        the target directory you're already in deep doodoo.
        i    s   test-easy-install-%s(
   R6   t   getpidt	   Exceptiont   randomt   randintR   t   maxsizeR7   t   joinRh   (   R   t   pid(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   pseudo_tempname  s
    c         C   s   d  S(   N(    (   R   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR     s    c         C   s  t  |  j  } t j j | d  } | |  j k } | rS |  j rS |  j   } n |  j   d } t j j	 |  } y: | r t j
 |  n  t | d  j   t j
 |  Wn! t t f k
 r |  j   n X| r |  j r t |  j     n  | r)|  j d k r2t | |  j  |  _ q2n	 d |  _ t j j d d  j t j  } | t t  t d |   k r}t |  _ n1 |  j rt j j	 |  rt |  _ d |  _ n  | |  _ d S(   s;   Verify that self.install_dir is .pth-capable dir, if neededs   easy-install.pths   .write-testt   wt
   PYTHONPATHR   N(   R   Rh   R6   R7   R   R   Rr   t   check_pth_processingR   R8   R   t   opent   closet   OSErrort   IOErrort   cant_write_to_targetR   t   no_default_version_msgR   Re   R.   t   environt   getR   t   pathsepR   t   filterRF   R   (   R   t   instdirR   t   is_site_dirt   testfilet   test_existsR   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR     s6    	!	sS  
        can't create or remove files in install directory

        The following error occurred while trying to add or remove files in the
        installation directory:

            %s

        The installation directory you specified (via --install-dir, --prefix, or
        the distutils default setting) was:

            %s
        s   
        This directory does not currently exist.  Please create it and try again, or
        choose a different installation directory (using the -d or --install-dir
        option).
        s  
        Perhaps your account does not have write access to this directory?  If the
        installation directory is a system-owned directory, you may need to sign in
        as the administrator or "root" account.  If you do not have administrative
        access to this machine, you may wish to choose a different installation
        directory, preferably one that is listed in your PYTHONPATH environment
        variable.

        For information on other options, you may wish to consult the
        documentation at:

          https://pythonhosted.org/setuptools/easy_install.html

        Please make the appropriate changes for your system and try again.
        c         C   sj   |  j  t j   d |  j f } t j j |  j  sI | d |  j 7} n | d |  j 7} t	 |   d  S(   Ni   s   
(
   t   _easy_install__cant_write_msgR   t   exc_infoRh   R6   R7   R8   t   _easy_install__not_exists_idt   _easy_install__access_msgR   (   R   R   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    s
     c         C   sH  |  j  } t j d |  |  j   d } | d } t j j |  } t d  d } y] | rn t j |  n  t j j	 |  } t j j |  s t j
 |  n  t | d  } Wn! t t f k
 r |  j   nSXz | j | j t      | j   d } t j } t j d k r}t j j |  \ } }	 t j j | d  }
 |	 j   d	 k oht j j |
  } | r}|
 } q}n  d
 d l m } | | d d d g d  t j j |  rt j d |  t SWd | r| j   n  t j j |  rt j |  n  t j j |  r't j |  n  X|  j sDt j d |  n  t S(   s@   Empirically verify whether .pth files are supported in inst. dirs    Checking .pth file support in %ss   .pths   .oksz   
            import os
            f = open({ok_file!r}, 'w')
            f.write('OK')
            f.close()
            s   
R   R   s   pythonw.exes
   python.exei(   t   spawns   -Es   -ct   passi    s-   TEST PASSED: %s appears to support .pth filesNs+   TEST FAILED: %s does NOT support .pth files(    Rh   R
   R   R   R6   R7   R8   t
   _one_linerR   t   dirnamet   makedirsR  R  R  R  t   writeR   R   R  Re   R   t
   executableR   R   R   t   lowert   distutils.spawnR  RF   Rr   R   RH   (   R   R  R   t   ok_filet	   ok_existsR   R  RY   R  t   basenamet   altt   use_altR  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    sX    	

		c         C   s   |  j  ro | j d  ro xS | j d  D]? } | j d |  rH q) n  |  j | | | j d |   q) Wn  |  j |  d S(   s=   Write all the scripts for `dist`, unless scripts are excludedt   scriptss   scripts/N(   Rj   t   metadata_isdirt   metadata_listdirt   install_scriptt   get_metadatat   install_wrapper_scripts(   R   R   t   script_name(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   install_egg_scriptsM  s    c         C   s|   t  j j |  rh xc t  j |  D]? \ } } } x- | D]% } |  j j t  j j | |   q8 Wq" Wn |  j j |  d  S(   N(   R6   R7   R   t   walkR   R   R   (   R   R7   t   baseR   t   filesR   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt
   add_output[  s
    *c         C   s#   |  j  r t d | f   n  d  S(   Nsj   Invalid argument %r: you can't use filenames or URLs with --editable (except via the --find-links option).(   R^   R   (   R   R   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   not_editablec  s    	c         C   sW   |  j  s d  St j j t j j |  j | j   rS t d | j |  j f   n  d  S(   Ns2   %r already exists in %s; can't do a checkout there(   R^   R6   R7   R8   R   Rm   t   keyR   (   R   R   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   check_editablek  s    	'c         C   s  t  j d d  } |  j s( |  j   n  zYt | t  s t |  r |  j |  |  j j	 | |  } |  j
 d  | | | t  St j j |  r |  j |  |  j
 d  | | | t  St |  } n  |  j |  |  j j | | |  j |  j |  j |  j  } | d  k r>d | } |  j r/| d 7} n  t |   nB | j t k rg|  j | | | d  | S|  j
 | | j | |  SWd  t j j |  rt |  n  Xd  S(   NRv   s   easy_install-s+   Could not find suitable distribution for %rs2    (--always-copy skips system and development eggs)t   Using(   t   tempfilet   mkdtempR^   t   install_site_pyR   R"   R   R.  R   t   downloadt   install_itemRe   RF   R6   R7   R8   t   parse_requirement_argR0  t   fetch_distributionRS   Rq   R   R   t
   precedenceR)   t   process_distributiont   locationR   (   R   R   t   depst   tmpdirt   dlR   R   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR-   u  s8    		
	c         C   s  | p |  j  } | p* t j j |  | k } | p@ | j d  } | p| |  j d  k	 o| t j j t |   t |  j  k } | r | r x4 |  j | j	 D] } | j
 | k r Pq q Wt } n  t j d t j j |   | r!|  j | | |  } xP | D] } |  j | | |  qWn, |  j |  g } |  j | | d | d  | d  k	 r}x! | D] } | | k r`| Sq`Wn  d  S(   Ns   .eggs   Processing %si    R1  (   Rq   R6   R7   R  t   endswithR   Re   R   R   t   project_nameR;  RF   R
   R   R  t   install_eggsR:  t   egg_distribution(   R   R   R5  R=  R<  t   install_neededR   t   dists(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR6    s.    	c         C   sU   t  | } xD t D]< } d | } t |  |  d k r t |  | | |  q q Wd S(   s=   Sets the install directories by applying the install schemes.t   install_N(   R   R	   R   Re   R   (   R   R   t   schemeR/  t   attrname(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR     s
    

c         G   s*  |  j  |  |  j j |  | |  j | j k rF |  j j |  n  |  j j |  |  j |  | |  j | j <t j	 |  j
 | | |   | j d  r |  j r |  j j | j d   n  | r |  j r d  S| d  k	 r| j | j k rt j d |  d  S| d  k s#| | k rD| j   } t t |   } n  t j	 d |  y( t g   j | g |  j |  j  } WnI t k
 r} t t |    n% t k
 r} t | j     n X|  j s|  j rx9 | D]. } | j |  j k r|  j | j    qqWn  t j	 d |  d  S(   Ns   dependency_links.txts   Skipping dependencies for %ss   Processing dependencies for %ss'   Finished processing dependencies for %s(   t
   update_pthR   t   addR   R/  t   removeR)  R   R
   R   t   installation_reportt   has_metadataR   R   t   get_metadata_linesRq   Re   R   t   as_requirementR"   t   strR&   t   resolveR-   R'   R   R(   t   reportR   (   R   t   requirementR   R<  R   t   distreqt   distrosR_   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR:    sB    
	c         C   sA   |  j  d  k	 r |  j  S| j d  r* t S| j d  s= t St S(   Ns   not-zip-safes   zip-safe(   Rf   Re   RL  RF   RH   (   R   R   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   should_unzip  s    c         C   s  t  j j |  j | j  } t  j j |  rS d } t j | | j |  j |  | St  j j |  rn | } n t  j j	 |  | k r t  j
 |  n  t  j |  } t |  d k r t  j j | | d  } t  j j |  r | } q n  t |  t j | |  | S(   Ns<   %r already exists in %s; build directory %s will not be kepti   i    (   R6   R7   R   Rm   R/  R8   R
   R   R   R  R   t   listdirR   R   t   shutilt   move(   R   R   t   dist_filenamet
   setup_baset   dstR   t   contents(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt
   maybe_move  s"    	
c         C   s>   |  j  r d  Sx* t j   j |  D] } |  j |   q# Wd  S(   N(   Rj   t   ScriptWritert   bestt   get_argst   write_script(   R   R   Rn   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR'    s    	c         C   sp   t  | j    } t | |  } | rS |  j |  t   } t j |  | } n  |  j | t |  d  d S(   s/   Generate a legacy script wrapper and install itRZ   N(	   RO  RN  t   is_python_scriptt   _load_templateR   R^  t
   get_headerRa  RC   (   R   R   R(  t   script_textt   dev_pathR   t	   is_scriptt   body(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR%    s    c         C   s=   d } |  r! | j  d d  } n  t d |  } | j d  S(   s   
        There are a couple of template scripts in the package. This
        function loads one of them and prepares it for use.
        s   script.tmpls   .tmpls    (dev).tmplR   s   utf-8(   RN   R   t   decode(   Rf  R   t	   raw_bytes(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRc  "  s
    t   tc   	      C   s   |  j  g  | D] } t j j |  j |  ^ q  t j d | |  j  t j j |  j |  } |  j |  t   } |  j	 s t
 |  t j j |  r t j |  n  t | d |   } | j |  Wd QXt | d |  n  d S(   s1   Write an executable file to the scripts directorys   Installing %s script to %sR   Ni  (   R   R6   R7   R   Ri   R
   R   R-  t   current_umaskR   R   R8   R   R  R  t   chmod(	   R   R(  R\  t   modeR   RV   t   targett   maskRY   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRa  1  s    ,		
c         C   s  | j    j d  r( |  j | |  g S| j    j d  rP |  j | |  g S| } t j j |  r | j d  r t | | |  j  n' t j j	 |  r t j j
 |  } n  | j |  r |  j r | d  k	 r |  j | | |  } n  t j j | d  } t j j |  st t j j | d d   } | s[t d t j j
 |    n  t |  d k rt d t j j
 |    n  | d	 } n  |  j rt j |  j | |   g  S|  j | |  Sd  S(
   Ns   .eggs   .exes   .pys   setup.pyR   s"   Couldn't find a setup script in %si   s   Multiple setup scripts in %si    (   R  R?  t   install_eggt   install_exeR6   R7   t   isfileR   t   unpack_progressR   t   abspatht
   startswithRm   Re   R]  R   R8   R    R   R   R^   R
   R   t   report_editablet   build_and_install(   R   R   RY  R=  RZ  t   setup_scriptt   setups(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRA  C  s8    "	c         C   s[   t  j j |  r3 t | t  j j | d   } n t t j |   } t j	 | d | S(   Ns   EGG-INFOt   metadata(
   R6   R7   R   R$   R   R%   t	   zipimportt   zipimporterR#   t   from_filename(   R   t   egg_pathR{  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRB  m  s
    c         C   s%  t  j j |  j t  j j |   } t  j j |  } |  j sL t |  n  |  j |  } t	 | |  st  j j
 |  r t  j j |  r t j | d |  j n2 t  j j |  r |  j t  j | f d |  n  yt } t  j j
 |  r*| j |  rt j d } } qt j d } } ng |  j |  rY|  j |  |  j d } } n8 t } | j |  rt j d } } n t j d } } |  j | | | f | d t  j j |  t  j j |  f  t | d | Wqt k
 rt | d t   qXn  |  j |  |  j |  S(   NR   s	   Removing t   Movingt   Copyingt
   Extractings	    %s to %st   fix_zipimporter_caches(   R6   R7   R   Rh   R  Ru  R   R   RB  R,   R   R   R   t   remove_treeR8   R   R   RH   Rv  RW  RX  t   copytreeRU  t   mkpatht   unpack_and_compileRF   t   copy2R  t   update_dist_cachesR   R-  (   R   R  R=  t   destinationR   t   new_dist_is_zippedRY   RR   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRq  u  sT    		%	
c         C   s  t  |  } | d  k r+ t d |   n  t d  d | j d d  d | j d d  d t   } t j j | | j	   d  } | | _
 | d } t j j | d	  } t j j | d
  } t |  t | |  | _ |  j | |  t j j |  st | d  }	 |	 j d  xU | j d  D]D \ }
 } |
 d k r*|	 j d |
 j d d  j   | f  q*q*W|	 j   n  t j j | d  } |  j g  t j |  D] } t j j | | d  ^ q t j | | d |  j d |  j |  j | |  S(   Ns(   %s is not a valid distutils Windows .exeR@  R{  R   Rc   t   platforms   .eggs   .tmps   EGG-INFOs   PKG-INFOR   s   Metadata-Version: 1.0
t   target_versions   %s: %s
t   _t   -R"  i    R   R   (   R/   Re   R   R#   R	  R   R6   R7   R   t   egg_nameR;  R   R$   t	   _providert
   exe_to_eggR8   R  R  t   itemsRN   t   titleR  R   R^  R`  R   t   make_zipfileR   R   Rq  (   R   RY  R=  t   cfgR   R  t   egg_tmpt	   _egg_infot   pkg_infRY   t   kt   vRi   Rn   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRr    s<    	

03c            s  t  |   g   g   i         f d   } t |   |  g  } x  D] } | j   j d  rV | j d  } | d } t j | d  d | d <t j j	   |  }  j
 |  | j
 |  t j | |  qV qV W|  j   t j t j j	   d  t j   |   x d D] }	 t   |	 r*t j j	   d |	 d	  }
 t j j |
  st |
 d
  } | j d j	 t   |	  d  | j   qq*q*Wd S(   s;   Extract a bdist_wininst to the directories an egg would usec            sL  |  j    } x D]\ } } | j |  r | |  t |  }  |  j d  } t j j   |  } | j    } | j d  s | j d  r t j	 | d  | d <d  t j j
 | d  d < j |   nI | j d  r| d k rd  t j j
 | d  d < j |  n  | Sq W|  j d	  sHt j d
 |   n  d  S(   Nt   /s   .pyds   .dllii   i    s   .pys   SCRIPTS/s   .pths   WARNING: can't process %s(   R  Rv  R   R   R6   R7   R   R?  R   t   strip_modulet   splitextR   R
   R   Re   (   t   srcR[  RB   t   oldt   newt   partsR>  (   R  t   native_libst   prefixest
   to_compilet	   top_level(    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   process  s$    s   .pydR  is   .pys   EGG-INFOR  R  s   .txtR   s   
N(   s	   top_levels   native_libs(   R1   R   R  R?  R   R   R  R6   R7   R   R   t
   write_stubt   byte_compilet   write_safety_flagt   analyze_eggR   R8   R  R  R  (   R   RY  R  R  t   stubst   resR  t   resourcet   pyfileR   t   txtRY   (    (   R  R  R  R  R  sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    s6    
!s(  
        Because this distribution was installed --multi-version, before you can
        import modules from this package in an application, you will need to
        'import pkg_resources' and then use a 'require()' call similar to one of
        these examples, in order to select the desired version:

            pkg_resources.require("%(name)s")  # latest installed version
            pkg_resources.require("%(name)s==%(version)s")  # this exact version
            pkg_resources.require("%(name)s>=%(version)s")  # this version or higher
        s   
        Note also that the installation directory must be on sys.path at runtime for
        this to work.  (e.g. by being the application's script directory, by being on
        PYTHONPATH, or by being added to sys.path by your code.)
        t	   Installedc   	      C   s   d } |  j  r\ |  j r\ | d |  j 7} |  j t t t j  k r\ | d |  j 7} q\ n  | j	 } | j
 } | j } d } | t   S(   s9   Helpful installation message for display to package userss   
%(what)s %(eggloc)s%(extras)ss   
R   (   Rr   Rw   t   _easy_install__mv_warningRh   R   R   R   R7   t   _easy_install__id_warningR;  R@  Rc   R   (	   R   t   reqR   t   whatR   t   egglocR   Rc   t   extras(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRK    s    			sR  
        Extracted editable version of %(spec)s to %(dirname)s

        If it uses setuptools in its setup script, you can activate it in
        "development" mode by going to that directory and running::

            %(python)s setup.py develop

        See the setuptools documentation for the "develop" command for more info.
        c         C   s-   t  j j |  } t j } d |  j t   S(   Ns   
(   R6   R7   R  R   R  t   _easy_install__editable_msgR   (   R   R   Ry  R  t   python(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRw  7  s    	c         C   s  t  j j d t  t  j j d t  t |  } |  j d k ri d |  j d } | j d d |  n" |  j d k  r | j d d  n  |  j r | j d d	  n  t	 j
 d
 | t |  d d j |   y t | |  Wn- t k
 r} t d | j d f   n Xd  S(   Ns   distutils.command.bdist_eggs   distutils.command.egg_infoi   R  i   i    R  s   -qs   -ns   Running %s %st    s   Setup script exited with %s(   R   t   modulest
   setdefaultR   R   R   R   R   R   R
   R   R   R   R   R   R   Rn   (   R   Ry  RZ  Rn   R  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR   <  s     	$c   	      C   s  d d g } t  j d d d t j j |   } z |  j t j j |   | j |  |  j | | |  t | g  } g  } x? | D]7 } x. | | D]" } | j |  j	 | j
 |   q Wq W| r |  j r t j d |  n  | SWd  t |  t j |  j  Xd  S(   NR   s
   --dist-dirRv   s   egg-dist-tmp-t   dirs+   No eggs found in %s (setup script problem?)(   R2  R3  R6   R7   R  t   _set_fetcher_optionsR   R   R!   Rq  R;  R   R
   R   R   R   R   (	   R   Ry  RZ  Rn   t   dist_dirt   all_eggst   eggsR/  R   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRx  P  s$    	$	

c   	      C   s   |  j  j d  j   } d } i  } xF | j   D]8 \ } } | | k rO q1 n  | d | | j d d	  <q1 Wt d |  } t j j | d
  } t	 j
 | |  d S(   s  
        When easy_install is about to run bdist_egg on a source dist, that
        source dist might have 'setup_requires' directives, requiring
        additional fetching. Ensure the fetcher options given to easy_install
        are available to that command as well.
        R-   Rl   R   Rk   Ro   Rt   i   R  R  s	   setup.cfgN(   s
   find_linkss	   site_dirss	   index_urls   optimizes	   site_dirss   allow_hosts(   R   R   t   copyR  RN   t   dictR6   R7   R   R   t   edit_config(	   R   R+  t   ei_optst   fetch_directivest   fetch_optionsR/  R   t   settingst   cfg_filename(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR  h  s    	 c         C   s  |  j  d  k r d  Sx~ |  j  | j D]l } |  j sE | j | j k r$ t j d |  |  j  j |  | j |  j k r |  j j | j  q q$ q$ W|  j s| j |  j  j	 k r t j d |  qt j d |  |  j  j
 |  | j |  j k r|  j j | j  qn  |  j s|  j  j   | j d k rt j j |  j d  } t j j |  rot j |  n  t | d  } | j |  j  j | j  d  | j   qn  d  S(   Ns&   Removing %s from easy-install.pth files4   %s is already the active version in easy-install.pths"   Adding %s to easy-install.pth fileR   s   setuptools.ptht   wts   
(   R   Re   R/  Rr   R;  R
   R   RJ  R   t   pathsRI  R   R   t   saveR6   R7   R   Rh   R   R   R  R  t   make_relativeR  (   R   R   RU   R   RY   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRH    s4    	
	 c         C   s   t  j d | |  | S(   Ns   Unpacking %s to %s(   R
   t   debug(   R   R  R[  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRt    s    c            s   g   g       f d   } t  | | |    j     j s x<  D]1 } t j |  t j d Bd @} t | |  qN Wn  d  S(   Nc            s   | j  d  r/ |  j d  r/  j |  n. | j  d  sM | j  d  r]  j |  n    j |  |    j r} | p d  S(   Ns   .pys	   EGG-INFO/s   .dlls   .so(   R?  Rv  R   Rt  R   Re   (   R  R[  (   R   t   to_chmodR  (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   pf  s    im  i  (   R   R  R   R6   t   statt   ST_MODERm  (   R   R  R  R  RY   Rn  (    (   R   R  R  sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    s    	c         C   s   t  j r |  j d  d  Sd d l m } ze t j |  j d  | | d d d d d |  j |  j	 r | | d |  j	 d d d |  j n  Wd  t j |  j  Xd  S(	   Ns%   byte-compiling is disabled, skipping.i(   R  i   Ro   i    t   forceR   (
   R   t   dont_write_bytecodeR   t   distutils.utilR  R
   R   R   R   Ro   (   R   R  R  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    s    		sw  
        bad install directory or PYTHONPATH

        You are attempting to install a package to a directory that is not
        on PYTHONPATH and which Python does not read ".pth" files from.  The
        installation directory you specified (via --install-dir, --prefix, or
        the distutils default setting) was:

            %s

        and your PYTHONPATH environment variable currently contains:

            %r

        Here are some of your options for correcting the problem:

        * You can choose a different installation directory, i.e., one that is
          on PYTHONPATH or supports .pth files

        * You can add the installation directory to the PYTHONPATH environment
          variable.  (It must then also be on PYTHONPATH whenever you run
          Python and want to use the package(s) you are installing.)

        * You can set up the installation directory to support ".pth" files by
          using one of the approaches described here:

          https://pythonhosted.org/setuptools/easy_install.html#custom-installation-locations

        Please make the appropriate changes for your system and try again.c         C   s)   |  j  } | |  j t j j d d  f S(   NR   R   (   t   _easy_install__no_default_msgRh   R6   R  R	  (   R   t   template(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    s    	c         C   s7  |  j  r d St j j |  j d  } t d d  } | j d  } d } t j j |  r t j	 d |  j  t
 j |   } | j   } Wd QX| j d  s t d	 |   q n  | | k r*t j d
 |  |  j st |  t
 j | d d d  } | j |  Wd QXn  |  j | g  n  t |  _  d S(   s8   Make sure there's a site.py in the target dir, if neededNs   site.pyR   s   site-patch.pys   utf-8R   s   Checking existing site.py in %ss   def __boot():s;   %s is not a setuptools-generated site.py; please remove it.s   Creating %sR   t   encoding(   R   R6   R7   R   Rh   R   Ri  R8   R
   R  t   ioR  t   readRv  R   R   R   R   R  R  RF   (   R   t   sitepyt   sourcet   currentt   strm(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR4    s,    		
c         C   s   |  j  s d St t j j d   } xf t j |  j  D]R \ } } | j |  r8 t j j	 |  r8 |  j
 d |  t j | d  q8 q8 Wd S(   s   Create directories under ~.Nt   ~s   os.makedirs('%s', 0o700)i  (   Rd   R   R6   R7   R   R   t	   iteritemsR   Rv  R   t   debug_printR  (   R   t   homeR   R7   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR     s    	"R   Rh   s/   $base/lib/python$py_version_short/site-packagesRi   s	   $base/bins   $base/Lib/site-packagess   $base/Scriptsc         G   s   |  j  d  j } |  j r | j   } |  j | d <|  j j t j |  j  } xH | j	   D]7 \ } } t
 |  | d   d  k r\ t |  | |  q\ q\ Wn  d d l m } xo | D]g } t
 |  |  } | d  k	 r | | |  } t j d k rt j j |  } n  t |  | |  q q Wd  S(   NR   R+  i(   R   R   (   t   get_finalized_commandR   Rv   R  R   R	  R6   R   t   DEFAULT_SCHEMER  R   Re   R   R  R   R7   R   (   R   R   R   RF  R   R   R   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR   )  s     	N(   s   prefix=Ns   installation prefix(   s   zip-okRQ   s   install package as a zipfile(   s   multi-versionRR   s%   make apps have to require() a version(   s   upgradeRT   s1   force upgrade (searches PyPI for latest versions)(   s   install-dir=RU   s   install package to DIR(   s   script-dir=RB   s   install scripts to DIR(   s   exclude-scriptsRV   s   Don't install scripts(   s   always-copyRW   s'   Copy all needed packages to install dir(   s
   index-url=RX   s    base URL of Python Package Index(   s   find-links=RY   s(   additional URL(s) to search for packages(   s   build-directory=RZ   s/   download/extract/build in DIR; keep the results(   s	   optimize=R[   sl   also compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0](   s   record=Ns3   filename in which to record list of installed files(   s   always-unzipR\   s*   don't install as a zipfile, no matter what(   s
   site-dirs=R]   s)   list of directories where .pth files work(   s   editableR_   s+   Install specified packages in editable form(   s   no-depsR`   s   don't install dependencies(   s   allow-hosts=Ra   s$   pattern(s) that hostnames must match(   s   local-snapshots-okRb   s(   allow building eggs from local checkouts(   s   versionNs"   print version information and exit(   s   no-find-linksNs9   Don't load find-links defined in packages being installed(    (O   t   __name__t
   __module__t   __doc__t   descriptionRF   t   command_consumes_argumentsRe   t   user_optionst   boolean_optionsR   R   R   t   help_msgR   t   negative_optR   R   R   R   R   t   staticmethodR   R   R   R   R   R   R   R   R   R   RK   RL   t   lstripR  R  R  R  R  R)  R-  R.  R0  RH   R-   R6  R   R:  RU  R]  R'  R%  Rc  Ra  RA  RB  Rq  Rr  R  R  R  RK  R  Rw  R   Rx  R  RH  Rt  R  R  R  R  R4  R   R  R   R  R   (    (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR-   v   s        			0				z									+			<				
)$		'				
	*		6	-	5								%					 	
	c          C   sE  g  t  j j d d  j t  j  D] }  |  r" |  ^ q" } t j g } t j t j k rk | j t j  n  x2| D]*} | rr t j	 d k r | j t  j
 j | d d   n| t  j d k r| j t  j
 j | d d	 t j d
  d  t  j
 j | d d  g  n% | j | t  j
 j | d d  g  t j	 d k rd | k rt  j j d  } | rt  j
 j | d d t j d
  d  } | j |  qqqqr qr Wt d  t d  f } x* | D]" } | | k r| j |  qqWt j r| j t j  n  y | j t j    Wn t k
 r+n Xt t t |   } | S(   NR   R   t   os2emxt   riscost   Libs   site-packagesR  t   libR  i   s   site-pythont   darwins   Python.frameworkt   HOMEt   Libraryt   Pythont   purelibt   platlib(   s   os2emxs   riscos(   R6   R  R	  R   R
  R   Rv   R   R   R  R7   R   t   sept   extendRc   R   R   R   R   t   getsitepackagest   AttributeErrorR   R   R   (   t   _ft   sitedirsR  Rv   R  t   home_spt	   lib_pathst   site_lib(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR   @  sV    +"		
		c         c   s^  i  } xQ|  D]I} t  |  } | | k r1 q n  d | | <t j j |  sS q n  t j |  } | | f Vx | D] } | j d  s qt n  | d k r qt n  t t j j | |   } t t	 |   } | j
   xw | D]o } | j d  s t  | j    } | | k rNd | | <t j j |  s4q n  | t j |  f VqNq q Wqt Wq Wd S(   sB   Yield sys.path directories that might contain "old-style" packagesi   s   .pths   easy-install.pths   setuptools.ptht   importN(   s   easy-install.pths   setuptools.pth(   R   R6   R7   R   RV  R?  R  R   R   R   R  Rv  t   rstrip(   t   inputst   seenR  R,  R   RY   t   linest   line(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   expand_paths{  s4    


c         C   s  t  |  d  } z^t j |  } | d k r1 d S| d | d | d } | d k  r[ d S| j | d  t j d | j d   \ } } } | d k r d S| j | d |  i d	 d
 6d	 d 6} t j	 |  } yT | j |  }	 |	 j
 d d  d }
 |
 j t j    }
 | j t j |
   Wn t j k
 rCd SX| j d  sd| j d  rhd S| SWd | j   Xd S(   sn   Extract configuration data from a bdist_wininst .exe

    Returns a configparser.RawConfigParser, or None
    t   rbi	   i   i   i   s   <iiiizV4i{V4R   Rc   R  t    i   i    R{  t   SetupN(   izV4i{V4(   R  t   zipfilet   _EndRecDataRe   t   seekR3   t   unpackR  R   t   RawConfigParserR   Ri  R   t   getfilesystemencodingt   readfpR   t   StringIOt   Errort   has_sectionR  (   RY  RY   t   endrect	   prependedt   tagt   cfglent   bmlent   initR  t   partt   config(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR/     s4    $ c   
      C   s  d d d d d g } t  j |   } zqxj| j   D]\} | j } | j d  } t |  d	 k r | d
 d k r | d j d  r | j d d j | d
   d f  Pq n  t |  d
 k s4 | j d  r q4 n  | j d  r q4 n  | d j	   d k r4 | j
 |  } t j r+| j   } n  xb t |  D]Q } | j   j d d  } | j d  s8| j d | d | f d f  q8q8Wq4 q4 WWd | j   Xg  | D] \ } }	 | j   |	 f ^ q} | j   | j   | S(   s4   Get exe->egg path translations for a given .exe files   PURELIB/R   s   PLATLIB/pywin32_system32s   PLATLIB/s   SCRIPTS/s   EGG-INFO/scripts/s   DATA/lib/site-packagesR  i   i   s   PKG-INFOi   s	   .egg-infoi    s	   EGG-INFO/s   .pths
   -nspkg.ptht   PURELIBt   PLATLIBs   \R  s   %s/%s/N(   s   PURELIB/R   (   s   PLATLIB/pywin32_system32R   (   s   PLATLIB/R   (   s   SCRIPTS/s   EGG-INFO/scripts/(   s   DATA/lib/site-packagesR   (   R  R   (   R  t   ZipFilet   infolistR   R   R   R?  R   R   t   upperR  R   t   PY3Ri  R   RM   RN   Rv  R   R  R  t   sortt   reverse(
   t   exe_filenameR  RQ   R   R   R  R\  t   pthRV   t   y(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR1     s>    		"#"	3+

c         C   s<   y t  j |   SWn$ t k
 r7 t d |  f   n Xd  S(   Ns1   Not a URL, existing file, or requirement spec: %r(   R"   t   parseR   R   (   R   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR7    s
    c           B   s\   e  Z d  Z e Z d d  Z d   Z d   Z e d    Z	 d   Z
 d   Z d   Z RS(	   s)   A .pth file with Distribution paths in itc         C   s   | |  _  t t t |   |  _ t t j j |  j    |  _ |  j	   t
 j |  g  d  d   x6 t |  j  D]% } t t |  j t | t    qo Wd  S(   N(   R   R   R   R   R  R6   R7   R  t   basedirt   _loadR!   t   __init__Re   R   R  RI  R    RF   (   R   R   R  R7   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR-    s    	
c         C   s  g  |  _  t } t j |  j  } t j j |  j  r3t	 |  j d  } x | D] } | j
 d  rp t } qO n  | j   } |  j  j |  | j   sO | j   j
 d  r qO n  t t j j |  j |   } |  j  d <t j j |  s | | k r|  j  j   t |  _ qO n  d | | <qO W| j   n  |  j  rO| rOt |  _ n  x. |  j  r|  j  d j   r|  j  j   qRWd  S(   Nt   rtR  t   #ii   (   R  RH   R  t   fromkeysR  R6   R7   Rs  R   R  Rv  RF   R  R   RM   R   R   R+  R8   t   popt   dirtyR  (   R   t
   saw_importR  RY   R  R7   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR,    s2    	"&	 c         C   s   |  j  s d St t |  j |  j   } | r t j d |  j  |  j |  } d j	 |  d } t
 j j |  j  r t
 j |  j  n  t |  j d   } | j |  Wd QXn; t
 j j |  j  r t j d |  j  t
 j |  j  n  t |  _  d S(   s$   Write changed .pth file back to diskNs	   Saving %ss   
R  s   Deleting empty %s(   R2  R   R   R  R  R
   R  R   t   _wrap_linesR   R6   R7   R   R   R  R  R8   RH   (   R   t	   rel_pathsR  t   dataRY   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR  *  s    	c         C   s   |  S(   N(    (   R  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR4  @  s    c         C   sr   | j  |  j k o6 | j  |  j k p6 | j  t j   k } | r^ |  j j | j   t |  _ n  t j	 |  |  d S(   s"   Add `dist` to the distribution mapN(
   R;  R  R  R6   t   getcwdR   RF   R2  R!   RI  (   R   R   t   new_path(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRI  D  s    c         C   sI   x2 | j  |  j k r4 |  j j | j   t |  _ q Wt j |  |  d S(   s'   Remove `dist` from the distribution mapN(   R;  R  RJ  RF   R2  R!   (   R   R   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRJ  R  s    c         C   s   t  j j t |   \ } } t |  j  } | g } t  j d k rK d pQ t  j } xu t |  | k r | |  j k r | j t  j	  | j
   | j |  St  j j |  \ } } | j |  qW W| Sd  S(   NR  (   R6   R7   R   R   R   R+  t   altsepR  R   t   curdirR&  R   (   R   R7   t   npatht   lastt   baselenR  R  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR  Y  s    	
(    (   R  R  R  RH   R2  R-  R,  R  R  R4  RI  RJ  R  (    (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR.     s   					t   RewritePthDistributionsc           B   s/   e  Z e d     Z e d  Z e d  Z RS(   c         c   s*   |  j  Vx | D] } | Vq W|  j Vd  S(   N(   t   preludet   postlude(   t   clsR  R  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR4  k  s    	s?   
        import sys
        sys.__plen = len(sys.path)
        s   
        import sys
        new = sys.path[sys.__plen:]
        del sys.path[sys.__plen:]
        p = getattr(sys, '__egginsert', 0)
        sys.path[p:p] = new
        sys.__egginsert = p + len(new)
        (   R  R  t   classmethodR4  R  R?  R@  (    (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR>  i  s
   	t   SETUPTOOLS_SYS_PATH_TECHNIQUEt   rawt   rewritec           C   s,   t  t j t  r t St j t j j    S(   s_   
    Return a regular expression based on first_line_re suitable for matching
    strings.
    (   R   R   t   patternRO  t   ret   compileRi  (    (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   _first_line_re  s    c         C   s}   |  t  j k r8 t  j d k r8 t | t j  |  |  St j   \ } } } t j	 | | d | d d |  | f f  d  S(   NR   i    i   s    %s %s(
   R6   RJ  R   Rm  R  t   S_IWRITER   R  R   t   reraise(   t   funct   argt   exct   ett   evR  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt
   auto_chmod  s
    
c         C   s=   t  |   } t | t j  | r/ t |  n
 t |  d S(   sa
  
    Fix any globally cached `dist_path` related data

    `dist_path` should be a path of a newly installed egg distribution (zipped
    or unzipped).

    sys.path_importer_cache contains finder objects that have been cached when
    importing data from the original distribution. Any such finders need to be
    cleared since the replacement distribution might be packaged differently,
    e.g. a zipped egg distribution might get replaced with an unzipped egg
    folder or vice versa. Having the old finders cached may then cause Python
    to attempt loading modules from the replacement distribution using an
    incorrect loader.

    zipimport.zipimporter objects are Python loaders charged with importing
    data packaged inside zip archives. If stale loaders referencing the
    original distribution, are left behind, they can fail to load modules from
    the replacement distribution. E.g. if an old zipimport.zipimporter instance
    is used to load data from a new zipped egg archive, it may cause the
    operation to attempt to locate the requested data in the wrong location -
    one indicated by the original distribution's zip archive directory
    information. Such an operation may then fail outright, e.g. report having
    read a 'bad local file header', or even worse, it may fail silently &
    return invalid data.

    zipimport._zip_directory_cache contains cached zip archive directory
    information for all existing zipimport.zipimporter instances and all such
    instances connected to the same archive share the same cached directory
    information.

    If asked, and the underlying Python implementation allows it, we can fix
    all existing zipimport.zipimporter instances instead of having to track
    them down and remove them one by one, by updating their shared cached zip
    archive directory information. This, of course, assumes that the
    replacement distribution is packaged as a zipped egg.

    If not asked to fix existing zipimport.zipimporter instances, we still do
    our best to clear any remaining zipimport.zipimporter related cached data
    that might somehow later get used when attempting to load data from the new
    distribution and thus cause such load operations to fail. Note that when
    tracking down such remaining stale data, we can not catch every conceivable
    usage from here, and we clear only those that we know of and have found to
    cause problems if left alive. Any remaining caches should be updated by
    whomever is in charge of maintaining them, i.e. they should be ready to
    handle us replacing their zip archives with new distributions at runtime.

    N(   R   t   _uncacheR   t   path_importer_cachet!   _replace_zip_directory_cache_datat*   _remove_and_clear_zip_directory_cache_data(   t	   dist_pathR  t   normalized_path(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    s
    <c         C   sr   g  } t  |   } xY | D]Q } t |  } | j |   r | | | d !t j d f k r | j |  q q W| S(   sp  
    Return zipimporter cache entry keys related to a given normalized path.

    Alternative path spellings (e.g. those using different character case or
    those using alternative path separators) related to the same path are
    included. Any sub-path entries are included as well, i.e. those
    corresponding to zip archives embedded in other zip archives.

    i   R   (   R   R   Rv  R6   R  R   (   RW  t   cachet   resultt
   prefix_lent   pt   np(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt"   _collect_zipimporter_cache_entries  s    
 c         C   s]   xV t  |  |  D]E } | | } | | =| o9 | | |  } | d k	 r | | | <q q Wd S(   s  
    Update zipimporter cache data for a given normalized path.

    Any sub-path entries are processed as well, i.e. those corresponding to zip
    archives embedded in other zip archives.

    Given updater is a callable taking a cache entry key and the original entry
    (after already removing the entry from the cache), and expected to update
    the entry and possibly return a new one to be inserted in its place.
    Returning None indicates that the entry should not be replaced with a new
    one. If no updater is given, the cache entries are simply removed without
    any additional processing, the same as if the updater simply returned None.

    N(   R]  Re   (   RW  RX  t   updaterR[  t	   old_entryt	   new_entry(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   _update_zipimporter_cache  s    

c         C   s   t  |  |  d  S(   N(   Ra  (   RW  RX  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRR    s    c         C   s#   d   } t  |  t j d | d  S(   Nc         S   s   | j    d  S(   N(   t   clear(   R7   R_  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt2   clear_and_remove_cached_zip_archive_directory_data#  s    R^  (   Ra  R|  t   _zip_directory_cache(   RW  Rc  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRU  "  s    	t   __pypy__c         C   s#   d   } t  |  t j d | d  S(   Nc         S   s/   | j    t j |   | j t j |   | S(   N(   Rb  R|  R}  t   updateRd  (   R7   R_  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt)   replace_cached_zip_archive_directory_data8  s    
R^  (   Ra  R|  Rd  (   RW  Rg  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRT  7  s    	s   <string>c         C   s7   y t  |  | d  Wn t t f k
 r. t SXt Sd S(   s%   Is this string a valid Python script?t   execN(   RH  t   SyntaxErrort	   TypeErrorRH   RF   (   RO   R   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt	   is_pythonJ  s
    c         C   sV   y1 t  j |  d d  } | j d  } Wd QXWn t t f k
 rK |  SX| d k S(   sC   Determine if the specified executable is a .sh (contains a #! line)R  s   latin-1i   Ns   #!(   R  R  R  R  R  (   R  t   fpt   magic(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   is_shT  s    c         C   s   t  j |  g  S(   s@   Quote a command line argument according to Windows parsing rules(   t
   subprocesst   list2cmdline(   RM  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   nt_quote_arg^  s    c         C   sb   | j  d  s | j  d  r" t St |  |  r5 t S|  j d  r^ d |  j   d j   k St S(   sM   Is this text, as a whole, a Python script? (as opposed to shell/bat/etc.
    s   .pys   .pyws   #!R  i    (   R?  RF   Rk  Rv  t
   splitlinesR  RH   (   Re  R   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRb  c  s    (   Rm  c          G   s   d  S(   N(    (   Rn   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   _chmodu  s    c         C   sQ   t  j d |  |  y t |  |  Wn& t j k
 rL } t  j d |  n Xd  S(   Ns   changing mode of %s to %os   chmod failed: %s(   R
   R  Rs  R6   t   error(   R7   Rn  R_   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRm  y  s
    t   CommandSpecc           B   s   e  Z d  Z g  Z e   Z e d    Z e d    Z e d    Z	 e d    Z
 e d    Z d   Z e d    Z d   Z e d	    Z e d
    Z RS(   sm   
    A command spec for a #! header, specified as a list of arguments akin to
    those passed to Popen.
    c         C   s   |  S(   sV   
        Choose the best CommandSpec class based on environmental conditions.
        (    (   RA  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR_    s    c         C   s(   t  j j t j  } t  j j d |  S(   Nt   __PYVENV_LAUNCHER__(   R6   R7   R:   R   R  R  R	  (   RA  t   _default(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   _sys_executable  s    c         C   sO   t  | |   r | St  | t  r, |  |  S| d k rB |  j   S|  j |  S(   sg   
        Construct a CommandSpec from a parameter to build_scripts, which may
        be None.
        N(   R   R   Re   t   from_environmentt   from_string(   RA  t   param(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt
   from_param  s    

c         C   s   |  |  j    g  S(   N(   Rx  (   RA  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRy    s    c         C   s   t  j | |  j  } |  |  S(   s}   
        Construct a command spec from a simple string representing a command
        line parseable by shlex.split.
        (   t   shlexR   t
   split_args(   RA  t   stringR  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRz    s    c         C   sM   t  j |  j |   |  _ t j |   } t |  sI d g |  j d *n  d  S(   Ns   -xi    (   R}  R   t   _extract_optionst   optionsRo  Rp  RI   (   R   Re  t   cmdline(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   install_options  s    c         C   sQ   |  d j    d } t   j |  } | rA | j d  pD d n d } | j   S(   sH   
        Extract any options from the first line of the script.
        s   
i    i   R   (   Rr  RI  t   matcht   groupRM   (   t   orig_scriptt   firstR  R  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    s    !c         C   s   |  j  |  t |  j   S(   N(   t   _renderR   R  (   R   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt	   as_header  s    c         C   sD   d } x7 | D]/ } |  j  |  r |  j |  r |  d d !Sq W|  S(   Ns   "'i   i(   Rv  R?  (   t   itemt   _QUOTESt   q(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   _strip_quotes  s
    c         C   s%   t  j d   |  D  } d | d S(   Nc         s   s$   |  ] } t  j | j    Vq d  S(   N(   Ru  R  RM   (   R   R  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pys	   <genexpr>  s    s   #!s   
(   Ro  Rp  (   R  R  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    s    (   R  R  R  R  R  R~  RB  R_  Rx  R|  Ry  Rz  R  R  R  R  R  R  (    (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRu    s   			
	t   WindowsCommandSpecc           B   s   e  Z e d  e  Z RS(   R   (   R  R  R  RH   R~  (    (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    s   R^  c           B   s   e  Z d  Z e j d  j   Z e Z e	 d e d   Z e	 d e d   Z e	 d d   Z e d    Z e	 d    Z e	 d    Z e	 d    Z e	 d	 d d
   Z RS(   s`   
    Encapsulates behavior around writing entry point scripts for console and
    gui apps.
    s6  
        # EASY-INSTALL-ENTRY-SCRIPT: %(spec)r,%(group)r,%(name)r
        __requires__ = %(spec)r
        import sys
        from pkg_resources import load_entry_point

        if __name__ == '__main__':
            sys.exit(
                load_entry_point(%(spec)r, %(group)r, %(name)r)()
            )
    c         C   sM   t  j d t  | r t n t j   } |  j d | |  } | j | |  S(   Ns   Use get_argsR   (   t   warningsR   t   DeprecationWarningt   WindowsScriptWriterR^  R_  t   get_script_headerR`  (   RA  R   R  t   wininstt   writert   header(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   get_script_args  s    c         C   sN   t  j d t  | r d } n  |  j j   j |  } | j |  | j   S(   Ns   Use get_headers
   python.exe(   R  R   R  t   command_spec_classR_  R|  R  R  (   RA  Re  R  R  t   cmd(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    s    	c         c   s   | d k r |  j   } n  t | j    } x d D] } | d } xn | j |  j   D]W \ } } |  j |  |  j t   } |  j	 | | | |  }	 x |	 D] }
 |
 Vq WqZ Wq4 Wd S(   s   
        Yield write_script() argument tuples for a distribution's
        console_scripts and gui_scripts entry points.
        t   consolet   guit   _scriptsN(   s   consoles   gui(
   Re   Rd  RO  RN  t   get_entry_mapR  t   _ensure_safe_nameR  R   t   _get_script_args(   RA  R   R  R   t   type_R  R   t   epRe  Rn   R  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR`    s    
"c         C   s+   t  j d |   } | r' t d   n  d S(   s?   
        Prevent paths in *_scripts entry point names.
        s   [\\/]s+   Path separators not allowed in script namesN(   RG  t   searchR   (   R   t   has_path_sep(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    s    c         C   s*   t  j d t  | r  t j   S|  j   S(   Ns   Use best(   R  R   R  R  R_  (   RA  t   force_windows(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt
   get_writer  s    c         C   s?   t  j d k s- t j d k r7 t j d k r7 t j   S|  Sd S(   sD   
        Select the best ScriptWriter for this environment.
        t   win32t   javaR   N(   R   R  R6   R   t   _nameR  R_  (   RA  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR_  #  s    -
c         c   s   | | | f Vd  S(   N(    (   RA  R  R   R  Re  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR  -  s    R   c         C   s/   |  j  j   j |  } | j |  | j   S(   s;   Create a #! line, getting options (if any) from script_text(   R  R_  R|  R  R  (   RA  Re  R  R  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRd  2  s    N(   R  R  R  RK   RL   R  R  Ru  R  RB  Re   RH   R  R  R`  R  R  R  R_  R  Rd  (    (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR^    s    
		
R  c           B   sY   e  Z e Z e d     Z e d    Z e d    Z e d    Z e	 d    Z
 RS(   c         C   s   t  j d t  |  j   S(   Ns   Use best(   R  R   R  R_  (   RA  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR  =  s    c         C   s2   t  d t d |   } t j j d d  } | | S(   sC   
        Select the best ScriptWriter suitable for Windows
        R  t   naturalt   SETUPTOOLS_LAUNCHER(   R  t   WindowsExecutableLauncherWriterR6   R  R	  (   RA  t   writer_lookupt   launcher(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR_  C  s
    	c   
      c   s   t  d d d d  | } | t j d j   j d  k r` d j t     } t j | t	  n  d d d	 d
 d d d g } | j
 |  |  j | |  } g  | D] } | | ^ q }	 | | | | d |	 f Vd S(   s    For Windows, add a .py extensionR  s   .pyaR  s   .pywt   PATHEXTt   ;sK   {ext} not listed in PATHEXT; scripts will not be recognized as executables.s   .pys
   -script.pys   .pycs   .pyos   .exeRk  N(   R  R6   R  R  R   R   R   R  R   t   UserWarningRJ  t   _adjust_header(
   RA  R  R   R  Re  t   extR   R  RV   R   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR  P  s    "c         C   su   d } d } | d k r( | | } } n  t  j t  j |  t  j  } | j d | d |  } |  j |  rq | S| S(   s   
        Make sure 'pythonw' is used for gui and and 'python' is used for
        console (regardless of what sys.executable is).
        s   pythonw.exes
   python.exeR  R  t   repl(   RG  RH  t   escapet
   IGNORECASEt   subt   _use_header(   RA  R  t   orig_headerRF  R  t
   pattern_obt
   new_header(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR  `  s    c         C   s/   |  d d !j  d  } t j d k p. t |  S(   s   
        Should _adjust_header use the replaced header?

        On non-windows systems, always use. On
        Windows systems, only use the replaced header if it resolves
        to an executable on the system.
        i   it   "R  (   RM   R   R  R   (   R  t   clean_header(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR  n  s    	(   R  R  R  R  RB  R  R_  R  R  R  R  (    (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR  :  s   R  c           B   s   e  Z e d     Z RS(   c         c   s   | d k r$ d } d } d g } n d } d } d d d g } |  j  | |  } g  | D] }	 | |	 ^ qX }
 | | | | d	 |
 f V| d
 t |  d f Vt   s | d } | t |  d	 f Vn  d S(   sG   
        For Windows, add a .py extension and an .exe launcher
        R  s   -script.pyws   .pywt   clis
   -script.pys   .pys   .pycs   .pyoRk  s   .exeRZ   s   .exe.manifestN(   R  t   get_win_launcherR5   t   load_launcher_manifest(   RA  R  R   R  Re  t   launcher_typeR  R  t   hdrRV   R   t   m_name(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR  }  s    	
(   R  R  RB  R  (    (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR  {  s   c         C   sG   d |  } t    r( | j d d  } n | j d d  } t d |  S(   s   
    Load the Windows launcher (executable) suitable for launching a script.

    `type` should be either 'cli' or 'gui'

    Returns the executable as a byte string.
    s   %s.exet   .s   -64.s   -32.R   (   R5   RN   R   (   t   typet   launcher_fn(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    s
    
	c         C   s>   t  j t d  } t j r& | t   S| j d  t   Sd  S(   Ns   launcher manifest.xmls   utf-8(   t   pkg_resourcesR   R  R   t   PY2t   varsRi  (   R   t   manifest(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    s    	c         C   st  | r d   } n | d k r* d   } n  g  } y t j |   } Wn- t j k
 rr | t j |  t j    n Xx | D] } t j j |  |  } y t j |  j	 } Wn t j k
 r d } n Xt
 j |  r t | | |  qz y t j |  Wqz t j k
 r*| t j | t j    qz Xqz Wy t j |   Wn- t j k
 ro| t j |  t j    n Xd S(   s   Recursively delete a directory tree.

    This code is taken from the Python 2.4 version of 'shutil', because
    the 2.3 version doesn't really work right.
    c          W   s   d  S(   N(    (   Rn   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   onerror  s    c          W   s     d  S(   N(    (   Rn   (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    s    i    N(   Re   R6   RV  Rt  R   R  R7   R   t   lstatt   st_modeR  t   S_ISDIRR   RJ  t   rmdir(   R7   t   ignore_errorsR  t   namesR   t   fullnameRn  (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR     s2    
!c          C   s    t  j d  }  t  j |   |  S(   Ni   (   R6   t   umask(   t   tmp(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyRl    s    c          C   sM   d d  l  }  t j j |  j d  } | t j d <t j j |  t   d  S(   Nii    (	   R   R6   R7   R  t   __path__R   t   argvR   R0   (   R   t   argv0(    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt	   bootstrap  s
    c            s   d d l  m } d d l m   d   f   f d     Y} |  d  k rX t j d }  n  t   ; | d d d	 d
 g |  d t j d p d	 d | |  Wd  QXd  S(   Ni(   t   setup(   R#   t   DistributionWithoutHelpCommandsc              s   e  Z d  Z   f d   Z RS(   R   c            s'   t       j |  | |  Wd  QXd  S(   N(   t   _patch_usaget
   _show_help(   R   Rn   t   kw(   R#   (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    s    
(   R  R  t   common_usageR  (    (   R#   (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR    s   i   t   script_argss   -qR-   s   -vR(  i    t	   distclass(   R   R  t   setuptools.distR#   Re   R   R  R  (   R  R  R  R  (    (   R#   sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR0     s    
c          #   se   d d  l  }  t j d  j       f d   } |  j j } | |  j _ z	 d  VWd  | |  j _ Xd  S(   Nise   
        usage: %(script)s [options] requirement_or_url ...
           or: %(script)s --help
        c            s     t  d t j j |    S(   Nt   script(   R  R6   R7   R  (   R(  (   t   USAGE(    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt	   gen_usage	  s    	(   t   distutils.coreRK   RL   R  t   coreR  (   R   R  t   saved(    (   R  sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyR  	  s    	(   R  R    R  R   R   R   t   distutils.errorsR   R   R   R   t   distutils.command.installR   R	   R   R
   R   t   distutils.command.build_scriptsR   R  R   R   R6   R|  RW  R2  R  RG  R  R   RK   R  R   R3   t
   contextlibRo  R}  R  t   setuptools.externR   t   setuptools.extern.six.movesR   R   R   R   t   setuptools.sandboxR   t   setuptools.py31compatR   R   t   setuptools.commandR   t   setuptools.archive_utilR   t   setuptools.package_indexR   R   R   R   R  R   R   R   R   R   R    R!   R"   R#   R$   R%   R&   R'   R(   R)   t   filterwarningst   PEP440Warningt   __all__R5   R,   R  RC   RI   R  R-   R   R	  R/   R1   R7  R.   R>  R  R	  RI  RQ  R  R]  Re   Ra  RR  RU  t   builtin_module_namesRT  Rk  Rn  Rq  Rb  Rm  Rs  t   ImportErrorR   Ru  Rx  t   sys_executableR  t   objectR^  R  R  R  R  R  R  RH   R   Rl  R  R0   t   contextmanagerR  (    (    (    sC   /tmp/pip-build-Q3rTTP/setuptools/setuptools/command/easy_install.pyt   <module>   s   "d							    	;	)	)	'		l				R	 				
	
			T^A!				$		
