Ñò
$8Zc           @   s­   d  Z  d Z d d k Z d d k Z d d k l Z d d k l Z d d k l	 Z	 d d k
 l Z d d k l Z d d	 k l Z e i d
 ƒ Z d e	 f d „  ƒ  YZ d S(   sR   distutils.command.build_scripts

Implements the Distutils 'build_scripts' command.s   $Id$iÿÿÿÿN(   t   ST_MODE(   t	   sysconfig(   t   Command(   t   newer(   t   convert_path(   t   logs   ^#!.*python[0-9.]*([ 	].*)?$t   build_scriptsc           B   sS   e  Z d  Z d d d g Z d g Z d
 „  Z d „  Z d „  Z d „  Z d „  Z	 RS(   s(   "build" scripts (copy and fixup #! line)s
   build-dir=t   ds   directory to "build" (copy) tot   forcet   fs1   forcibly build everything (ignore file timestampss   executable=t   es*   specify final destination interpreter pathc         C   s1   d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  S(   N(   t   Nonet	   build_dirt   scriptsR   t
   executablet   outfiles(   t   self(    (    s5   /usr/lib/python2.6/distutils/command/build_scripts.pyt   initialize_options!   s
    				c         C   s)   |  i  d d d d ƒ |  i i |  _ d  S(	   Nt   buildR   R   R   R   (   s   build_scriptss	   build_dir(   s   forces   force(   s
   executables
   executable(   t   set_undefined_optionst   distributionR   (   R   (    (    s5   /usr/lib/python2.6/distutils/command/build_scripts.pyt   finalize_options(   s
    	c         C   s   |  i  S(   N(   R   (   R   (    (    s5   /usr/lib/python2.6/distutils/command/build_scripts.pyt   get_source_files/   s    c         C   s   |  i  p d  S|  i ƒ  d  S(   N(   R   t   copy_scripts(   R   (    (    s5   /usr/lib/python2.6/distutils/command/build_scripts.pyt   run2   s    
c         C   sì  |  i  |  i ƒ g  } x0|  i D]%} d } t | ƒ } t i i |  i t i i | ƒ ƒ } | i | ƒ |  i	 o( t
 | | ƒ o t i d | ƒ q  n y t | d ƒ } Wn* t j
 o |  i p ‚  n d } nc X| i ƒ  } | p |  i d | ƒ q  n t i | ƒ } | o  d } | i d ƒ p d } n | oÜ t i d | |  i ƒ |  i p£ t | d ƒ }	 t i p |	 i d	 |  i | f ƒ nL |	 i d	 t i i t i d
 ƒ d t i d ƒ t i d ƒ f ƒ | f ƒ |	 i | i ƒ  ƒ |	 i ƒ  n | o | i ƒ  qEq  | o | i ƒ  n |  i | | ƒ q  Wt i  d j o xŒ | D]€ }
 |  i o t i d |
 ƒ q`t i! |
 ƒ t" d @} | d Bd @} | | j o* t i d |
 | | ƒ t i# |
 | ƒ q`q`Wn d S(   s"  Copy each script listed in 'self.scripts'; if it's marked as a
        Python script in the Unix way (first line matches 'first_line_re',
        ie. starts with "\#!" and contains "python"), then adjust the first
        line to refer to the current Python interpreter as we copy.
        i    s   not copying %s (up-to-date)t   rs   %s is an empty file (skipping)i   t    s   copying and adjusting %s -> %st   ws   #!%s%s
t   BINDIRs
   python%s%st   VERSIONt   EXEt   posixs   changing mode of %siÿ  im  s!   changing mode of %s from %o to %oN($   t   mkpathR   R   R   t   ost   patht   joint   basenamet   appendR   R   R   t   debugt   opent   IOErrort   dry_runR   t   readlinet   warnt   first_line_ret   matcht   groupt   infoR   t   python_buildt   writeR   t   get_config_vart
   writelinest	   readlinest   closet	   copy_filet   namet   statR    t   chmod(   R   R   t   scriptt   adjustt   outfileR	   t
   first_lineR-   t   post_interpt   outft   filet   oldmodet   newmode(    (    s5   /usr/lib/python2.6/distutils/command/build_scripts.pyR   8   st    
 $



			 
	(   s
   build-dir=R   s   directory to "build" (copy) to(   s   forceR	   s1   forcibly build everything (ignore file timestamps(   s   executable=R
   s*   specify final destination interpreter path(
   t   __name__t
   __module__t   descriptiont   user_optionst   boolean_optionsR   R   R   R   R   (    (    (    s5   /usr/lib/python2.6/distutils/command/build_scripts.pyR      s   						(   t   __doc__t   __revision__R!   t   reR8   R    t	   distutilsR   t   distutils.coreR   t   distutils.dep_utilR   t   distutils.utilR   R   t   compileR,   R   (    (    (    s5   /usr/lib/python2.6/distutils/command/build_scripts.pyt   <module>   s   