
pQc           @   s  d  Z  d d l m Z d Z d d l Z d d l Z d d l Z d d l Td d l m	 Z	 d d l
 m Z d d l m Z d d	 l m Z d d
 l m Z d d l m Z m Z m Z d d l m Z d d l m Z d d l m Z d d l m Z e j d k  r1i d d 6d d 6d d 6d d 6d d 6Z n) i d d 6d d 6d d 6d d 6d d 6Z i
 i d d 6d d 6d d 6d d 6d d 6d 6i d d 6d d 6d  d 6d d 6d d 6d! 6i d" d 6d" d 6d# d 6d$ d 6d% d 6d& 6e d' 6i d" d 6d" d 6d( d 6d) d 6d% d 6d* 6i d d 6d d 6d d 6d d 6d d 6d+ 6i d" d 6d" d 6d# d 6d$ d 6d% d 6d, 6i d d 6d d 6d d 6d- d 6d d 6d. 6i d d 6d d 6d  d 6d- d 6d d 6d/ 6i d" d 6d" d 6d# d 6d0 d 6d% d 6d1 6Z d4 Z d2 e	 f d3     YZ d S(5   sF   distutils.command.install

Implements the Distutils 'install' command.i(   t   logs   $Id$N(   t   *(   t   Command(   t   DEBUG(   t   get_config_vars(   t   DistutilsPlatformError(   t
   write_file(   t   convert_patht
   subst_varst   change_root(   t   get_platform(   t   DistutilsOptionError(   t	   USER_BASE(   t	   USER_SITEs   2.2s   $baset   purelibt   platlibs   $base/Include/$dist_namet   headerss   $base/Scriptst   scriptst   datas   $base/Lib/site-packagess/   $base/lib/python$py_version_short/site-packagess3   $platbase/lib/python$py_version_short/site-packagess0   $base/include/python$py_version_short/$dist_names	   $base/bint   unix_prefixs   $base/lib/pythons   $base/include/python/$dist_namet	   unix_homes	   $usersites4   $userbase/include/python$py_version_short/$dist_names   $userbase/bins	   $userbaset	   unix_usert   nts4   $userbase/Python$py_version_nodot/Include/$dist_names   $userbase/Scriptst   nt_usert   os2t   os2_homes   /rc/bint   plan9_prefixt
   plan9_homes   $userbase/bin/rct
   plan9_usert   installc           B   s  e  Z d  Z dH dI dJ d dG d e f dK d dG d d f dL dM dN d dG d d f dO dP dQ dR dS dT dU dV dW g Z d d% d( d g Z i d d  6Z d,   Z d-   Z	 d.   Z
 d/   Z d0   Z d1   Z d2   Z d3   Z d4   Z d5   Z d6   Z d7   Z d8   Z d9   Z d:   Z d;   Z d<   Z d=   Z d>   Z d?   Z d@   Z dA e f dB e f dC e f dD e f dE dF   f g Z RS(X   s'   install everything from build directorys   prefix=s   installation prefixs   exec-prefix=s.   (Unix only) prefix for platform-specific filess   home=s+   (Unix only) home directory to install undert   users!   install in user site-package '%s's   install-base=s;   base installation directory (instead of --prefix or --home)s   install-platbase=s8   base installation directory for platform-specific files s$   (instead of --exec-prefix or --home)s   root=s<   install everything relative to this alternate root directorys   install-purelib=s;   installation directory for pure Python module distributionss   install-platlib=s8   installation directory for non-pure module distributionss   install-lib=s4   installation directory for all module distributions s3   (overrides --install-purelib and --install-platlib)s   install-headers=s(   installation directory for C/C++ headerss   install-scripts=s)   installation directory for Python scriptss   install-data=s%   installation directory for data filest   compilet   cs   compile .py to .pyc [default]s
   no-compiles   don't compile .py filess	   optimize=t   Osl   also compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0]t   forcet   fs1   force installation (overwrite any existing files)s
   skip-builds2   skip rebuilding everything (for testing/debugging)s   record=s3   filename in which to record list of installed filesc         C   s   d  |  _ d  |  _ d  |  _ d |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _	 d  |  _
 d  |  _ d  |  _ d  |  _ t |  _ t |  _ d  |  _ d  |  _ d  |  _ d |  _ d |  _ d |  _ d |  _ d  |  _ d  |  _ d  |  _ d  S(   Ni    i   (   t   Nonet   prefixt   exec_prefixt   homeR   t   install_baset   install_platbaset   roott   install_purelibt   install_platlibt   install_headerst   install_libt   install_scriptst   install_dataR   t   install_userbaseR   t   install_usersiteR   t   optimizet
   extra_patht   install_path_fileR"   t
   skip_buildt   warn_dirt
   build_baset	   build_libt   record(   t   self(    (    s/   /sys/lib/python2.7/distutils/command/install.pyt   initialize_options   s2    																	
							c         C   sL  |  j  s |  j s |  j r= |  j s- |  j r= t d d  n  |  j rd |  j  sX |  j rd t d  n  |  j r |  j  s |  j s |  j s |  j s |  j r t d   n  t j d k r |  j r |  j	 d  d  |  _ q n  |  j d  t j d k r|  j   n
 |  j   |  j d  t j t 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 6|  j d 6|  j d 6|  _ |  j   |  j d  |  j |  j d <|  j |  j d <t r;d d l m } d GH| |  j  n  |  j   |  j d  |  j rh|  j   n  |  j d  k r|  j j  r|  j! |  _ q|  j" |  _ n  |  j# d d  d! d" d# d$ d d  |  j$   |  j |  _% t j& j' |  j |  j(  |  _ |  j) d  k	 r(|  j* d% d d  d! d" d# d$  n  |  j d&  |  j+ d' d* d+  d  S(,   Ns.   must supply either prefix/exec-prefix/home or s)   install-base/install-platbase -- not boths9   must supply either home or prefix/exec-prefix -- not bothsG   can't combine user with prefix, exec_prefix/home, or install_(plat)baset   posixs+   exec-prefix option ignored on this platforms   pre-finalize_{unix,other}s   post-finalize_{unix,other}()i    R%   R&   t	   dist_namet   dist_versiont   dist_fullnamet
   py_versioni   t   py_version_shorti   t   py_version_nodott
   sys_prefixt   sys_exec_prefixt   userbaset   usersites   post-expand_basedirs()t   baset   platbasei(   t   pprints   config vars:s   post-expand_dirs()t   libR   R   R   R   R   t   libbases   after prepending roott   buildR8   R9   (   s
   build_bases
   build_base(   s	   build_libs	   build_lib(,   R%   R&   R'   R(   R)   R   R   t   ost   namet   warnR$   t	   dump_dirst   finalize_unixt   finalize_othert   stringt   splitt   syst   versionR   t   distributiont   get_namet   get_versiont   get_fullnameR1   R2   t   config_varst   expand_basedirsR   RJ   t   expand_dirst   create_home_pathR.   t   ext_modulesR,   R+   t   convert_pathst   handle_extra_patht   install_libbaset   patht   joint
   extra_dirsR*   t   change_rootst   set_undefined_options(   R;   RA   R%   R&   RJ   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyt   finalize_options  s~    
	$	




		

	c         C   s   t  r d d l m } | d GHx |  j D] } | d } | d d k rY | d d !} n  | |  j k r t j |  j | |  } t |  |  } n! t j | |  } t |  |  } d | | f GHq) Wn  d  S(   Ni(   t   longopt_xlatet   :i    t   =s     %s: %s(   R   t   distutils.fancy_getoptRj   t   user_optionst   negative_optRT   t	   translatet   getattr(   R;   t   msgRj   t   optt   opt_namet   val(    (    s/   /sys/lib/python2.7/distutils/command/install.pyRQ     s    	
	c      	   C   s  d } t  j d k r d } n  |  j d  k	 s< |  j d  k	 r |  j d  k ri |  j d  k ri |  j d  k s |  j d  k s |  j	 d  k s |  j
 d  k r t d  n  d  S|  j r |  j d  k r t d   n  |  j |  _ |  _ |  j | d  n |  j d  k	 r*|  j |  _ |  _ |  j | d  n |  j d  k r|  j d  k	 rTt d  n  t j j t  j  |  _ t j j t  j  |  _ n |  j d  k r|  j |  _ n  |  j |  _ |  j |  _ |  j | d  d  S(	   Nt   unixt   plan9sP   install-base or install-platbase supplied, but installation scheme is incompletes$   User base directory is not specifiedt   _usert   _homes*   must not supply exec-prefix without prefixt   _prefix(   RV   t   platformR(   R$   R)   R.   R+   R,   R-   R/   R0   R   R   R1   R   t   select_schemeR'   R%   R&   RN   Rd   t   normpath(   R;   R{   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyRR     sB    				c         C   s   |  j  rQ |  j d  k r' t d   n  |  j |  _ |  _ |  j t j d  n |  j	 d  k	 r |  j	 |  _ |  _ |  j d  nu |  j
 d  k r t j j t j
  |  _
 n  |  j
 |  _ |  _ y |  j t j  Wn! t k
 r t d t j  n Xd  S(   Ns$   User base directory is not specifiedRx   R   s)   I don't know how to install stuff on '%s'(   R   R1   R$   R   R(   R)   R|   RN   RO   R'   R%   Rd   R}   RV   t   KeyError(   R;   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyRS     s"    	c         C   sU   t  | } xD t D]< } d | } t |  |  d  k r t |  | | |  q q Wd  S(   Nt   install_(   t   INSTALL_SCHEMESt   SCHEME_KEYSRq   R$   t   setattr(   R;   RO   t   schemet   keyt   attrname(    (    s/   /sys/lib/python2.7/distutils/command/install.pyR|     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=   R   (	   Rq   R$   RN   RO   Rd   t
   expanduserR   R\   R   (   R;   t   attrst   attrRu   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyt   _expand_attrs  s    c         C   s   |  j  d d d g  d  S(   NR(   R)   R*   (   R   (   R;   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyR]     s    	c         C   s#   |  j  d d d d d d g  d  S(   NR+   R,   R.   R-   R/   R0   (   R   (   R;   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyR^     s    	c         G   s>   x7 | D]/ } d | } t  |  | t t |  |    q Wd  S(   NR   (   R   R   Rq   (   R;   t   namesRO   R   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyRa     s    
c         C   s   |  j  d  k r! |  j j  |  _  n  |  j  d  k	 r t |  j   t k r` t j |  j  d  |  _  n  t |  j   d k r |  j  d } } n0 t |  j   d k r |  j  \ } } n	 t d  t	 |  } n d  } d } | |  _
 | |  _ d  S(   Nt   ,i   i    i   sY   'extra_path' option must be a list, tuple, or comma-separated string with 1 or 2 elementst    (   R4   R$   RX   t   typet
   StringTypeRT   RU   t   lenR   R   t	   path_fileRf   (   R;   R   Rf   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyRb     s     	c      	   G   sD   x= | D]5 } d | } t  |  | t |  j t |  |    q Wd  S(   NR   (   R   R	   R*   Rq   (   R;   R   RO   R   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyRg   7  s    
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  (   R   R   RN   Rd   R   R\   t	   iteritemst
   startswitht   isdirt   debug_printt   makedirs(   R;   R'   RO   Rd   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyR_   <  s    	"c         C   s  |  j  sU |  j d  |  j j d  j } |  j rU | t   k rU t d   qU n  x! |  j   D] } |  j |  qb W|  j	 r |  j
   n  |  j r|  j   } |  j r t |  j  } x/ t t |   D] } | | | | | <q Wn  |  j t |  j | f d |  j  n  t t j j t j  } t t j j |  } t j j t j j |  j   } |  j r|  j	 oz|  j r| | k rt j d |  j  n  d  S(   NRM   s"   Can't install when cross-compilings'   writing list of installed files to '%s's   modules installed to '%s', which is not in Python's module search path (sys.path) -- you'll have to change the search path yourself(   R6   t   run_commandRX   t   get_command_objt	   plat_nameR7   R
   R   t   get_sub_commandsR   t   create_path_fileR:   t   get_outputsR*   R   t   xranget   executeR   t   mapRN   Rd   R}   RV   t   normcaseR.   R5   R    t   debug(   R;   t
   build_platt   cmd_namet   outputst   root_lent   countert   sys_pathR.   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyt   runI  s6    					!		c         C   sc   t  j j |  j |  j d  } |  j rN |  j t | |  j g f d |  n |  j	 d |  d  S(   Ns   .pths   creating %ss   path file '%s' not created(
   RN   Rd   Re   Rc   R   R5   R   R   Rf   RP   (   R;   t   filename(    (    s/   /sys/lib/python2.7/distutils/command/install.pyR   w  s    		c         C   s   g  } xV |  j    D]H } |  j |  } x0 | j   D]" } | | k r5 | j |  q5 q5 Wq W|  j r |  j r | j t j j |  j	 |  j d   n  | S(   Ns   .pth(
   R   t   get_finalized_commandR   t   appendR   R5   RN   Rd   Re   Rc   (   R;   R   R   t   cmdR   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyR     s    c         C   sC   g  } x6 |  j    D]( } |  j |  } | j | j    q W| S(   N(   R   R   t   extendt
   get_inputs(   R;   t   inputsR   R   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyR     s
    c         C   s   |  j  j   p |  j  j   S(   sR   Return true if the current distribution has any Python
        modules to install.(   RX   t   has_pure_modulest   has_ext_modules(   R;   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyt   has_lib  s    c         C   s   |  j  j   S(   N(   RX   t   has_headers(   R;   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyR     s    c         C   s   |  j  j   S(   N(   RX   t   has_scripts(   R;   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyR     s    c         C   s   |  j  j   S(   N(   RX   t   has_data_files(   R;   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyt   has_data  s    R.   R-   R/   R0   t   install_egg_infoc         C   s   t  S(   N(   t   True(   R;   (    (    s/   /sys/lib/python2.7/distutils/command/install.pyt   <lambda>  s    N(   s   prefix=Ns   installation prefix(   s   exec-prefix=Ns.   (Unix only) prefix for platform-specific files(   s   home=Ns+   (Unix only) home directory to install under(   s   install-base=Ns;   base installation directory (instead of --prefix or --home)(   s   root=Ns<   install everything relative to this alternate root directory(   s   install-purelib=Ns;   installation directory for pure Python module distributions(   s   install-platlib=Ns8   installation directory for non-pure module distributions(   s   install-headers=Ns(   installation directory for C/C++ headers(   s   install-scripts=Ns)   installation directory for Python scripts(   s   install-data=Ns%   installation directory for data files(   s   compileR    s   compile .py to .pyc [default](   s
   no-compileNs   don't compile .py files(   s	   optimize=R!   sl   also compile with optimization: -O1 for "python -O", -O2 for "python -OO", and -O0 to disable [default: -O0](   s   forceR#   s1   force installation (overwrite any existing files)(   s
   skip-buildNs2   skip rebuilding everything (for testing/debugging)(   s   record=Ns3   filename in which to record list of installed files(   t   __name__t
   __module__t   descriptionR$   R   Rn   t   boolean_optionsRo   R<   Ri   RQ   RR   RS   R|   R   R]   R^   Ra   Rb   Rg   R_   R   R   R   R   R   R   R   R   t   sub_commands(    (    (    s/   /sys/lib/python2.7/distutils/command/install.pyR   s   s      
           		M			0				
					"			.											(   s   purelibs   platlibs   headerss   scriptss   data(    t   __doc__t	   distutilsR    t   __revision__RV   RN   RT   t   typest   distutils.coreR   t   distutils.debugR   t   distutils.sysconfigR   t   distutils.errorsR   t   distutils.file_utilR   t   distutils.utilR   R   R	   R
   R   t   siteR   R   RW   t   WINDOWS_SCHEMER   R   R   (    (    (    s/   /sys/lib/python2.7/distutils/command/install.pyt   <module>   s   $

