[Kc@sdZddlZddlZddlZddlZddlZddlmZddlm Z m Z ddl m Z ddl mZmZdZddlmZdd lmZmZmZmZmZdd lmZdd lmZd Zd ejfd YZej dej!j"Z#ej dej!j"Z$ej dej!j"Z%ej dej!j&Z'ej dej!j&Z(dZ)dZ*dZ+ej dej!j"Z,ej dej!j"Z-dZ.dS(s" Build swig, f2py, pyrex sources. iN(t build_ext(t newer_grouptnewer(t get_platform(tDistutilsErrortDistutilsSetupErrorcCs-yddl}tSWntk r(tSXdS(Ni(tPyrex.Compiler.MaintTruet ImportErrortFalse(tPyrex((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyt have_pyrexs   (tlog(tfortran_ext_matcht appendpatht is_stringt is_sequencetget_cmd(t process_filecCstjd}t|d}zt|d}zsxl|jD]^}|j|}|r|j|jd|jd||jdq@|j|q@WWd|jXWd|jXdS(sOSubstitute any occurence of @foo@ by d['foo'] from source file into target.s@([a-zA-Z_]+)@trtws@%s@iN( tretcompiletopent readlinestsearchtwritetreplacetgrouptclose(ttargettsourcetdtvartfstfttltm((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyt subst_varss6t build_srcc BseZdZd*d,d-d.d/d0d1d2ddddfg ZddgZgZdZdZdZ dZ dZ dZ dZ dZdZd Zd!Zd"Zd#Zgd$Zd%Zd&Zd'Zd(Zd)ZRS(3s1build sources from SWIG, F2PY files or a functions build-src=R sdirectory to "build" sources tos f2py-opts=s!list of f2py command line optionssswig=spath to the SWIG executables swig-opts=s!list of SWIG command line optionssswig-cppsAmake SWIG create C++ files (default is autodetected from sources)s f2pyflags=s3additional flags to f2py (use --f2py-opts= instead)s swigflags=s3additional flags to swig (use --swig-opts= instead)tforcetfs2forcibly build everything (ignore file timestamps)tinplacetis=ignore build-lib and put compiled extensions into the source s,directory alongside your pure Python modulescCsd|_d|_d|_d|_d|_d|_d|_d|_d|_ d|_ d|_ d|_ d|_ d|_d|_d|_dS(N(tNonet extensionstpackaget py_modulestpy_modules_dictR't build_libt build_baseR(R*t package_dirt f2pyflagst f2py_optst swigflagst swig_optstswig_cpptswig(tself((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pytinitialize_optionsHs                cCs|jdddd|jdkr7|jj|_n|jj|_|jjpUg|_|jjpjg|_|jj pg|_ |j dkrdt t j dd!f}tjj|jd||_ ni|_|jr|jrtjd n |j|_d|_n|jdkr1g|_ntj|j|_|jr|jrhtjd n |j|_d|_n|jdkrg|_ntj|j|_|jd }|jdkr|j|_n|jdkr|j|_nxd d gD]}d|jdd}t||d}|rt||r_tjd|qtj d||ft!|||qqWdS(NtbuildR2R1R(s.%s-%siitsrcs0ignoring --f2pyflags as --f2py-opts already useds0ignoring --swigflags as --swig-opts already usedRR9tswig_opts--t_t-s-both build_src and build_ext define %s options+using "%s=%s" option from build_ext command(s build_bases build_base(s build_libs build_lib(sforcesforce("tset_undefined_optionsR.R,t distributiont ext_packaget ext_modulesR-t librariesR/t data_filesR'RtsystversiontostpathtjoinR2R0R4R5R twarntshlextsplitR6R7tget_finalized_commandR*R8Rtgetattrtinfotsetattr(R:tplat_specifierRtctotv((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pytfinalize_optionsZsV "           cCs1tjd|jp|js#dS|jdS(NR'(R RQR-REt build_sources(R:((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pytruns cCs|jr!|jdj|_n|jx|jD]}|j|q5W|jr|j|jx!|jD]}|j|qoWn|j |j dS(Ntbuild_py( R*ROtget_package_dirtbuild_py_modules_sourcesREtbuild_library_sourcesR-tcheck_extensions_listtbuild_extension_sourcestbuild_data_files_sourcestbuild_npy_pkg_config(R:t libname_infotext((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyRXs    c Cs|js dStjdddlm}g}x|jD]}}t|tr_|j|q:t|tr|\}}|j r|j dj |j t j}nt jj |j|}tt|}td|}x|D]}|jjdkr||} n |} | dk rt| trE|j| qyt| trd|j| qytt| qqW|||f} |j|| fq:tt|q:W||j(dS(Nsbuilding data_files sourcesi(tget_data_filest.cSs t| S(N(tcallable(R)((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pytsi(RFR RQtnumpy.distutils.misc_utilRdt isinstancetstrtappendttupleR*R[RKRNRItsepRJR'tfilterRft func_codet co_argcountR,tlisttextendt TypeErrortrepr( R:Rdtnew_data_filestdataR tfilest build_dirtfuncsR)tst filenames((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyR`s:    '   cCsddl}|\}}}tjj|}x$|jD]\}} | |||jnt}i}|jdkrhd}t}n!t |dr|j }t}n|r8x|j j j D]\}}|j j|}tjjtjj||}i|d6} xB|D]:} |j| | \} } |j jj| | gfqWqWndS(Ns(build_src: building npy-pkg config filestinstalliRetinstall_libbasetprefix(R RQtcopyRt finalizedRWR R*RthasattrRRBtinstalled_pkg_configR~R3RIRJRKtabspathRRFRk( R:t install_cmdt build_npkgRt top_prefixtpkgtinfostpkg_pathRR RQRR((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyRas*     !  cCsQ|js dStjdg}x |jD]}t|r2t|dkr2|\}}}|jrx|j|}n-tjj |j tjj |j d}t |rtjj ||d}||}n|dkrq*n|||fg}||jkrg|j|}tjjtjj|d} |j|| |fqW|j|c|7<|j|\}} | rtjd|| n||_dS(Nsbuilding extension "%s" sourcesReiis#%s - nothing done with h_files = %s(RqRR RQtnametget_ext_fullnameRNRKR*R[text_target_dirRRt swig_sourcest f2py_sourcest pyrex_sourcestfilter_py_filesR0RIRJRRRkR( R:RcRtfullnametmodpathR.tpy_filesRR)tmoduleR((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyR_:s2  "  c Cs^g}g}x7|D]/}t|r5|j|q|j|qW|sP|S|jrrt| rr|j}nKt|r|d}n |j}tjj|j g|j dd }|j |x|D]}|||}|sqnt|r5g|D]} t j d| f^q|j|qt j d|f|j|qW|S(NiReis adding '%s' to sources.(RRkR*RRRRIRJRKR'RNtmkpathR RQRr( R:Rt extensiont new_sourcest func_sourcesRRxRtfuncRz((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyRfs4         'cCs|j|dgS(Ns.py(t filter_files(R:R((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyRscCs|j|dddgS(Ns.hs.hpps.inc(R(R:R((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyRscCshg}g}xO|D]G}tjj|\}}||krM|j|q|j|qW||fS(N(RIRJRRk(R:RtextsRRwRtbaseRc((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyRs  cCsg}t|r;|djd}|djd}n|j}|j}x|D]}tjj|\}}|dkr|jrtjj|} nt |j tjj|} |j | tjj | tjj |} |jst|g|| ryt|r3tjd| t|} ntjd| t|} t| d} | j| | jnt| rtjj| } | |krtjd| |j| qn|j| qT|j|qTW|S( Nitdependst include_dirss.srcsfrom_template:> %ssconv_template:> %sRs adding '%s' to include_dirs.(RRRRRIRJRR*R}RR'RRKRR(Rt_f_pyf_ext_matchR RQtprocess_f_filetprocess_c_fileRRRt_header_ext_matchRk(R:RRRRRRRRct target_dirt target_filetoutstrtfidR ((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyRs>       !      c Csg}|jjdd}xg|D]_}tjj|\}}|dkru|j||||}|j|q#|j|q#W|S(NReis.pyx(RRNRIRJRtgenerate_a_pyrex_sourceRk( R:RRRtext_nameRRRcR((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyRs    c Csy|jst r(tjj|}nt|jtjj|}tjj||d}|g|j}|j st ||drutr3ddl }t j d||j||jjjd|jjjd|jd|} |jjj|d| } | jd krrtd | j|fqrqutjj|r_t jd ||fqutd |fn|S( Ns.cRis pyrexc:> %stdefaultst include_patht output_filetoptionsis'%d errors while compiling %r with PyrexsFPyrex required for compiling %r but not available, using old target %rs0Pyrex required for compiling %r but notavailable(R*R RIRJR}RR'RKRR(RRR RQRtCompilertMaintCompilationOptionstdefault_optionsRRt num_errorsRtisfileRL( R:RRRRRRRR Rt pyrex_result((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyRs2       cCsg}g}g}i}g}|jjdd}d} x|D]} tjj| \} } | dkr|jrtjj| } nt|jtjj| } tjj | r t | }||krt d| ||fntjj | |d}nt jd| |}d} tjj | |d}tjj |st jd ||ftjj| } tjj | |d}tjj |st d |fnt jd |n|j| |j| ||| <|j|qAt| r|j| qA|j| qAW|p9|s@|Sx|D]}|j|qGW|j|j}|jjrxH|jjD]7\}}||jkr|j|jd gqqWnt jd ||rt|dkrt d|fn|d} || }tjj|p-d} | g|j}|js[t||dr| rt jd| ddl}|jj |d| | gqt jd| n t!|r|d}n |j}tjj |jg|jdd } tjj | |d}|j|||j}|jsLt||dr| rt jd||j| ddl}|jj |dd| gd|g|nt jd|tjj |st"d|fntjj |jd}tjj |jd}t jd||j||j|j#krnt jd|j|j#j|jn| s%ddl}tjj|jj$}tjj |dd}tjj |dd}t%||st%||ru|jtjj||j&|||j&||qunPtjj |sMt d|fntjj |sut d|fnx`dd gD]R}tjj | ||}tjj |rt jd||j|qqW||S(!NReiis.pyfs;mismatch of extension names: %s provides %r but expected %rsmodule.cs. source %s does not exist: skipping f2py'ing.isd target %s does not exist: Assuming %smodule.c was generated with "build_src --inplace" command.s %r missings& Yes! Using %r as up-to-date target.t f2py_optionssf2py options: %ssConly one .pyf file is allowed per extension module but got more: %rRsf2py: %ss --build-dirs+ skipping '%s' f2py interface (up-to-date)s f2py:> %ss--lowers-ms3 skipping f2py fortran files for '%s' (up-to-date)s!f2py target file %r not generatedsfortranobject.csfortranobject.hs adding '%s' to sources.s adding '%s' to include_dirs.R=sf2py target_c file %r not foundsf2py target_h file %r not founds-f2pywrappers.fs-f2pywrappers2.f90('RRNRIRJRR*R}RR'Rtget_f2py_modulenameRRKR tdebugRLRQRkR RRR5RBRERrRRRR(Rt numpy.f2pytf2pytrun_mainRRRt__file__Rt copy_file(R:RRRRt f_sourcest f2py_targetst target_dirsRt skip_f2pyRRRcRRRR RRRtnumpyttarget_cttarget_htsource_ctsource_htname_exttfilename((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyRs                #            %     cCsag}g}i}g}g}d}|jr<d} t} n d} t} d} |jjdd} x|D]} tjj| \}}|dkr|j rtjj |}|j }n$t |j tjj |}|}tjj| rt| }|| dkr.td| || dfn| dkrdt| } | dk} | rd }qnnt| }| |krtjd | | |f|dkrtjd t} d }qtjd | ntjj|d ||f}ntjd| | d}d} t||}tjj|stjd||ftjj |}t||}tjj|std|fntjd|n|j||j||jtjj||d|j| |d|| [\w_]+)".*\)|)\s*(?P[\w_]+)s-[*]-\s*c\s*-[*]-s-[*]-\s*c[+][+]\s*-[*]-cCsYt|d}d}|j}t|r6d}nt|rKd}n|j|S(NRRTsc++(Rtreadlinet_has_cpp_headert _has_c_headerR(RR)tresulttline((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyRs      cCsqt|d}t|d|j}d}x6|D]+}t|}|r4|jd}Pq4q4W|j|S(NRt xreadlinesR(RRPRR,t_swig_module_name_matchRR(RR)t f_readlinesRRR%((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyRs  cCsPxIddgD];}tjj|d||f}tjj|r Pq q W|S(Ns.cpps.cs %s_wrap%s(RIRJRKR(RRRcR((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyRs s%\s*python\s*module\s*(?P[\w_]+)s4\s*python\s*module\s*(?P[\w_]*?__user__[\w_]*)cCsd}t|}t|d|j}xH|D]=}t|}|r1t|r[q1n|jd}Pq1q1W|j|S(NRR(R,RRPRt_f2py_module_name_matcht_f2py_user_module_name_matchRR(RRR)RRR%((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyRs    (/t__doc__RIRRGRMRtdistutils.commandRtdistutils.dep_utilRRtdistutils.utilRtdistutils.errorsRRR tnumpy.distutilsR RhR RRRRtnumpy.distutils.from_templateRRtnumpy.distutils.conv_templateRR&R'RtItmatchRRRRRRRRRRRR(((sE/usr/lib/python2.7/site-packages/numpy/distutils/command/build_src.pyts@      (