
&>Oc           @   s  d  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 m Z d d l m Z d d l m Z 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$ 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/ m0 Z0 m1 Z1 m2 Z2 m3 Z3 m4 Z4 m5 Z5 m6 Z6 m7 Z7 m8 Z8 m9 Z9 m: Z: e j; j< e j=  Z> d d d d d d g Z? d d l@ Z@ e jA d k  o+e@ jB ZC d   ZD e jE d f k r^d   ZF d   ZG n d   ZF d   ZG d e f d     YZH d   ZI d    ZJ d!   ZK d"   ZL d#   ZM d e2 f d$     YZN e> eO d%  ZP d&   ZQ d'   ZR d(   ZS d) d*  ZT d+   ZU d,   ZV d-   ZW y d d. l mX ZY Wn eZ k
 rJd/   ZY n Xd0   ZX d1   Z[ e> eO d2  Z\ eO eQ d3  Z] d4   Z^ e_ d5  Z` d S(6   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`__.

__ http://packages.python.org/distribute/easy_install.html

iN(   t   glob(   t   Commandt   _dont_write_bytecode(   t	   run_setup(   t   logt   dir_util(   t   get_platform(   t   convert_patht
   subst_vars(   t   get_python_libt   get_config_vars(   t   DistutilsArgErrort   DistutilsOptionErrort   DistutilsErrort   DistutilsPlatformError(   t   INSTALL_SCHEMESt   SCHEME_KEYS(   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   samefilet   easy_installt   PthDistributionst   extract_wininst_cfgt   maint   get_exe_prefixess   2.6c         C   s   t  t j d  rI t j j |   rI t j j |  rI t j j |  |  St j j t j j |    t j j t j j |   k S(   NR%   (   t   hasattrt   ost   patht   existsR%   t   normpatht   normcase(   t   p1t   p2(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR%   -   s
    $i   c         C   s   |  S(   N(    (   t   s(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt	   _to_ascii8   s    c         C   s.   y t  |  d  t SWn t k
 r) t SXd  S(   Nt   ascii(   t   unicodet   Truet   UnicodeErrort   False(   R3   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   isascii:   s
    c         C   s   |  j  d  S(   NR5   (   t   encode(   R3   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR4   A   s    c         C   s.   y |  j  d  t SWn t k
 r) t SXd  S(   NR5   (   R;   R7   R8   R9   (   R3   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR:   C   s
    c           B   s+  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 d d d d g Z d d d d
 d d d" d1 d4 d: d= dA g Z e	 r e j
 dF d dG e j f  e j
 dF  n  i d d+ 6Z e Z dH   Z dI   Z dJ   Z dK   Z dL   Z dM   Z dN   Z dO   Z dP   Z dQ   Z dR   Z dS   Z dT   Z dU   Z dV   Z dW   Z e  dX  Z! e  dY  Z" dZ   Z# e d[  Z$ d\   Z% d]   Z& d^   Z' d d_  Z( d` d da  Z) db   Z* dc   Z+ dd   Z, de   Z- df   Z. dg   Z/ dh   Z0 di dj  Z1 dk   Z2 dl   Z3 dm   Z4 dn   Z5 do   Z6 dp   Z7 dq   Z8 dr   Z9 ds   Z: dt   Z; e< j= du  d k sdy e< j> k rdz Z? n d{ Z? e@ d| e@ d} d~ d d  d e@ d} d e? d d  d e@ d} d e? d d  d e@ d} d e? d d   ZA e@ d} d d d  ZB d   ZC 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=R3   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   delete-conflictingt   Ds    no longer needed; don't use thiss   ignore-conflicts-at-my-risks   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   install-layout=s1   installation layout to choose (known values: deb)s"   force-installation-into-system-dirt   0s   force installation into /usrs   no-find-linkss9   Don't load find-links defined in packages being installedt   users!   install in user site-package '%s'c         C   s  t  r0 t j j t  } | j t j  |  _ n	 d |  _ d  |  _
 |  _ d  |  _ |  _ |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ |  _ d  |  _ |  _ |  _ d  |  _ |  _ |  _ d  |  _ |  _ |  _ d  |  _ d  |  _ d  |  _  d  |  _! d  |  _" d  |  _# d  |  _$ d  |  _% d  |  _& t  rKt j' |  _( t j |  _) n d  |  _( d  |  _) d  |  _* d  |  _+ d  |  _, |  _- d  |  _. d  |  _/ d  |  _0 i  |  _1 t2 |  _3 d  |  _4 d  |  _5 d  |  _6 |  j7 j8 |  _8 |  j7 j9 |  |  j7 j: d   d  S(   Ni    R&   (;   t   HAS_USER_SITER,   R-   t   abspatht   __file__t
   startswitht   sitet	   USER_SITERQ   t   Nonet   zip_okt   local_snapshots_okt   install_dirt
   script_dirt   exclude_scriptst	   index_urlt
   find_linkst   build_directoryt   argst   optimizet   recordR>   t   always_copyt   multi_versionRJ   t   no_depst   allow_hostst   roott   prefixt	   no_reportRO   t   install_purelibt   install_platlibt   install_headerst   install_libt   install_scriptst   install_datat   install_baset   install_platbaset	   USER_BASEt   install_userbaset   install_usersitet   no_find_linkst   package_indext   pth_filet   always_copy_fromt   delete_conflictingt   ignore_conflicts_at_my_riskt	   site_dirst   installed_projectsR9   t   sitepy_installedt   install_layoutt"   force_installation_into_system_dirt   _dry_runt   distributiont   verboset   _set_command_optionst   get_option_dict(   t   selft   whereami(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   initialize_options   sT    																											c         C   s   x | D] } t  j j |  s1 t  j j |  r t j d |  |  j s t  j j |  r| t  j j |  r| t |  q t  j	 |  q q q Wd  S(   Ns   Deleting %s(
   R,   R-   R.   t   islinkR   t   infot   dry_runt   isdirt   rmtreet   unlink(   R   t   blockerst   filename(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   delete_blockers   s    $	%c   
   
   C   s  |  j  r( d t d  j  GHt j   n  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 r	|  j |  j d <|  j |  j d <n  |  j rt r|  j   |  j d  k r@t d   n  |  j |  _ |  _ t j d k rr|  j d  q|  j t j d  n  |  j   |  j   |  j r|  j j   d0 k rt d   qn  |  j d d d d  |  j d  k r|  j |  _ n  |  j  d  k rt! |  _  n  |  j" d d1  |  j" d d2  |  j ri|  j# ri|  j# |  _ |  j$ |  _ n  |  j% d  k r|  j& rt d!   n  |  j" d" d3  t' t( t j)  } t*   |  _+ |  j, d  k	 ryg  |  j, j d$  D] } t j) j- | j.    ^ q} xq | D]f } t j) j/ |  s7t0 j1 d% |  qt( |  | k r\t | d&   q|  j+ j2 t( |   qWn  |  j3 s|  j4   n  |  j5 pd' |  _5 |  j+ |  _6 xE |  j t( |  j  f D]+ } | |  j6 k r|  j6 j7 d |  qqW|  j8 d  k	 r3g  |  j8 j d$  D] } | j.   ^ q}	 n	 d( g }	 |  j9 d  k rr|  j: |  j5 d) |  j6 d* |	 |  _9 n  t; |  j6 t j)  |  _< |  j= d  k	 rt> |  j= t?  r|  j= j   |  _= qn	 g  |  _= |  j@ r|  j9 jA |  j6 t j)  n  |  j  s|  j9 jB |  j=  n  |  j" d d4  t> |  jC tD  sy> tD |  jC  |  _C d |  jC k ocd k n sqtE  n  WqtE k
 rt d,   qXn  |  jF r|  jG rt d-   n  |  j3 r|  jH rtI d.   n  |  jJ stI d/   n  g  |  _K d  S(5   Ns   distribute %st
   distributei    Ri   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   usersites$   User base directory is not specifiedt   posixt	   unix_usert   _usert   debs"   unknown value for --install-layoutR[   R\   R`   R|   Rn   Ro   s   /usrs   installation into /usr

Trying to install into the system managed parts of the file system. Please
consider to install to another location, or use the option
--force-installation-into-system-dir to overwrite this warning.
t   installRc   t   ,s"   %s (in --site-dirs) does not exists$    (in --site-dirs) is not on sys.paths   http://pypi.python.org/simplet   *t   search_patht   hostsRb   s   --optimize must be 0, 1, or 2sV   Can't use both --delete-conflicting and --ignore-conflicts-at-my-risk at the same times9   Must specify a build directory (-b) when using --editables:   No urls, filenames, or requirements specified (see --help)(   R   (   s   install_dirs   install_dir(   s   install_dirs
   script_dir(   s   records   record(   s   optimizes   optimize(L   RO   R   t   syst   exitt   splitR
   R   t   get_namet   get_versiont   get_fullnamet   getattrt   config_varsRR   Rt   Ru   RQ   t   create_home_pathRX   R   Rq   Rr   R,   t   namet   select_schemet   expand_basedirst   expand_dirsR   t   lowerR   t   _expandR\   R[   Rv   R9   t   set_undefined_optionsRk   Ro   Ri   R   t   mapR   R-   t   get_site_dirst   all_site_dirsR|   t
   expandusert   stripR   R   t   warnt   appendRJ   t   check_site_dirR^   t   shadow_patht   insertRg   Rw   t   create_indexR   t   local_indexR_   t
   isinstancet
   basestringRZ   t   scan_egg_linkst   add_find_linksRb   t   intt
   ValueErrorRz   R{   R`   R   Ra   t   outputs(
   R   R   Ri   R   R/   R3   R|   R@   t	   path_itemR   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   finalize_options   s    	


			7	 .	!			 	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   RX   R,   R   R-   R   R   R   t   setattr(   R   t   attrst   attrt   val(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   _expand_attrsS  s    c         C   s   |  j  d d d g  d S(   sN   Calls `os.path.expanduser` on install_base, install_platbase and
        root.Rq   Rr   Rh   N(   R   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR   \  s    c         C   s#   |  j  d d d d d d g  d S(   s+   Calls `os.path.expanduser` on install dirs.Rk   Rl   Rn   Rm   Ro   Rp   N(   R   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR   a  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_verbosityRa   R&   Rf   Rc   R   Rh   t   lent   xranget	   distutilsR   t   executet
   write_filet   warn_deprecated_options(   R   t   specR   t   root_lent   counterR   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   rung  s$    			c         C   sI   y t  j   } Wn 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(	   R,   t   getpidt   randomt   randintR   t   maxintR-   t   joinR[   (   R   t   pid(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   pseudo_tempname}  s
    c         C   s&   |  j  s |  j r" t j d  n  d  S(   Nsw   Note: The -D, --delete-conflicting and --ignore-conflicts-at-my-risk no longer have any purpose and should not be used.(   Rz   R{   R   R   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR     s    c         C   s  t  |  j  } t j j | d  } | |  j k } | sH |  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 r't | |  j  |  _ q'n	 d |  _ t j j d d  j t j  } | t t  t d |   k rr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   R[   R,   R-   R   R   t   check_pth_processingR   R.   R   t   opent   closet   OSErrort   IOErrort   cant_write_to_targetRe   R   t   no_default_version_msgRx   RX   R'   t   environt   getR   t   pathsepR   t   filterR7   R~   (   R   t   instdirRx   t   is_site_dirt   testfilet   test_existsR   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR     s6     	!	c         C   sY   d t  j   d |  j f } t j j |  j  s? | d 7} n
 | d 7} t |   d  S(   Ns  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
i   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).
sM  
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:

  http://packages.python.org/distribute/easy_install.html

Please make the appropriate changes for your system and try again.
(   R   t   exc_infoR[   R,   R-   R.   R   (   R   t   msg(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR     s    
c         C   s-  |  j  } t j d |  |  j   d } | d } t j j |  } y] | r^ t j |  n  t j j |  } t j j |  s t j	 |  n  t
 | d  } Wn! t t f k
 r |  j   nHXz | j d | f  | j   d } t j } t j d k rbt j j |  \ } } t j j | d  }	 | j   d k rbt j j |	  rb|	 } qb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 s)t j d |  n  t S(   s@   Empirically verify whether .pth files are supported in inst. dirs    Checking .pth file support in %ss   .pths   .okR   s#   import os;open(%r,'w').write('OK')
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(   R[   R   R   R   R,   R-   R.   R   t   dirnamet   makedirsR   R   R   R   t   writeR   RX   R   t
   executableR   R   R   R   t   distutils.spawnR   R7   Re   R   R9   (   R   R   Rx   t   ok_filet	   ok_existsR   RD   R   t   basenamet   altR   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR     sP    	
 
 	$   	c         C   sg   |  j  rV | j d  rV x: | j d  D]& } |  j | | | j d |   q) Wn  |  j |  d S(   s=   Write all the scripts for `dist`, unless scripts are excludedt   scriptss   scripts/N(   R]   t   metadata_isdirt   metadata_listdirt   install_scriptt   get_metadatat   install_wrapper_scripts(   R   t   distt   script_name(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   install_egg_scripts  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(   R,   R-   R   t   walkR   R   R   (   R   R-   t   baset   dirst   filesR   (    (    sC   /usr/lib/python2.7/dist-packages/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).(   RJ   R   (   R   R   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   not_editable!  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(   RJ   R,   R-   R.   R   R`   t   keyR   (   R   R   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   check_editable)  s    	'c         C   s  t  j d 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 rDd | } |  j r5| d 7} n  t |   nB | j t k rm|  j | | | d  | S|  j | | j | |  SWd  t j j |  rt |  n  Xd  S(   NRi   s   easy_install-s+   Could not find suitable distribution for %rs2    (--always-copy skips system and development eggs)t   Using(   t   tempfilet   mkdtempRX   RJ   t   install_site_pyR   R   R   R  Rw   t   downloadt   install_itemR7   R,   R-   R.   t   parse_requirement_argR  t   fetch_distributionR>   Rd   R   R   t
   precedenceR$   t   process_distributiont   locationR   (   R   R   t   depst   tmpdirR  R  R   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR&   8  s:    	 	
	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 | | |  } xY | D] } |  j | | |  qWn5 |  j |  j |   g } |  j | | d | d  | d  k	 rx! | D] } | | k ri| SqiWn  d  S(   Ns   .eggs   Processing %si    R  (   Rd   R,   R-   R   t   endswithRy   RX   R   R   t   project_nameR   R7   R   R   R  t   install_eggsR  t   check_conflictst   egg_distribution(   R   R   R  R"  R!  t   install_neededR  t   dists(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR  b  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   RX   R   (   R   R   t   schemeR  t   attrname(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR     s
    

c      
   G   s$  |  j  |  |  j j |  |  j j |  |  j sF |  j |  n  | |  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 r<| j   } | p| } t | j | j | j  } n  t j	 d |  y( t g   j | g |  j |  j  } WnK t k
 r} t d | j   n& t k
 r} t d | 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'   Could not find required distribution %ss7   Installed distribution %s conflicts with requirement %ss'   Finished processing dependencies for %s(   t
   update_pthRw   t   addR   RJ   R  R}   R  R   R   t   installation_reportt   has_metadataRv   R   t   get_metadata_linesRd   RX   R   t   as_requirementR   R$  t   specst   extrasR!   t   resolveR&   R"   R   Ra   R#   Ry   (   R   t   requirementR  R!  R   t   distreqt   distrosRK   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR    sJ    	
	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(   RY   RX   R0  R7   (   R   R  (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   should_unzip  s    c         C   s  t  j j |  j | j  } t  j j |  rM t j d | j |  j |  | St  j j |  rh | } 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    (   R,   R-   R   R`   R  R.   R   R   R   R   R   t   listdirR   R   t   shutilt   move(   R   R   t   dist_filenamet
   setup_baset   dstt   contents(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt
   maybe_move  s$    	
 c         C   s4   |  j  s0 x$ t |  D] } |  j |   q Wn  d  S(   N(   R]   t   get_script_argst   write_script(   R   R  Ra   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR
    s    	c         C   s   t  | j    } t | |  } | rG | rG t |  d t   } n  | rg t |  d t   } n  |  j | t |  d  d S(   s/   Generate a legacy script wrapper and install its   # EASY-INSTALL-DEV-SCRIPT: %(spec)r,%(script_name)r
__requires__ = %(spec)r
from pkg_resources import require; require(%(spec)r)
del require
__file__ = %(dev_path)r
execfile(__file__)
s   # EASY-INSTALL-SCRIPT: %(spec)r,%(script_name)r
__requires__ = %(spec)r
import pkg_resources
pkg_resources.run_script(%(spec)r, %(script_name)r)
RF   N(   t   strR2  t   is_python_scriptt   get_script_headert   localsRC  R4   (   R   R  R  t   script_textt   dev_pathR   t	   is_script(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR    s    		t   tc         C   s   |  j  g  | D] } t j j |  j |  ^ q  t j d | |  j  t j j |  j |  } |  j |  |  j s t	 |  t
 | d |  } | j |  | j   t | d  n  d S(   s1   Write an executable file to the scripts directorys   Installing %s script to %sR   i  N(   R   R,   R-   R   R\   R   R   R  R   R   R   R   R   t   chmod(   R   R  R@  t   modeR   RA   t   targetRD   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyRC    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_exeR,   R-   t   isfileR   t   unpack_progressR   RS   RU   R`   RX   RA  R   R.   R    R   R   RJ   R   R   t   report_editablet   build_and_install(   R   R   R=  R"  R>  t   setup_scriptt   setups(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR%    s4    "	c         C   s[   t  j j |  r3 t | t  j j | d   } n t t j |   } t j	 | d | S(   Ns   EGG-INFOt   metadata(
   R,   R-   R   R   R   R    t	   zipimportt   zipimporterR   t   from_filename(   R   t   egg_pathRW  (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR'  :  s    !c         C   s  t  j j |  j t  j j |   } t  j j |  } |  j sL t |  n  |  j |  } |  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  t |  t  j j |  r8| j |  r%t j d } } qt j d } } na |  j |  rg|  j |  |  j d } } n2 | j |  rt j d } } n t j d } } |  j | | | f | d t  j j |  t  j j |  f  n  |  j |  |  j |  S(   NR   s	   Removing t   Movingt   Copyingt
   Extractings	    %s to %s(   R,   R-   R   R[   R  RS   R   R   R'  R&  R%   R   R   R   t   remove_treeR.   R   R   t   uncache_zipdirRU   R;  R<  t   copytreeR9  t   mkpatht   unpack_and_compilet   copy2R   R  (   R   R[  R"  t   destinationR  RD   R=   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyRO  A  s6    $	% 
)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 |  D] } t j j | | d  ^ q t j | | d |  j d |  j |  j | |  S(   Ns(   %s is not a valid distutils Windows .exeR$  RW  R   RO   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(   RX   R   R   R   R   R,   R-   R   t   egg_nameR   R   R   t	   _providert
   exe_to_eggR.   R   R   t   itemst   replacet   titleR   R   RB  R   t   make_zipfileR   R   RO  (   R   R=  R"  t   cfgR  R[  t   egg_tmpR   t   pkg_infRD   t   kt   vR\   Ra   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyRP  c  s6    	&

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   RU   R   R   R,   R-   R   R#  R   t   strip_modulet   splitextR   R   R   RX   (   t   srcR?  R3   t   oldt   newt   partst   dl(   t   native_libsRr  t	   top_levelt   prefixest
   to_compile(    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   process  s$    s   .pydRv  is   .pys   EGG-INFOR  R~  s   .txtR   s   
N(   s	   top_levels   native_libs(   R*   R   R   R#  R   R   Rw  R,   R-   R   R   t
   write_stubt   byte_compilet   write_safety_flagt   analyze_eggRG  R.   R   R   R   (   R   R=  Rr  R  t   stubst   resR|  t   resourcet   pyfileR   t   txtRD   (    (   R~  R  R  Rr  R  sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyRl    s4    
 !c         C   s  | Sd d l  m } m } d d l m } g  } t j | j d   } i d d 6d d 6} x$ |   D] \ } }	 }
 d | | <qf Wxt |  j g |  j	  D] \ } } x | D] } t
 j j |  \ } } | | k r | sHy | | | g  \ } } } Wn t k
 rq qX| r)| j   n  | | k r| j |  qq| | k r| d k r| j t
 j j | |   qq q Wq W| r|  j | |  n  | S(	   s9   Verify that there are no conflicting "old-style" packagesi(   t   find_modulet   get_suffixes(   R    s   top_level.txti   s   .pycs   .pyoRV   (   t   impR  R  R    t   dictt   fromkeyst   _get_metadatat   expand_pathsR[   R   R,   R-   Rx  t   ImportErrorR   R   R   t   found_conflicts(   R   R  R  R  R    R   t   namest   extst   extRM  t   typR-   R  R   R  RD   t   descr(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR&    s4    & *c         C   s   |  j  r# t j d  |  j |  Sd d j |  } |  j rS | d | j 7} n
 | d 7} | d 7} t j j	 |  t j j
   |  j s t d   n  d  S(   Ns*   Attempting to delete conflicting packages:s  -------------------------------------------------------------------------
CONFLICT WARNING:

The following modules or packages have the same names as modules or
packages being installed, and will be *before* the installed packages in
Python's search path.  You MUST remove all of the relevant files and
directories before you will be able to use the package(s) you are
installing:

   %s

s   
   s   (Note: you can run EasyInstall on '%s' with the
--delete-conflicting option to attempt deletion of the above files
and/or directories.)
sL  Note: you can attempt this installation again with EasyInstall, and use
either the --delete-conflicting (-D) option or the
--ignore-conflicts-at-my-risk option, to either delete the above files
and directories, or to ignore the conflicts, respectively.  Note that if
you ignore the conflicts, the installed package(s) may not work.
sJ   -------------------------------------------------------------------------
s%   Installation aborted due to conflicts(   Rz   R   R   R   R   R{   R$  R   t   stderrR   t   flushR   (   R   R  R   R   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR    s    			t	   Installedc   	      C   sz   d } |  j  rN |  j rN | d 7} |  j t t t j  k rN | d 7} qN n  | j } | j } | j	 } d } | t
   S(   s9   Helpful installation message for display to package userss   
%(what)s %(eggloc)s%(extras)ss  

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.)
R   (   Re   Rj   R[   R   R   R   R-   R   R$  RO   RG  (	   R   t   reqR  t   whatR   t   egglocR   RO   R4  (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR/  	  s    
			c         C   s&   t  j j |  } t j } d t   S(   Ns"  
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.
(   R,   R-   R   R   R   RG  (   R   R   RU  R   t   python(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyRS  %  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   Ru  i   i    Ri  s   -qs   -ns   Running %s %st    s   Setup script exited with %s(   R   t   modulest
   setdefaultR   R   t   listR   R   R   R   R   R   R   R   t
   SystemExitR   Ra   (   R   RU  R>  Ra   Ru  (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR   2  s     	$c   	      C   s   d d g } t  j d d d t j j |   } z | j |  |  j | | |  t | g  } g  } x? | D]7 } x. | | D]" } | j |  j | j	 |   q Wqo W| r |  j
 r t j d |  n  | SWd  t |  t j |  j  Xd  S(   NR   s
   --dist-dirRi   s   egg-dist-tmp-t   dirs+   No eggs found in %s (setup script problem?)(   R  R  R,   R-   R   R   R   R   RO  R   R   R   R   R   R   R   (	   R   RU  R>  Ra   t   dist_dirt   all_eggst   eggsR  R  (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyRT  F  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   
(   Rx   RX   R  Re   R   R   R   t   removeR   t   pathsR.  R   R   t   saveR,   R-   R   R[   R   R   R   R   t   make_relativeR   (   R   R  R@   R   RD   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR-  [  s4    	
	  c         C   s   t  j d | |  | S(   Ns   Unpacking %s to %s(   R   t   debug(   R   Ry  R?  (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyRR  ~  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 |   j |  n. | j  d  sZ | j  d  rj  j |  n   j |  |   j r | p d  S(   Ns   .pys	   EGG-INFO/s   .dlls   .so(   R#  RU   R   RR  R   RX   (   Ry  R?  (   R  R   t   to_chmod(    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   pf  s    im  i  (   R   R  R   R,   t   statt   ST_MODERL  (   R   R[  Re  R  RD   RM  (    (   R  R   R  sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyRc    s     		c         C   s   t  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   Rb   i    t   forceR   (	   R   R   t   distutils.utilR  R   R   R   R   Rb   (   R   R  R  (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR    s    	c         C   s    d |  j  t j j d d  f S(   Ns  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:

  http://packages.python.org/distribute/easy_install.html#custom-installation-locations

Please make the appropriate changes for your system and try again.R   R   (   R[   R,   R   R   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR     s    c         C   sH  |  j  r d St j j |  j d  } t t j d  d  } d } t j j |  r t	 j
 d |  j  t | d  } | j   } t j d k r | j   } n  | j   | j d  s t d	 |   q n  | | k r;t	 j d
 |  |  j s(t |  t | d  } | j |  | j   n  |  j | g  n  t |  _  d S(   s8   Make sure there's a site.py in the target dir, if neededNs   site.pyR   R   s   Checking existing site.py in %st   rbi   s   def __boot():s;   %s is not a setuptools-generated site.py; please remove it.s   Creating %st   wb(   i   (   R~   R,   R-   R   R[   R   R   t   parseR.   R   R  R   t   readR   t   version_infot   decodeR   RU   R   R   R   R   R   R  R7   (   R   t   sitepyt   sourcet   currentRD   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR    s2    	
	
c         C   s   |  j  s d St t j j d   } xc |  j j   D]R \ } } | j |  r5 t j j |  r5 |  j	 d |  t j
 | d  q5 q5 Wd S(   s   Create directories under ~.Nt   ~s   os.makedirs('%s', 0700)i  (   RQ   R   R,   R-   R   R   t	   iteritemsRU   R   t   debug_printR   (   R   t   homeR   R-   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR      s    	"i   s   2.3s   2.4s   2.5t   real_prefixs   site-packagess   dist-packagesR   R[   s/   $base/lib/python$py_version_short/site-packagesR\   s	   $base/bint
   unix_locals*   $base/local/lib/python$py_version_short/%ss   $base/local/bint   posix_localt
   deb_systems   $base/lib/python3/%ss   $base/Lib/site-packagess   $base/Scriptsc         G   s  |  j  d  j } |  j s$ |  j r |  j rT |  j j   d k rT d } d |  _ n* |  j sl d t j k rx t j } n d } | j	   } |  j | d <|  j
 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 ret j j |  } n  t |  | |  qqWd  S(   NR   R   R  s   /usrR  R  R  i(   R   R   (   s   deb(   t   get_finalized_commandR   Ri   R   R   R   t   __dict__R,   R   t   copyR   R   t   DEFAULT_SCHEMERm  R   RX   R   R  R   R-   R   (   R   R   R   t   scheme_nameR+  R   R   R   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR   -  s,    N(   s   prefix=Ns   installation prefix(   s   zip-okR<   s   install package as a zipfile(   s   multi-versionR=   s%   make apps have to require() a version(   s   upgradeR?   s1   force upgrade (searches PyPI for latest versions)(   s   install-dir=R@   s   install package to DIR(   s   script-dir=R3   s   install scripts to DIR(   s   exclude-scriptsRA   s   Don't install scripts(   s   always-copyRB   s'   Copy all needed packages to install dir(   s
   index-url=RC   s    base URL of Python Package Index(   s   find-links=RD   s(   additional URL(s) to search for packages(   s   delete-conflictingRE   s    no longer needed; don't use this(   s   ignore-conflicts-at-my-riskNs    no longer needed; don't use this(   s   build-directory=RF   s/   download/extract/build in DIR; keep the results(   s	   optimize=RG   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-unzipRH   s*   don't install as a zipfile, no matter what(   s
   site-dirs=RI   s)   list of directories where .pth files work(   s   editableRK   s+   Install specified packages in editable form(   s   no-depsRL   s   don't install dependencies(   s   allow-hosts=RM   s$   pattern(s) that hostnames must match(   s   local-snapshots-okRN   s(   allow building eggs from local checkouts(   s   versionNs"   print version information and exit(   s   install-layout=Ns1   installation layout to choose (known values: deb)(   s"   force-installation-into-system-dirRP   s   force installation into /usr(   s   no-find-linksNs9   Don't load find-links defined in packages being installed(    (   s   2.3s   2.4s   2.5(D   t   __name__t
   __module__t   __doc__t   descriptionR7   t   command_consumes_argumentsRX   t   user_optionst   boolean_optionsRR   R   RV   RW   t   negative_optR   R   R   R   R   R   R   R   R   R   R   R   R   R   R  R  R  R  R9   R&   R  R   R  R9  RA  R
  R  RC  R%  R'  RO  RP  Rl  R&  R  R/  RS  R   RT  R-  RR  Rc  R  R   R  R   R   RO   R  t   sitedir_nameR  R   R  R   (    (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR&   J   s        			9	
									*	)	,	
			*&	.					)		"	)	1	#	)				#				)	'	"		
	
	
	c       	   C   s?  t  d  t j j d d  j t j   }  t j g } t j	 t j k r[ | j
 t j	  n  x|| D]t} | rb 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  nu t j d
  d k rd } n d } |  j t j j | d d	 t j d
  |  t j j | d d	 t j d
  |  g  t j d k rd | k rt j j d  } | r|  j
 t j j | d d t j d
  d   qqqqb qb Wx6 d D]. } t |  } | |  k r|  j
 |  qqWt r,|  j
 t j  n  t t |   }  |  S(   NR   R   t   os2emxt   riscost   Libs   site-packagesRv  t   libR  i   s   site-pythons   2.3s   2.4s   2.5s   dist-packagess	   local/libt   darwins   Python.frameworkt   HOMEt   Libraryt   Pythoni    i   (   s   os2emxs   riscos(   s   2.3s   2.4s   2.5(   i    i   (   R   RX   R,   R   R   R   R   R   Ri   R   R   Rf  R-   R   t   sept   extendRO   R	   RR   RV   RW   R   R   (   t   sitedirsR  Ri   t   sdirR  t   plat_specifict   site_lib(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR   Q  sL    *"	#*
 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   R,   R-   R   R:  R#  R   R   R  R   R   RU   t   rstrip(   t   inputst   seenR   R  R   RD   t   linest   line(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR    s4    


c         C   s  t  |  d  } zat j |  } | d k r1 d S| d | d | d } | d k  r[ d S| j | d  d d l } d d l } d d l } | j d | j	 d   \ } } }	 | d k r d S| j | d |  | j
 i d d 6d d 6 }
 y9 |
 j | j | j	 |  j t d  d  d   Wn | j k
 rFd SX|
 j d  sg|
 j d  rkd S|
 SWd | j   Xd S(   sn   Extract configuration data from a bdist_wininst .exe

    Returns a ConfigParser.RawConfigParser, or None
    R  i	   i   i   i   iNs   <iiiizV4i{V4R   RO   Rg  i    i   RW  t   Setup(   izV4i{V4(   R   t   zipfilet   _EndRecDataRX   t   seekt   structt   StringIOt   ConfigParsert   unpackR  t   RawConfigParsert   readfpR   t   chrt   Errort   has_sectionR   (   R=  RD   t   endrect	   prependedR  R  R  t   tagt   cfglent   bmlenRq  (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR(     s.    $$9 c   	      C   s  d d d d d g } t  j |   } zSxL| 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 xk t
 | j |   D]Q } | j   j d d  } | j d  s| j d | d | f d f  qq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-packagesRv  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  R   Rn  RU   R   R   R   t   sortt   reverse(	   t   exe_filenameR  R<   R   R   R|  t   pthRA   t   y(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR*     s6    		"#"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   R  R   R   (   R   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR    s
    c           B   sM   e  Z d  Z e Z d d  Z d   Z d   Z d   Z d   Z	 d   Z
 RS(   s)   A .pth file with Distribution paths in itc         C   s   | |  _  t t |  |  _ t t j j |  j    |  _ |  j   t	 j
 |  g  d  d   x0 t |  j  D] } t |  j t | t   qi Wd  S(   N(   R   R   R   R  R,   R-   R   t   basedirt   _loadR   t   __init__RX   R   R  R.  R   R7   (   R   R   R  R-   (    (    sC   /usr/lib/python2.7/dist-packages/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  R9   R  R  R  R,   R-   RQ  R   R   RU   R7   R  R   R   R   R   R  R.   t   popt   dirtyR   (   R   t
   saw_importR  RD   R  R-   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR    s2    	"&	 c         C   s   |  j  s d Sd j t |  j |  j   } | r t j d |  j  d | } t j	 j
 |  j  rv t j |  j  n  t |  j d  } | j |  | j   n; t j	 j |  j  r t j d |  j  t j |  j  n  t |  _  d S(   s$   Write changed .pth file back to diskNs   
s	   Saving %ss   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  s   Deleting empty %s(   R  R   R   R  R  R   R  R   R,   R-   R   R   R   R   R   R.   R9   (   R   t   dataRD   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR  *  s     	 c         C   sl   | j  |  j k rX | j  |  j k s9 | j  t j   k rX |  j j | j   t |  _ n  t j	 |  |  d S(   s"   Add `dist` to the distribution mapN(
   R   R  R  R,   t   getcwdR   R7   R  R   R.  (   R   R  (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR.  F  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  R  R7   R  R   (   R   R  (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR  P  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(   NRv  (   R,   R-   R   R   R   R  t   altsepR  R   t   curdirR  R   (   R   R-   t   npatht   lastt   baselenR|  R  (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR  W  s    	
(    (   R  R  R  R9   R  R  R  R  R.  R  R  (    (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR'     s   			
	c         C   s)  d d l  m } t | j t  s= t j | j j    } n  |  d j   d } | j	 |  } d } | r | j
 d  p~ d } | r d | } q n  | r d } n t |  } d	 t   } t |  s	| r | j   j d
  rd | j   d } qq	d } n  t | |  } d	 t   } | S(   s;   Create a #! line, getting options (if any) from script_texti(   t   first_line_res   
i    R   i   R  s
   python.exes   #!%(executable)s%(options)s
Ri  s    -x(   t   distutils.command.build_scriptsR  R   t   patternRD  t   ret   compileR  t
   splitlinest   matcht   groupt   nt_quote_argRG  R:   R   RU   t   fix_jython_executable(   RH  R   t   wininstR  t   firstR  t   optionst   hdr(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyRF  f  s,     		c         C   sy   |  t  j k r8 t  j d k r8 t | t j  |  |  St j   } | d | d d | d d d |  | f f  d  S(   NR   i    i   s    %s %s(   R,   R  R   RL  R  t   S_IWRITER   R   (   t   funct   argt   exc(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt
   auto_chmod  s
    
c         C   s1   d d l  m } t |  |  t |  t j  d S(   s?   Ensure that the importer caches dont have stale info for `path`i(   t   _zip_directory_cacheN(   RX  R'  t   _uncacheR   t   path_importer_cache(   R-   t   zdc(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR`    s    c         C   sT   |  | k r | |  =n: t  |   }  x+ | D]# } t  |  |  k r) | | =d  Sq) Wd  S(   N(   R   (   R-   t   cachet   p(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR(    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(   R  t   SyntaxErrort	   TypeErrorR9   R7   (   t   textR   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt	   is_python  s
    c         C   sN   y) t  |   } | j d  } | j   Wn t t f k
 rC |  SX| d k S(   sC   Determine if the specified executable is a .sh (contains a #! line)i   s   #!(   R   R  R   R   R   (   R   t   fpt   magic(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   is_sh  s     c         C   s  g  } t  } d } d |  k p' d |  k } | r@ | j d  n  x |  D]z } | d k rf | d 7} qG | d k r | j d | d d  d } qG | r | j d |  d } n  | j |  qG W| r | j d |  n  | r| j d |  | j d  n  d	 j |  S(
   s@   Quote a command line argument according to Windows parsing rulesi    R  s   	t   "s   \i   i   s   \"R   (   R9   R   R   (   R$  t   resultt	   needquotet   nbt   c(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR    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#  R7   R1  RU   R  R   R9   (   RH  R   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyRE    s    (   RL  c          G   s   d  S(   N(    (   Ra   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   _chmod  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  R:  R,   t   error(   R-   RM  RK   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyRL    s
    c         C   sC   t  j j d  r? t |   r? | r4 t j d  q? d |  Sn  |  S(   Nt   javas   WARNING: Unable to adapt shebang line for Jython, the following script is NOT executable
         see http://bugs.jython.org/issue1112 for more information.s   /usr/bin/env %s(   R   Rf  RU   R4  R   R   (   R   R   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR    s
    c         c   s~  t  |  j    } t d | |  } xSd D]K} xB|  j |  j   D]+\ } } d t   } t j d k su | rc| d k r d \ }	 }
 d g } t j	 d	 d
 |  } n0 d \ }	 }
 d d d g } t j	 d d |  } t
 j j | d d ! st j d k r| } n | } | |	 | | d g  | D] } | | ^ q-f V| d t d |
  d f VqG | | | f VqG Wq+ Wd S(   sE   Yield write_script() argument tuples for a distribution's entrypointsR   t   console_scriptst   gui_scriptss   # 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)()
    )
t   win32s   -script.pyws   gui.exes   .pyws   (?i)python.exes   pythonw.exes
   -script.pys   cli.exes   .pys   .pycs   .pyos   (?i)pythonw.exes
   python.exei   iRK  s   .exet
   setuptoolsRF   N(   R=  R>  (   s   -script.pyws   gui.exe(   s
   -script.pys   cli.exe(   RD  R2  RF  t   get_entry_mapRm  RG  R   Rf  R  t   subR,   R-   R.   R   (   R  R   R  R   t   headerR  R   t   epRH  R  t   launcherRz  t
   new_headerR!  RA   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyRB     s*    "

	(	0c         C   sx  | r d   } n | d k r* d   } n  g  } y t j |   } Wn/ t j k
 rt } | 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 | | |  q| y t j |  Wq| t j k
 r.} | t j | t j    q| Xq| Wy t j |   Wn- t j k
 rs| 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(    (   Ra   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   onerror2  s    c          W   s     d  S(   N(    (   Ra   (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyRG  5  s    i    N(   RX   R,   R:  R;  R   R   R-   R   t   lstatt   st_modeR  t   S_ISDIRR   R  t   rmdir(   R-   t   ignore_errorsRG  R  t   errR   t   fullnameRM  (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR   +  s2    
!c          C   sM   d d  l  }  t j j |  j d  } | t j d <t j j |  t   d  S(   Nii    (	   R@  R,   R-   R   t   __path__R   t   argvR   R)   (   R@  t   argv0(    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt	   bootstrapN  s
       c            s   d d l  m  d d l m  d d  l  d   f d        f d    d  f   f d     Y  d  k r t j d	  n       f d
    d  S(   Ni(   t   setup(   R   sL   usage: %(script)s [options] requirement_or_url ...
   or: %(script)s --help
c            s   t  j j |   }   t   S(   N(   R,   R-   R  t   vars(   R  t   script(   t   USAGE(    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt	   gen_usage]  s    c            s7    j  j } z    j  _ |    SWd  |  j  _ Xd  S(   N(   t   coreRW  (   RD   t   old_gen_usage(   RW  R   (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   with_ei_usagea  s
    t   DistributionWithoutHelpCommandsc              s/   e  Z d  Z    f d   Z   f d   Z RS(   R   c            s          f d    d  S(   Nc              s     j      S(   N(   t
   _show_help(    (   R   Ra   t   kwR   (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   <lambda>m  s    (    (   R   Ra   R]  (   RZ  R   (   R   Ra   R]  sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR\  l  s    c            s/     j  |   } d | k r+ | j d  n  | S(   Ns	   setup.cfg(   t   find_config_filesR  (   R   R  (   R   (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR_  o  s    (   R  R  t   common_usageR\  R_  (    (   R   RZ  (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR[  i  s   i   c        	      s6     d d d d g  d t  j d p) d d    S(   Nt   script_argss   -qR&   s   -vR  i    t	   distclass(   R   RP  (    (   RS  R]  R[  RP  (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR^  x  s    (   R@  RS  t   setuptools.distR   t   distutils.coreRX   R   RP  (   RP  R]  (    (	   RW  R   RS  RP  R]  RV  R   RZ  R[  sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyR)   S  s    (a   R  R   t   os.pathR,   RX  R;  R  R  R  R  R   R    R@  R   R   t   setuptools.sandboxR   R   R   R   R  R   R   R   t   distutils.sysconfigR	   R
   t   distutils.errorsR   R   R   R   t   distutils.command.installR   R   t   setuptools.archive_utilR   t   setuptools.package_indexR   R   t   setuptools.commandR   R   t   pkg_resourcesR   R   R   R   R   R   R   R   R   R   R    R!   R"   R#   R$   R-   R/   R   t   sys_executablet   __all__RV   RO   t   ENABLE_USER_SITERR   R%   R  R4   R:   R&   R   R  R(   R*   R  R'   R9   RF  R&  R`  R(  R1  R4  R  RE  RL  R:  R  R  RB  R   RR  RX   R)   (    (    (    sC   /usr/lib/python2.7/dist-packages/setuptools/command/easy_install.pyt   <module>   sp   l"d	
			     	2	)	)	"	g			
				)			+#	