lJc@sdZdZddkZddkZddkZddkZddkTddklZddk Tddk l Z l Z ddk lZddklZdd klZeid Zd Zd efd YZdS(sdistutils.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 54332 2007-03-13 10:19:35Z georg.brandl $iN(t*(tCommand(tcustomize_compilertget_python_version(t newer_group(t Extension(tlogs3^[a-zA-Z_][a-zA-Z_0-9]*(\.[a-zA-Z_][a-zA-Z_0-9]*)*$cCsddkl}|dS(Ni(tshow_compilers(tdistutils.ccompilerR(R((s./sys/lib/python/distutils/command/build_ext.pyRst build_extcBseZdZdeiZd@dAdd d d fd d defdBdCdDdddefdEdFdGdHdIdKdLdMgZdd!d$d*gZd0dJd1e fgZ d2Z d3Z d4Z d5Zd6Zd7Zd8Zd9Zd:Zd;Zd<Zd=Zd>Zd?ZRS(Ns8build C/C++ extensions (compile/link to build directory)s (separated by '%s')s build-lib=tbs(directory for compiled extension moduless build-temp=tts1directory for temporary files (build by-products)tinplacetis=ignore build-lib and put compiled extensions into the source s,directory alongside your pure Python moduless include-dirs=tIs.list of directories to search for header filessdefine=tDsC preprocessor macros to definesundef=tUs!C preprocessor macros to undefines libraries=tls!external C libraries to link withs library-dirs=tLs.directories to search for external C librariessrpath=tRs7directories to search for shared C libraries at runtimes link-objects=tOs2extra explicit link objects to include in the linktdebugtgs'compile/link with debugging informationtforcetfs2forcibly build everything (ignore file timestamps)s compiler=tcsspecify the compiler typesswig-cpps)make SWIG create C++ files (default is C)s swig-opts=s!list of SWIG command line optionssswig=spath to the SWIG executables help-compilerslist available compilerscCsd|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_d|_d|_dS(Ni(tNonet extensionst build_libt build_tempR tpackaget include_dirstdefinetundeft librariest library_dirstrpatht link_objectsRRtcompilertswigtswig_cppt swig_opts(tself((s./sys/lib/python/distutils/command/build_ext.pytinitialize_optionsas$                 c Csddkl}|idd"d#d$d%d&|idjo|ii|_n|ii|_|i }|i d d }|i djo|ii pg|_ nt |i t jot i|i ti|_ n|i i|||jo|i i|nt |it jo|ig|_n|idjo g|_n|idjo g|_n6t |it jot i|iti|_n|idjo g|_n6t |it jot i|iti|_ntid jo|iitiitid |iotii|id |_ntii|id|_|i itiitid|iitiitidntidjo&|iitiitidntid djptid djoltiitiitido3|iitiitiddt dq~|iidntiidptiidof|i!doVtiitiitido|ii|i!dq |iidn|i"o.t i|i"d}t#d ||_"n|i$ot i|i$d|_$n|i%djo g|_%n|i%id!|_%dS('Ni(t sysconfigtbuildRRR&RRt plat_specificitnttlibstDebugtReleasetPCtPCBuildtos2tConfigitcygwintatheostbintlibtpythontconfigt.tlinuxtgnutPy_ENABLE_SHAREDtLIBDIRt,cSs |dfS(t1((tsymbol((s./sys/lib/python/distutils/command/build_ext.pytst (s build_libs build_lib(s build_temps build_temp(scompilerscompiler(sdebugsdebug(sforcesforce(&t distutilsR,tset_undefined_optionsRRt distributiont ext_packaget ext_modulesRtget_python_incRttypet StringTypetstringtsplittostpathseptappendR"R#R$tnametpathtjointsyst exec_prefixRRtplatformt executablet startswithtprefixRtget_config_varR tmapR!R)(R*R,t py_includetplat_py_includetdefines((s./sys/lib/python/distutils/command/build_ext.pytfinalize_optionsvsv      " "&&(% &%   c Csddkl}|ipdSn|iioC|id}|ii|ipg|i i |i n|d|i d|i d|id|i|_ t|i |idj o|i i|in|idj o1x.|iD]\}}|i i||qWn|idj o(x%|iD]}|i i|q4Wn|idj o|i i|in|i dj o|i i|i n|idj o|i i|in|idj o|i i|in|idS(Ni(t new_compilert build_clibR&tverbosetdry_runR(RRcRRIthas_c_librariestget_finalized_commandR"textendtget_library_namesR#RSRdR&ReRfRRRRtset_include_dirsR t define_macroR!tundefine_macrot set_librariestset_library_dirsR$tset_runtime_library_dirsR%tset_link_objectstbuild_extensions(R*RcRdRTtvaluetmacro((s./sys/lib/python/distutils/command/build_ext.pytruns>      c Csft|tj o tdnx?tt|D]+}||}t|toq3n|\}}tid|t|t j o t|djo tdnt|t jo t i |p tdnt|t j o tdnt||d}x>dD]6}|i|}|dj ot|||qqW|id|_|idotidn|id}|og|_g|_x|D]} t| t jo!dt| jo djnp tdnt| djo|ii| dqt| djo|ii| qqWn||||i|ig}x!|iD]}|i|iq W|S(N(RRRiRv(R*t filenamesR((s./sys/lib/python/distutils/command/build_ext.pytget_source_files}s  cCsh|i|ig}xK|iD]@}|i|i}|itii|i|i |q W|S(N( RRtget_ext_fullnameRTRSRQRURVRtget_ext_filename(R*toutputsRtfullname((s./sys/lib/python/distutils/command/build_ext.pyt get_outputss cCs5|i|ix|iD]}|i|qWdS(N(RRtbuild_extension(R*R((s./sys/lib/python/distutils/command/build_ext.pyRrs cCs|i}|djpt|ttfjotddd|int|}|i|i}|i out i |d}t i |dd!d}|d}|i d}|i|}tii ||i|} n"tii |i|i|} ||i} |ipt| | dptid |idSntid |i|i||}|ipg} |i} x!|iD]} | i| fqW|ii|d |i d | d |i!d|id| d|i}||_"|i#o|i$|i#n|i%pg} |i&p|ii'|}|ii(|| d|i)|d|i*d|i+d| d|i,|d|id|i d|dS(Ns*in 'ext_modules' option (extension '%s'), s&'sources' must be present and must be sa list of source filenamesR=iitbuild_pytnewers$skipping '%s' extension (up-to-date)sbuilding '%s' extensiont output_dirR{RRtextra_postargstdependsR"R#Rtexport_symbolsRt target_lang(-RvRRMR|RR}RTtlistRR RORPRVRhtget_package_dirRQRURRRRRRRtinfot swig_sourcesRxRRRSR&tcompileRRt_built_objectsRwRiRytlanguagetdetect_languagetlink_shared_objectt get_librariesR#Rtget_export_symbols(R*RRvRtmodpathRtbaseRt package_dirt ext_filenameRt extra_argsR{R!tobjectsR((s./sys/lib/python/distutils/command/build_ext.pyRsd &                  c Csg}g}h}|iotidn|ipd|ijo d}nd}xt|D]l}tii|\}} | djo4|i|d||i||d||WnxE|D]=}||} ti d || |i | d | |gq`W|S( sWalk 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-pythonsswigging %s to %ss-o( R(RRR)RQRUtsplitextRSR't find_swigRiRtspawn(R*Rvt extensiont new_sourcesRt swig_targetst target_exttsourceRRR'tswig_cmdtottarget((s./sys/lib/python/distutils/command/build_ext.pyRsB         cCstidjodSntidjoMxrd D]:}tiid|d}tii|o|Sq/q/WdSn)tid jodSntd tid S( sReturn the name of the SWIG executable. On Unix, this is just "swig" -- it should be in the PATH. Tries a bit harder on Windows. tposixR'R/s1.3s1.2s1.1s c:\swig%ssswig.exeR5s>I don't know how to find (much less run) SWIG on platform '%s'N(s1.3s1.2s1.1(RQRTRURVtisfiletDistutilsPlatformError(R*tverstfn((s./sys/lib/python/distutils/command/build_ext.pyR=s cCs+|idjo|Sn|id|SdS(NR=(RR(R*R((s./sys/lib/python/distutils/command/build_ext.pyR_scCsddkl}ti|d}tidjo*|t|dd |t|ds0