Ñò
ïžòKc           @   s1  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 l	 Z	 d 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 d d k l Z e i d j o# d d k l Z e e ƒ  ƒ Z n 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 75395 2009-10-13 21:17:34Z tarek.ziade $iÿÿÿÿN(   t   *(   t	   USER_BASEt	   USER_SITE(   t   Command(   t   customize_compilert   get_python_version(   t   newer_group(   t	   Extension(   t   get_platform(   t   logt   nt(   t   get_build_versions3   ^[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   scripts/common/Lib/distutils/command/build_ext.pyR       s    t	   build_extc           B   s?  e  Z d  Z d e i Z dF dG d d	 d
 e ƒ  f d d d d f d d d e f dH dI dJ d d d e f dK dL dM dN dO dQ dR dS dT g Z d d$ d' d- d3 g Z	 d5 dP d6 e
 f g 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 „  Z dD „  Z dE „  Z RS(U   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)s
   plat-name=t   ps>   platform name to cross-compile for, if supported (default: %s)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 executablet   users#   add user include, library and rpaths   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  |  _ d  |  _ d  S(   Ni    (   t   Nonet
   extensionst	   build_libt	   plat_namet
   build_tempR   t   packaget   include_dirst   definet   undeft	   librariest   library_dirst   rpatht   link_objectsR   R   t   compilert   swigt   swig_cppt	   swig_optsR    (   t   self(    (    s1   scripts/common/Lib/distutils/command/build_ext.pyt   initialize_optionsl   s(    																			c   	   
   C   s:  d d k  l } |  i d d/ d0 d1 d2 d3 d4 ƒ |  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 ƒ o |  i
 i t i ƒ |  _
 n |  i
 i | ƒ | | j o |  i
 i | ƒ n t |  i t ƒ 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 ƒ ƒ t d j os |  i d j o
 d } n |  i d } t i i t i d ƒ } | o t i i | | ƒ } n |  i i | ƒ q t d j o, |  i i t i i t i d d d ƒ ƒ q t d j o) |  i i t i i t i d d ƒ ƒ q |  i i t i i t i d 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$ ƒ ƒ qj|  i i d% ƒ n | i% d& ƒ t i  i" d' ƒ p& 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+ |  i& i d+ ƒ } t' d, „  | ƒ |  _& n |  i( o |  i( i d+ ƒ |  _( n |  i) d  j o g  |  _) n |  i) i d- ƒ |  _) |  i* oŒ t i i t+ d. ƒ } t i i t+ d" ƒ } t i i, | ƒ o |  i
 i | ƒ n t i i, | ƒ o$ |  i i | ƒ |  i i | ƒ q6n d  S(5   Niÿÿÿÿ(   t	   sysconfigt   buildR#   R%   R.   R   R   R$   t   plat_specifici   R
   t   libst   Debugt   Releaset   PCi	   t   win32t    i   t   PCbuildi   s   VS8.0t   win32releasei   s   VS7.1t   VC6t   os2t   Configi   t   cygwint   atheost   bint   libt   pythont   configt   .t   Py_ENABLE_SHAREDt   linuxt   gnut   sunost   LIBDIRt   ,c         S   s
   |  d  f S(   t   1(    (   t   symbol(    (    s1   scripts/common/Lib/distutils/command/build_ext.pyt   <lambda>ÿ   s    t    t   include(   s	   build_libs	   build_lib(   s
   build_temps
   build_temp(   s   compilers   compiler(   s   debugs   debug(   s   forces   force(   s	   plat_names	   plat_name(-   t	   distutilsR4   t   set_undefined_optionsR&   R!   t   distributiont   ext_packaget   ext_modulesR"   t   get_python_incR'   t
   isinstancet   strt   splitt   ost   pathsept   appendR*   R+   t   typet
   StringTypet   stringR,   t   namet   patht   joint   syst   exec_prefixR   R%   t   MSVC_VERSIONR$   t   platformt
   executablet
   startswitht   prefixR   t   get_config_varR(   t   mapR)   R1   R    R   t   isdir(	   R2   R4   t
   py_includet   plat_py_includet   suffixt   new_libt   definest   user_includet   user_lib(    (    s1   scripts/common/Lib/distutils/command/build_ext.pyt   finalize_optionsƒ   sª    	"
"
&(%
&%


c      
   C   s3  d d k  l } |  i p d  S|  i i ƒ  oC |  i d ƒ } |  i i | i ƒ  p g  ƒ |  i	 i
 | i ƒ n | d |  i d |  i d |  i d |  i ƒ |  _ t |  i ƒ t i d j o* |  i t ƒ  j o |  i i |  i ƒ n |  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 | ƒ qk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
   ($   R   Rx   R"   RV   t   has_c_librariest   get_finalized_commandR*   t   extendt   get_library_namesR+   R_   Ry   R.   Rz   R{   R   R   R]   Rc   R$   R   t
   initializeR'   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(   R2   Rx   Ry   Rc   t   valuet   macro(    (    s1   scripts/common/Lib/distutils/command/build_ext.pyt   run  sB    
		#
 
 c   
      C   s:  t  | t ƒ p t d ‚ n xt | ƒ D]\ } } t  | t ƒ o q* n t  | t ƒ p t | ƒ d j o t d ‚ n | \ } } t i d | ƒ t  | t	 ƒ o t
 i | ƒ p t d ‚ n t  | t ƒ p t d ‚ n t | | d ƒ } x> d D]6 } | i | ƒ } | d j	 o t | | | ƒ qÿ qÿ W| i d ƒ | _ d | j o t i d ƒ n | i d ƒ } | o© g  | _ g  | _ x” | D]ˆ }	 t  |	 t ƒ o t |	 ƒ d j p t d ‚ n t |	 ƒ d j o | i i |	 d ƒ q˜t |	 ƒ d j o | i i |	 ƒ q˜q˜Wn | | | <q* 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 instancesi   sM   each element of 'ext_modules' option must be an Extension instance or 2-tuplesu   old-style (ext_name, build_info) tuple found in ext_modules for extension '%s'-- please convert to Extension instancesR   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(   i   i   (   RZ   t   listt   DistutilsSetupErrort	   enumerateR   t   tuplet   lenR	   t   warnR[   t   extension_name_ret   matcht   dictt   getR!   t   setattrt   runtime_library_dirst   define_macrost   undef_macrosR_   (
   R2   R"   R   t   extt   ext_namet
   build_infot   keyt   valR‘   RŠ   (    (    s1   scripts/common/Lib/distutils/command/build_ext.pyt   check_extensions_listV  sZ    

 $
	

  		 #
c         C   s>   |  i  |  i ƒ g  } x! |  i D] } | i | i ƒ q  W| S(   N(   R¥   R"   R~   RŒ   (   R2   t	   filenamesR    (    (    s1   scripts/common/Lib/distutils/command/build_ext.pyt   get_source_files¤  s    
 c         C   sG   |  i  |  i ƒ g  } x* |  i D] } | i |  i | i ƒ ƒ q  W| S(   N(   R¥   R"   R_   t   get_ext_fullpathRc   (   R2   t   outputsR    (    (    s1   scripts/common/Lib/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(   R2   R    (    (    s1   scripts/common/Lib/distutils/command/build_ext.pyRˆ   ¼  s    
 c   
      C   s	  | i  } | d  j p t | ƒ t t f j o t d d d | i ‚ n t | ƒ } |  i | i ƒ } | | i	 } |  i
 p t | | d ƒ p t i d | i ƒ d  S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 filenamest   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(#   RŒ   R!   R`   t   ListTypet	   TupleTypeR“   Rc   R’   R¨   R¯   R   R   R	   R   t   infot   swig_sourcesRŽ   Rž   RŸ   R_   R.   t   compileR%   R'   t   _built_objectsR�   R~   R�   t   languaget   detect_languaget   link_shared_objectt   get_librariesR+   R�   t   get_export_symbols(
   R2   R    RŒ   t   ext_pathR¯   t
   extra_argsR‘   R)   t   objectsR¸   (    (    s1   scripts/common/Lib/distutils/command/build_ext.pyR«   Ã  sP    	&

 			

						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 | S|  i p
 |  i	 ƒ  }
 |
 d g } | i
 |  i ƒ |  i  o | i d ƒ n |  i p% x" | i D] } | i | ƒ qKWn xE | D]= } | | } t i d	 | | ƒ |  i | d
 | | g ƒ qm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   _wrapiÿÿÿÿs   -pythons   swigging %s to %ss   -o(   R0   R	   R—   R1   R]   Rd   t   splitextR_   R/   t	   find_swigR~   R´   t   spawn(   R2   RŒ   t	   extensiont   new_sourcesRµ   t   swig_targetst
   target_extt   sourcet   baseR    R/   t   swig_cmdt   ot   target(    (    s1   scripts/common/Lib/distutils/command/build_ext.pyRµ     sD    

 


  
c         C   s˜   t  i d j o d St  i d j oJ xl d D]7 } t  i i d | d ƒ } t  i i | ƒ o | Sq, Wd Sn& t  i d	 j o d S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.exeR@   s>   I don't know how to find (much less run) SWIG on platform '%s'N(   s   1.3s   1.2s   1.1(   R]   Rc   Rd   Re   t   isfilet   DistutilsPlatformError(   R2   t   verst   fn(    (    s1   scripts/common/Lib/distutils/command/build_ext.pyRÂ   P  s     	c   	      C   sü   t  i d t i d ƒ } | i | ƒ } |  i | ƒ } | i d ƒ } |  i | ƒ } t i i | ƒ d } |  i	 p4 t i i
 | d  | g Œ  } t i i
 |  i | ƒ Sd i
 | d d !ƒ } |  i d ƒ } t i i | i | ƒ ƒ } t i i
 | | ƒ S(   s¡   Returns the path of the filename for a given extension.

        The file is located in `build_lib` or directly in the package
        (inplace option).
        t   /s   ..RH   iÿÿÿÿi    t   build_py(   Rb   t	   maketransR]   t   sept	   translatet   get_ext_fullnameR\   t   get_ext_filenameRd   R   Re   R#   R}   t   abspatht   get_package_dir(	   R2   R¡   t   all_dotst   fullnamet   modpatht   filenameR&   RÓ   t   package_dir(    (    s1   scripts/common/Lib/distutils/command/build_ext.pyR¨   q  s    
c         C   s(   |  i  d j o | S|  i  d | Sd S(   sS   Returns the fullname of a given extension name.

        Adds the `package.` prefixRH   N(   R&   R!   (   R2   R¡   (    (    s1   scripts/common/Lib/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	 | S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ÿÿÿÿ(   Rm   RH   R@   i   i   t   SOR
   t   _d(   t   distutils.sysconfigRm   Rb   R\   R]   Rc   R–   R   t   applyRd   Re   (   R2   R¡   Rm   R½   t   so_ext(    (    s1   scripts/common/Lib/distutils/command/build_ext.pyRØ   š  s    *c         C   sE   d | 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   initRH   iÿÿÿÿ(   Rc   R\   R°   R_   (   R2   R    t   initfunc_name(    (    s1   scripts/common/Lib/distutils/command/build_ext.pyR¼   ª  s    c         C   sS  t  i d j o} d d k l } t |  i | ƒ pO d } |  i o | d } n | t  i d ?t  i d ?d @f } | i | g S| i SnÃt  i d	 j o7 d } | t  i d ?t  i d ?d @f } | i | g St  i d
  d j o7 d } | t  i d ?t  i d ?d @f } | i | g S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 | St  i d j o | i Sd d k	 l
 } | i d ƒ o7 d } | t  i d ?t  i d ?d @f } | i | g S| 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).
        R;   iÿÿÿÿ(   t   MSVCCompilers
   python%d%dRá   i   i   iÿ   t   os2emxi   RB   s   python%d.%dRC   (   R4   t   SHLIBSs   -li   t   mt   darwinRI   N(   Rf   Ri   t   distutils.msvccompilerRç   RZ   R.   R   t
   hexversionR*   RT   R4   Rm   R\   Rk   R_   (   R2   R    Rç   t   templatet	   pythonlibR4   t   extraRE   (    (    s1   scripts/common/Lib/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(   s   userNs#   add user include, library and rpath(   t   __name__t
   __module__t   descriptionR]   R^   t   sep_byR   R!   t   user_optionst   boolean_optionsR   t   help_optionsR3   Rw   R‹   R¥   R§   Rª   Rˆ   R«   Rµ   RÂ   R¨   R×   RØ   R¼   R»   (    (    (    s1   scripts/common/Lib/distutils/command/build_ext.pyR   %   st     

   
         			“	@	N	
			S	:	!	 				(!   t   __doc__t   __revision__Rf   R]   Rb   t   ret   typest   siteR   R   t   distutils.coreR   t   distutils.errorsRâ   R   R   t   distutils.dep_utilR   t   distutils.extensionR   t   distutils.utilR   RT   R	   Rc   Rì   R   t   intRh   R¶   R˜   R   R   (    (    (    s1   scripts/common/Lib/distutils/command/build_ext.pyt   <module>   s$   0

		