
\Kc           @   s   d  Z  d Z d d k Z d d k Z d d k Z d d k Z d d k Td d k l Z d d k	 Td d k
 l Z l Z d d k l Z d d k l Z d d	 k l Z e i d
  Z d   Z d e f d     YZ d S(   s   distutils.command.build_ext

Implements the Distutils 'build_ext' command, for building extension
modules (currently limited to C extensions, should accommodate C++
extensions ASAP).s;   $Id: build_ext.py 54942 2007-04-24 15:27:25Z georg.brandl $iN(   t   *(   t   Command(   t   customize_compilert   get_python_version(   t   newer_group(   t	   Extension(   t   logs3   ^[a-zA-Z_][a-zA-Z_0-9]*(\.[a-zA-Z_][a-zA-Z_0-9]*)*$c          C   s   d d k  l }  |    d  S(   Ni(   t   show_compilers(   t   distutils.ccompilerR   (   R   (    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyR      s    t	   build_extc           B   s  e  Z d  Z d e i Z d@ dA d d	 d
 d f d d d e f dB dC dD d d d e f dE dF dG dH dI dK dL dM g Z d d! d$ d* g Z d0 dJ d1 e	 f g 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 RS(N   s8   build C/C++ extensions (compile/link to build directory)s    (separated by '%s')s
   build-lib=t   bs(   directory for compiled extension moduless   build-temp=t   ts1   directory for temporary files (build by-products)t   inplacet   is=   ignore build-lib and put compiled extensions into the source s,   directory alongside your pure Python moduless   include-dirs=t   Is.   list of directories to search for header filess   define=t   Ds   C preprocessor macros to defines   undef=t   Us!   C preprocessor macros to undefines
   libraries=t   ls!   external C libraries to link withs   library-dirs=t   Ls.   directories to search for external C librariess   rpath=t   Rs7   directories to search for shared C libraries at runtimes   link-objects=t   Os2   extra explicit link objects to include in the linkt   debugt   gs'   compile/link with debugging informationt   forcet   fs2   forcibly build everything (ignore file timestamps)s	   compiler=t   cs   specify the compiler types   swig-cpps)   make SWIG create C++ files (default is C)s
   swig-opts=s!   list of SWIG command line optionss   swig=s   path to the SWIG executables   help-compilers   list available compilersc         C   s   d  |  _ d  |  _ d  |  _ d |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _	 d  |  _
 d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  |  _ d  S(   Ni    (   t   Nonet
   extensionst	   build_libt
   build_tempR   t   packaget   include_dirst   definet   undeft	   librariest   library_dirst   rpatht   link_objectsR   R   t   compilert   swigt   swig_cppt	   swig_opts(   t   self(    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyt   initialize_optionsa   s$    																	c      	   C   s  d d k  l } |  i d d" d# d$ d% d&  |  i d  j o |  i i |  _ n |  i i |  _ | i	   } | i	 d	 d
  } |  i
 d  j o |  i i
 p g  |  _
 n t |  i
  t j o t i |  i
 t i  |  _
 n |  i
 i |  | | j o |  i
 i |  n t |  i  t j o |  i g |  _ n |  i d  j o g  |  _ n |  i d  j o g  |  _ n6 t |  i  t j o t i |  i t i  |  _ n |  i d  j o g  |  _ n6 t |  i  t j o t i |  i t i  |  _ n t i d j o |  i i t i i t i d   |  i o t i i |  i d  |  _ n t i i |  i d  |  _ |  i
 i t i i t i d   |  i i t i i t i d   n t i d j o& |  i i t i i t i d   n t i d  d j p t i d  d j ol t i i t i i t i d   o3 |  i i t i i t i d d t    d   q~|  i i d  n t i i d  p t i i d  of | i! d  oV t i i t i i t i d   o |  i i | i! d   q
|  i i d  n |  i" o. t i |  i" d  } t# d    |  |  _" n |  i$ o t i |  i$ d  |  _$ n |  i% d  j o g  |  _% n |  i% i d!  |  _% d  S('   Ni(   t	   sysconfigt   buildR   R   R&   R   R   t   plat_specifici   t   ntt   libst   Debugt   Releaset   PCt   PCBuildt   os2t   Configi   t   cygwint   atheost   bint   libt   pythont   configt   .t   linuxt   gnut   Py_ENABLE_SHAREDt   LIBDIRt   ,c         S   s
   |  d  f S(   t   1(    (   t   symbol(    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyt   <lambda>   s    t    (   s	   build_libs	   build_lib(   s
   build_temps
   build_temp(   s   compilers   compiler(   s   debugs   debug(   s   forces   force(&   t	   distutilsR,   t   set_undefined_optionsR   R   t   distributiont   ext_packaget   ext_modulesR   t   get_python_incR   t   typet
   StringTypet   stringt   splitt   ost   pathsept   appendR"   R#   R$   t   namet   patht   joint   syst   exec_prefixR   R   t   platformt
   executablet
   startswitht   prefixR   t   get_config_varR    t   mapR!   R)   (   R*   R,   t
   py_includet   plat_py_includet   defines(    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyt   finalize_optionsv   sv    	"
"&&(%
&%

c      
   C   s  d d k  l } |  i p d  Sn |  i i   oC |  i d  } |  i i | i   p g   |  i	 i
 | i  n | d |  i d |  i d |  i d |  i  |  _ t |  i  |  i d  j	 o |  i i |  i  n |  i d  j	 o1 x. |  i D] \ } } |  i i | |  q Wn |  i d  j	 o( x% |  i D] } |  i i |  q4Wn |  i d  j	 o |  i i |  i  n |  i	 d  j	 o |  i i |  i	  n |  i d  j	 o |  i i |  i  n |  i d  j	 o |  i i |  i  n |  i   d  S(   Ni(   t   new_compilert
   build_clibR&   t   verboset   dry_runR   (   R   Rc   R   RI   t   has_c_librariest   get_finalized_commandR"   t   extendt   get_library_namesR#   RS   Rd   R&   Re   Rf   R   R   R   R   t   set_include_dirsR    t   define_macroR!   t   undefine_macrot   set_librariest   set_library_dirsR$   t   set_runtime_library_dirsR%   t   set_link_objectst   build_extensions(   R*   Rc   Rd   RT   t   valuet   macro(    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyt   run   s>    
		
 
 c   
      C   sf  t  |  t j	 o t d  n x?t t |   D]+} | | } t | t  o q3 n | \ } } t i d |  t  |  t	 j	 o  t |  d j o t d  n t  |  t
 j o t i |  p t d  n t  |  t j	 o t d  n t | | d  } x> d D]6 } | i |  } | d j	 o t | | |  qqW| i d  | _ | i d  o t i d  n | i d  } | o g  | _ g  | _ x | D] }	 t  |	  t	 j o! d t |	  j o
 d j n p t d  n t |	  d j o | i i |	 d  qt |	  d j o | i i |	  qqWn | | | <q3 Wd S(   s  Ensure that the list of extensions (presumably provided as a
        command option 'extensions') is valid, i.e. it is a list of
        Extension objects.  We also support the old-style list of 2-tuples,
        where the tuples are (ext_name, build_info), which are converted to
        Extension instances here.

        Raise DistutilsSetupError if the structure is invalid anywhere;
        just returns otherwise.
        s:   'ext_modules' option must be a list of Extension instancessu   old-style (ext_name, build_info) tuple found in ext_modules for extension '%s'-- please convert to Extension instancei   sM   each element of 'ext_modules' option must be an Extension instance or 2-tuplesR   first element of each tuple in 'ext_modules' must be the extension name (a string)sO   second element of each tuple in 'ext_modules' must be a dictionary (build info)t   sourcesR   R#   R"   t   extra_objectst   extra_compile_argst   extra_link_argsR$   t   def_files9   'def_file' element of build info dict no longer supportedt   macrosi   s9   'macros' element of build info dict must be 1- or 2-tuplei    N(   s   include_dirss   library_dirss	   librariess   extra_objectss   extra_compile_argss   extra_link_args(   RM   t   ListTypet   DistutilsSetupErrort   ranget   lent
   isinstanceR   R   t   warnt	   TupleTypeRN   t   extension_name_ret   matcht   DictionaryTypet   getR   t   setattrt   runtime_library_dirst   has_keyt   define_macrost   undef_macrosRS   (
   R*   R   R   t   extt   ext_namet
   build_infot   keyt   valR{   Rt   (    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyt   check_extensions_list'  sd    

 
	&


     		 $
c         C   s>   |  i  |  i  g  } x! |  i D] } | i | i  q  W| S(   N(   R   R   Ri   Rv   (   R*   t	   filenamesR   (    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyt   get_source_files}  s    
 c         C   sh   |  i  |  i  g  } xK |  i D]@ } |  i | i  } | i t i i |  i |  i	 |    q  W| S(   N(
   R   R   t   get_ext_fullnameRT   RS   RQ   RU   RV   R   t   get_ext_filename(   R*   t   outputsR   t   fullname(    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyt   get_outputs  s    
 c         C   s5   |  i  |  i  x |  i D] } |  i |  q Wd  S(   N(   R   R   t   build_extension(   R*   R   (    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyRr     s    
 c         C   s  | i  } | d  j p t |  t t f j o t d d d | i  n t |  } |  i | i  } |  i	 ou t
 i | d  } t
 i | d d !d  } | d } |  i d  } | i |  } t i i | |  i |   }	 n" t i i |  i |  i |   }	 | | i }
 |  i p t |
 |	 d  p t i d	 | i  d  Sn t i d
 | i  |  i | |  } | i p g  } | i } x! | i D] } | i | f  qW|  i i | d |  i  d | d | i! d |  i d | d | i } | |  _" | i# o | i$ | i#  n | i% p g  } | i& p |  i i' |  } |  i i( | |	 d |  i) |  d | i* d | i+ d | d |  i, |  d |  i d |  i  d | d  S(   Ns*   in 'ext_modules' option (extension '%s'), s&   'sources' must be present and must be s   a list of source filenamesR=   i    it   build_pyt   newers$   skipping '%s' extension (up-to-date)s   building '%s' extensiont
   output_dirR{   R   R   t   extra_postargst   dependsR"   R#   R   t   export_symbolsR   t   target_lang(-   Rv   R   RM   R|   R   R}   RT   t   listR   R   RO   RP   RV   Rh   t   get_package_dirRQ   RU   R   R   R   R   R   R   R   t   infot   swig_sourcesRx   R   R   RS   R&   t   compileR   R   t   _built_objectsRw   Ri   Ry   t   languaget   detect_languaget   link_shared_objectt   get_librariesR#   R   t   get_export_symbols(   R*   R   Rv   R   t   modpathR   t   baseR   t   package_dirt   ext_filenameR   t
   extra_argsR{   R!   t   objectsR   (    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyR     sd    	&



 			

						c      
   C   s  g  } g  } h  } |  i  o t i d  n |  i  p  d |  i j p d | i j o
 d } n d } xt | D]l } t i i |  \ } }	 |	 d j o4 | i | d |  | i |  | d | | <qn | i |  qn W| p | Sn |  i p
 |  i	   }
 |
 d g } | i
 |  i  |  i  o | i d  n |  i p% x" | i D] } | i |  qNWn xE | D]= } | | } t i d	 | |  |  i | d
 | | g  qpW| S(   s   Walk the list of source files in 'sources', looking for SWIG
        interface (.i) files.  Run SWIG on all that are found, and
        return a modified 'sources' list with SWIG source files replaced
        by the generated C (or C++) files.
        s/   --swig-cpp is deprecated - use --swig-opts=-c++s   -c++s   .cpps   .cs   .it   _wrapis   -pythons   swigging %s to %ss   -o(   R(   R   R   R)   RQ   RU   t   splitextRS   R'   t	   find_swigRi   R   t   spawn(   R*   Rv   t	   extensiont   new_sourcesR   t   swig_targetst
   target_extt   sourceR   R   R'   t   swig_cmdt   ot   target(    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyR     sD    

 


  
c         C   s   t  i d j o d Sn t  i d j oM xr d D]: } t  i i d | d  } t  i i |  o | Sq/ q/ Wd Sn) t  i d	 j o d Sn t d
 t  i  d S(   s   Return the name of the SWIG executable.  On Unix, this is
        just "swig" -- it should be in the PATH.  Tries a bit harder on
        Windows.
        t   posixR'   R/   s   1.3s   1.2s   1.1s	   c:\swig%ss   swig.exeR5   s>   I don't know how to find (much less run) SWIG on platform '%s'N(   s   1.3s   1.2s   1.1(   RQ   RT   RU   RV   t   isfilet   DistutilsPlatformError(   R*   t   verst   fn(    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyR   >  s     c         C   s+   |  i  d  j o | Sn |  i  d | Sd  S(   NR=   (   R   R   (   R*   R   (    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyR   `  s    c         C   s   d d k  l } t i | d  } t i d j o* | t |  d d  | t |  d <n | d  } t i d j o) |  i o t t i	 i
 |  d	 | Sn t t i	 i
 |  | S(
   s   Convert the name of an extension (eg. "foo.bar") into the name
        of the file from which it will be loaded (eg. "foo/bar.so", or
        "foo\bar.pyd").
        i(   R]   R=   R5   i   i   t   SOR/   t   _d(   t   distutils.sysconfigR]   RO   RP   RQ   RT   R   R   t   applyRU   RV   (   R*   R   R]   t   ext_patht   so_ext(    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyR   f  s    *c         C   sH   d t  i | i d  d } | | i j o | i i |  n | i S(   s  Return the list of symbols that a shared extension has to
        export.  This either uses 'ext.export_symbols' or, if it's not
        provided, "init" + module_name.  Only relevant on Windows, where
        the .pyd file (DLL) must export the module "init" function.
        t   initR=   i(   RO   RP   RT   R   RS   (   R*   R   t   initfunc_name(    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyR   w  s    c         C   se  t  i d j o d d k l } t |  i |  pR d } |  i o | d } n | t  i d ?t  i d ?d @f } | i | g Sqa| i Snt  i d	 j o: d } | t  i d ?t  i d ?d @f } | i | g Snt  i d
  d j o: d } | t  i d ?t  i d ?d @f } | i | g Sn:t  i d
  d j o d d k	 l
 } d } | t  i d ?t  i d ?d @f } g  } xO | i d  i   D]8 } | i d  o | i | d  q| i |  qW| i | d g | Sn} t  i d j o | i Snb d d k	 l
 } | i d  o: d } | t  i d ?t  i d ?d @f } | i | g Sn | i Sd S(   s   Return the list of libraries to link against when building a
        shared extension.  On most platforms, this is just 'ext.libraries';
        on Windows and OS/2, we add the Python library (eg. python20.dll).
        t   win32i(   t   MSVCCompilers
   python%d%dR   i   i   i   t   os2emxi   R7   s   python%d.%dR8   (   R,   t   SHLIBSs   -li   t   mt   darwinR@   N(   RW   RY   t   distutils.msvccompilerR   R   R&   R   t
   hexversionR"   RG   R,   R]   RP   R[   RS   (   R*   R   R   t   templatet	   pythonlibR,   t   extraR:   (    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyR     sR    

 (   s
   build-lib=R
   s(   directory for compiled extension modules(   s   build-temp=R   s1   directory for temporary files (build by-products)(   s   define=R   s   C preprocessor macros to define(   s   undef=R   s!   C preprocessor macros to undefine(   s
   libraries=R   s!   external C libraries to link with(   s   rpath=R   s7   directories to search for shared C libraries at runtime(   s   link-objects=R   s2   extra explicit link objects to include in the link(   s   debugR   s'   compile/link with debugging information(   s   forceR   s2   forcibly build everything (ignore file timestamps)(   s	   compiler=R   s   specify the compiler typeN(   s   swig-cppNs)   make SWIG create C++ files (default is C)(   s
   swig-opts=Ns!   list of SWIG command line options(   s   swig=Ns   path to the SWIG executable(   t   __name__t
   __module__t   descriptionRQ   RR   t   sep_byR   t   user_optionst   boolean_optionsR   t   help_optionsR+   Rb   Ru   R   R   R   Rr   R   R   R   R   R   R   R   (    (    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pyR	      sh     
   
        			r	?	V				b	:	"			(   t   __doc__t   __revision__RW   RQ   RO   t   ret   typest   distutils.coreR   t   distutils.errorsR   R   R   t   distutils.dep_utilR   t   distutils.extensionR   RG   R   R   R   R   R	   (    (    (    s1   /usr/lib/python2.5/distutils/command/build_ext.pys   <module>   s   0

		