ó
č¾bc           @   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' 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 d0 6i d+ d 6d+ d 6d1 d 6d2 d 6d. d 6d3 6i d d 6d d 6d d 6d d 6d d 6d4 6i d+ d 6d+ d 6d, d 6d- d 6d. d 6d5 6Z d8 Z d6 e	 f d7     YZ d S(9   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_prefixs5   $base/local/lib/python$py_version_short/dist-packagess9   $platbase/local/lib/python$py_version_short/dist-packagess6   $base/local/include/python$py_version_short/$dist_names   $base/local/bins   $base/localt
   unix_locals/   $base/lib/python$py_version_short/dist-packagess3   $platbase/lib/python$py_version_short/dist-packagest
   deb_systems   $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_homet   installc           B   s  e  Z d  Z dJ dK dL d dI d e f dM d dI d d f dN dO dP d dI d d f dQ dR dS dT dU dV dW dX dY dZ g Z d d% d( d g Z i d d  6Z 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   Z dB   Z dC e f dD e f dE e f dF e f dG dH   f g Z RS([   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 filess   install-layout=s7   installation layout to choose (known values: deb, unix)c         C   s÷   d  |  _ 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  |  _ d  S(   Ni    i   (   t   Nonet   prefixt   exec_prefixt   homeR   t   prefix_optiont   install_baset   install_platbaset   roott   install_purelibt   install_platlibt   install_headerst   install_libt   install_scriptst   install_dataR   t   install_userbaseR   t   install_usersitet   install_layoutR   t   optimizet
   extra_patht   install_path_fileR!   t
   skip_buildt   warn_dirt
   build_baset	   build_libt   record(   t   self(    (    s/   /usr/lib/python2.7/distutils/command/install.pyt   initialize_options“   s6    																			
							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   buildR9   R:   (   R9   R9   (   R:   R:   (,   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   RK   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<   RB   R$   R%   RK   (    (    s/   /usr/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_getoptRk   t   user_optionst   negative_optRU   t	   translatet   getattr(   R<   t   msgRk   t   optt   opt_namet   val(    (    s/   /usr/lib/python2.7/distutils/command/install.pyRR     s    	
	c         C   s  |  j  d  k	 s |  j d  k	 r |  j d  k rK |  j d  k rK |  j d  k sx |  j d  k sx |  j d  k sx |  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 |  _ |  j d  k rm|  j d  k	 r:t	 d  n  t j j t j  |  _ t j j t j  |  _ n |  j d  k r|  j |  _ n  |  j |  _  |  j |  _ |  j r|  j j   d k rŃ|  j d  q|  j j   d k rö|  j d
  qt	 d   n |  j r)t j j |  j  d k sGd t j k sGd t j k rW|  j d
  n8 t j j |  j  d k r|  j d  n |  j d  d  S(   NsP   install-base or install-platbase supplied, but installation scheme is incompletes$   User base directory is not specifiedR   R   s*   must not supply exec-prefix without prefixt   debR   R>   t   unixR   s"   unknown value for --install-layouts
   /usr/localt   PYTHONUSERBASEt   real_prefixR   (   Rw   (   R>   Rx   (   R(   R#   R)   R.   R+   R,   R-   R/   R0   R   R   R1   R   t   select_schemeR&   R$   R'   R%   RO   Re   t   normpathRW   R3   t   lowert   environt   __dict__(   R<   (    (    s/   /usr/lib/python2.7/distutils/command/install.pyRS   „  sX    				$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 specifiedt   _userR   s)   I don't know how to install stuff on '%s'(   R   R1   R#   R   R(   R)   R{   RO   RP   R&   R$   Re   R|   RW   t   KeyError(   R<   (    (    s/   /usr/lib/python2.7/distutils/command/install.pyRT   į  s"    	c         C   sU   t  | } xD t D]< } d | } t |  |  d  k r t |  | | |  q q Wd  S(   Nt   install_(   t   INSTALL_SCHEMESt   SCHEME_KEYSRr   R#   t   setattr(   R<   RP   t   schemet   keyt   attrname(    (    s/   /usr/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   (	   Rr   R#   RO   RP   Re   t
   expanduserR   R]   R   (   R<   t   attrst   attrRv   (    (    s/   /usr/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/   /usr/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/   /usr/lib/python2.7/distutils/command/install.pyR_     s    	c         G   s>   x7 | D]/ } d | } t  |  | t t |  |    q Wd  S(   NR   (   R   R   Rr   (   R<   t   namesRP   R   (    (    s/   /usr/lib/python2.7/distutils/command/install.pyRb     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    (   R5   R#   RY   t   typet
   StringTypeRU   RV   t   lenR   R   t	   path_fileRg   (   R<   R   Rg   (    (    s/   /usr/lib/python2.7/distutils/command/install.pyRc   !  s     	c      	   G   sD   x= | D]5 } d | } t  |  | t |  j t |  |    q Wd  S(   NR   (   R   R	   R*   Rr   (   R<   R   RP   R   (    (    s/   /usr/lib/python2.7/distutils/command/install.pyRh   C  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   RO   Re   R   R]   t	   iteritemst
   startswitht   isdirt   debug_printt   makedirs(   R<   R&   RP   Re   (    (    s/   /usr/lib/python2.7/distutils/command/install.pyR`   H  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(   NRN   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(   R7   t   run_commandRY   t   get_command_objt	   plat_nameR8   R
   R   t   get_sub_commandsR   t   create_path_fileR;   t   get_outputsR*   R   t   xranget   executeR   t   mapRO   Re   R|   RW   t   normcaseR.   R6   R    t   debug(   R<   t
   build_platt   cmd_namet   outputst   root_lent   countert   sys_pathR.   (    (    s/   /usr/lib/python2.7/distutils/command/install.pyt   runU  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(
   RO   Re   Rf   Rd   R   R6   R”   R   Rg   RQ   (   R<   t   filename(    (    s/   /usr/lib/python2.7/distutils/command/install.pyR     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   R6   RO   Re   Rf   Rd   (   R<   R§   R¦   t   cmdR¬   (    (    s/   /usr/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/   /usr/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.(   RY   t   has_pure_modulest   has_ext_modules(   R<   (    (    s/   /usr/lib/python2.7/distutils/command/install.pyt   has_lib­  s    c         C   s   |  j  j   S(   N(   RY   t   has_headers(   R<   (    (    s/   /usr/lib/python2.7/distutils/command/install.pyR¶   ³  s    c         C   s   |  j  j   S(   N(   RY   t   has_scripts(   R<   (    (    s/   /usr/lib/python2.7/distutils/command/install.pyR·   ¶  s    c         C   s   |  j  j   S(   N(   RY   t   has_data_files(   R<   (    (    s/   /usr/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/   /usr/lib/python2.7/distutils/command/install.pyt   <lambda>Ć  R   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(   R   R   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](   R!   R"   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(   s   install-layout=Ns7   installation layout to choose (known values: deb, unix)(   t   __name__t
   __module__t   descriptionR#   R   Ro   t   boolean_optionsRp   R=   Rj   RR   RS   RT   R{   R   R^   R_   Rb   Rc   Rh   R`   R«   R   R   R±   Rµ   R¶   R·   R¹   t   sub_commands(    (    (    s/   /usr/lib/python2.7/distutils/command/install.pyR   l   s      
            		Q			<				
					"			.											(   R   R   R   R   R   (    t   __doc__t	   distutilsR    t   __revision__RW   RO   RU   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   RX   t   WINDOWS_SCHEMER   R   R   (    (    (    s/   /usr/lib/python2.7/distutils/command/install.pyt   <module>   s   $

