ó
è¾bc           @   sƒ   d  Z  d Z d d l Z d d l Z d d l m Z d d l m Z e e d ƒ rc e j	 d Z
 n d Z
 d	 e f d
 „  ƒ  YZ d S(   sk   distutils.command.install_lib

Implements the Distutils 'install_lib' command
(install all Python modules).s   $Id$iÿÿÿÿN(   t   Command(   t   DistutilsOptionErrort   extsept   pys   .pyt   install_libc        	   B   sŸ   e  Z d  Z d d d  d! d# d$ d% g Z d d
 d g Z i d
 d 6Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(&   s7   install all Python modules (extensions and pure Python)s   install-dir=t   ds   directory to install tos
   build-dir=t   bs'   build directory (where to install from)t   forcet   fs-   force installation (overwrite existing files)t   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]s
   skip-builds   skip the build stepsc         C   s:   d  |  _ d  |  _ d |  _ d  |  _ d  |  _ d  |  _ d  S(   Ni    (   t   Nonet   install_dirt	   build_dirR   R	   t   optimizet
   skip_build(   t   self(    (    s3   /usr/lib/python2.7/distutils/command/install_lib.pyt   initialize_options7   s    					c      	   C   s¿   |  j  d d d d d d d ƒ |  j d  k r: d
 |  _ n  |  j d  k rU d |  _ n  t |  j t ƒ s» y. t |  j ƒ |  _ |  j d k r” t ‚ n  Wq» t t f k
 r· t d ‚ q» Xn  d  S(   Nt   installt	   build_libR   R   R   R   R	   R   R   i   i    i   s   optimize must be 0, 1, or 2(   R   R   (   R   R   (   R   R   (   R	   R	   (   R   R   (   R   R   (   i    i   i   (	   t   set_undefined_optionsR	   R   R   t
   isinstancet   intt   AssertionErrort
   ValueErrorR   (   R   (    (    s3   /usr/lib/python2.7/distutils/command/install_lib.pyt   finalize_options@   s$    	c         C   sE   |  j  ƒ  |  j ƒ  } | d  k	 rA |  j j ƒ  rA |  j | ƒ n  d  S(   N(   t   buildR   R   t   distributiont   has_pure_modulest   byte_compile(   R   t   outfiles(    (    s3   /usr/lib/python2.7/distutils/command/install_lib.pyt   runZ   s    
c         C   sN   |  j  sJ |  j j ƒ  r( |  j d ƒ n  |  j j ƒ  rJ |  j d ƒ qJ n  d  S(   Nt   build_pyt	   build_ext(   R   R   R   t   run_commandt   has_ext_modules(   R   (    (    s3   /usr/lib/python2.7/distutils/command/install_lib.pyR   j   s
    	c         C   sL   t  j j |  j ƒ r0 |  j |  j |  j ƒ } n |  j d |  j ƒ d  S| S(   Ns3   '%s' does not exist -- no Python modules to install(   t   ost   patht   isdirR   t	   copy_treeR   t   warn(   R   R   (    (    s3   /usr/lib/python2.7/distutils/command/install_lib.pyR   q   s    	c         C   sº   t  j r |  j d ƒ d  Sd d l m } |  j d ƒ j } |  j rp | | d d d |  j d | d	 |  j	 ƒn  |  j
 d k r¶ | | d |  j
 d |  j d | d
 |  j d	 |  j	 ƒn  d  S(   Ns%   byte-compiling is disabled, skipping.iÿÿÿÿ(   R   R   R   i    R   t   prefixt   dry_runt   verbose(   t   syst   dont_write_bytecodeR)   t   distutils.utilR   t   get_finalized_commandt   rootR	   R   R+   R   R,   (   R   t   filesR   t   install_root(    (    s3   /usr/lib/python2.7/distutils/command/install_lib.pyR   z   s    		c   
      C   sˆ   | s
 g  S|  j  | ƒ } | j ƒ  } t | | ƒ } t | ƒ t t j ƒ } g  } x. | D]& }	 | j t j j | |	 | ƒ ƒ qZ W| S(   N(	   R0   t   get_outputst   getattrt   lenR%   t   sept   appendR&   t   join(
   R   t   has_anyt	   build_cmdt
   cmd_optiont
   output_dirt   build_filesR   t
   prefix_lent   outputst   file(    (    s3   /usr/lib/python2.7/distutils/command/install_lib.pyt   _mutate_outputs“   s    $c         C   s   g  } x‚ | D]z } t  j j t  j j | ƒ ƒ d } | t k rG q n  |  j rd | j | d ƒ n  |  j d k r | j | d ƒ q q W| S(   Ni   R
   i    t   o(   R%   R&   t   splitextt   normcaset   PYTHON_SOURCE_EXTENSIONR	   R8   R   (   R   t   py_filenamest   bytecode_filest   py_filet   ext(    (    s3   /usr/lib/python2.7/distutils/command/install_lib.pyt   _bytecode_filenames¢   s    "	c         C   su   |  j  |  j j ƒ  d d |  j ƒ } |  j r? |  j | ƒ } n g  } |  j  |  j j ƒ  d d |  j ƒ } | | | S(   sÁ   Return the list of files that would be installed if this command
        were actually run.  Not affected by the "dry-run" flag or whether
        modules have actually been built yet.
        R!   R   R"   (   RB   R   R   R   R	   RK   R$   (   R   t   pure_outputst   bytecode_outputst   ext_outputs(    (    s3   /usr/lib/python2.7/distutils/command/install_lib.pyR4   ¶   s    	c         C   sr   g  } |  j  j ƒ  r: |  j d ƒ } | j | j ƒ  ƒ n  |  j  j ƒ  rn |  j d ƒ } | j | j ƒ  ƒ n  | S(   sþ   Get the list of files that are input to this command, ie. the
        files that get installed as they are named in the build tree.
        The files in this list correspond one-to-one to the output
        filenames returned by 'get_outputs()'.
        R!   R"   (   R   R   R0   t   extendR4   R$   (   R   t   inputsR!   R"   (    (    s3   /usr/lib/python2.7/distutils/command/install_lib.pyt
   get_inputsË   s    (   s   install-dir=R   s   directory to install to(   s
   build-dir=R   s'   build directory (where to install from)(   R   R   s-   force installation (overwrite existing files)(   R	   R
   s   compile .py to .pyc [default]N(   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
   skip-buildNs   skip the build steps(   t   __name__t
   __module__t   descriptionR   t   user_optionst   boolean_optionst   negative_optR   R   R    R   R   R   RB   RK   R4   RQ   (    (    (    s3   /usr/lib/python2.7/distutils/command/install_lib.pyR      s*    												(   t   __doc__t   __revision__R%   R-   t   distutils.coreR    t   distutils.errorsR   t   hasattrR   RF   R   (    (    (    s3   /usr/lib/python2.7/distutils/command/install_lib.pyt   <module>   s   