2[c@`sdZddlmZmZmZddlZddlZddlZddlZddl Z ddl m Z ddl m Z mZddlmZddlmZmZddlmZdd lmZmZmZmZmZdd lmZdd lmZ d Z!d e j fd YZ"ej#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%Z0dZ1dS(s Build swig and f2py sources. i(tdivisiontabsolute_importtprint_functionN(t build_ext(t newer_grouptnewer(t get_platform(tDistutilsErrortDistutilsSetupError(tlog(tfortran_ext_matcht appendpatht is_stringt is_sequencetget_cmd(t process_filecC`stjd}t|d}zt|d}zmxf|D]^}|j|}|r|j|jd|jd||jdq:|j|q:WWd|jXWd|jXdS(sPSubstitute any occurrence of @foo@ by d['foo'] from source file into target.s@([a-zA-Z_]+)@trtws@%s@iN(tretcompiletopentsearchtwritetreplacetgrouptclose(ttargettsourcetdtvartfstfttltm((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyt subst_varss 6t build_srcc B`seZdZd*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=Rsdirectory 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 modulescC`sd|_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((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pytinitialize_optionsDs                cC`s|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(NtbuildR.R-R$s.%s-%siitsrcs0ignoring --f2pyflags as --f2py-opts already useds0ignoring --swigflags as --swig-opts already usedRR5tswig_opts--t_t-s-both build_src and build_ext define %s options+using "%s=%s" option from build_ext command(R.R.(R-R-(R$R$("tset_undefined_optionsR*R(t distributiont ext_packaget ext_modulesR)t librariesR+t data_filesR#RtsystversiontostpathtjoinR.R,R0R1R twarntshlextsplitR2R3tget_finalized_commandR&R4Rtgetattrtinfotsetattr(R6tplat_specifierRtctotv((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pytfinalize_optionsVsV "           cC`s1tjd|jp|js#dS|jdS(NR#(R RMR)RAt build_sources(R6((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pytruns cC`s|jr!|jdj|_n|jx|jD]}|j|q5W|jr|j|jx!|jD]}|j|qoWn|j |j dS(Ntbuild_py( R&RKtget_package_dirtbuild_py_modules_sourcesRAtbuild_library_sourcesR)tcheck_extensions_listtbuild_extension_sourcestbuild_data_files_sourcestbuild_npy_pkg_config(R6t libname_infotext((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyRTs    c C`s|js dStjdddlm}g}x|jD]}t|tr_|j|q:t|tr|\}}|j r|j dj |j t j}nt jj |j|}g|D]}t|dr|^q}g|D]}t|ds|^q}x|D]}|jjdkr@||} n |} | dk rt| trt|j| qt| tr|j| qtt| qqW|||f} |j|| fq:tt|q:W||j(dS(Nsbuilding data_files sourcesi(tget_data_filest.t__call__i(RBR RMtnumpy.distutils.misc_utilR`t isinstancetstrtappendttupleR&RWRGRJREtsepRFR#thasattrt__code__t co_argcountR(tlisttextendt TypeErrortrepr( R6R`tnew_data_filestdataRtfilest build_dirR%tfuncstst filenames((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyR\s:    '((   cC`sddl}|\}}}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 filestinstalliRatinstall_libbasetprefix(R RMtcopyRt finalizedRStFalseR&tTrueRiRR>tinstalled_pkg_configRyR/RERFRGtabspathRRBRf( R6t install_cmdt build_npkgR~t top_prefixtpkgtinfostpkg_pathRRRMRR((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyR]s*     !  cC`sT|js dStjdg}x#|jD]}t|r5t|dkr5|\}}}|jrx|j|}n-tjj |j tjj |j d}t |drtjj ||d}||}n|dkrq*n|||fg}||jkrg|j|}tjjtjj|d} |j|| |fqW|j|c|7<|j|\}} | rtjd|| n||_dS(Nsbuilding extension "%s" sourcesRaiis#%s - nothing done with h_files = %s(RlRR RMtnametget_ext_fullnameRJRGR&RWtext_target_dirRRt swig_sourcest f2py_sourcest pyrex_sourcestfilter_py_filesR,RERFR{RzRfR( R6R_RtfullnametmodpathR*tpy_filesRR%tmoduleR((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyR[6s2  "  c C`s^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(NiRais adding '%s' to sources.(R RfR&R RRRERFRGR#RJtmkpathR RMRm( R6Rt extensiont new_sourcest func_sourcesRRsRtfuncRu((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyR^s4         'cC`s|j|dgS(Ns.py(t filter_files(R6R((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyRscC`s|j|dddgS(Ns.hs.hpps.inc(R(R6R((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyRscC`shg}g}xO|D]G}tjj|\}}||krM|j|q|j|qW||fS(N(RERFR{Rf(R6RtextsRRrRtbaseR_((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyRs  cC`sg}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.(R RRRRERFR{R&RxR R#RRGRzR$Rt_f_pyf_ext_matchR RMtprocess_f_filetprocess_c_fileRRRt_header_ext_matchRf(R6RRRRRRRR_t target_dirt target_filetoutstrtfidR((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyRs>       !      c C`sg}|jjdd}xg|D]_}tjj|\}}|dkru|j||||}|j|q#|j|q#W|S(s@Pyrex not supported; this remains for Cython support (see below)Rais.pyx(RRJRERFR{tgenerate_a_pyrex_sourceRf( R6RRRtext_nameRRR_R((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyRs    cC`sgS(sPyrex is not supported, but some projects monkeypatch this method. That allows compiling Cython code, see gh-6955. This method will remain here for compatibility reasons. ((R6RRRR((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyRscC`sg}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 |j| }tjj |d}tjj |d}t jd||j|||j#krwt jd||j#j|n| s.ddl}tjj|jj$}tjj |dd}tjj |dd}t%||st%||r~|jtjj||j&|||j&||q~nPtjj |sVt d|fntjj |s~t d|fnx`dd gD]R}tjj | ||}tjj |rt jd||j|qqW||S(!NRaiis.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.R9sf2py target_c file %r not foundsf2py target_h file %r not founds-f2pywrappers.fs-f2pywrappers2.f90('RRJRERFR{R&RxR R#tisfiletget_f2py_modulenameRRGR tdebugRHRMRfR RRR1R>RARmRRRR$Rt numpy.f2pytf2pytrun_mainR RRt__file__Rt copy_file(R6RRRRt f_sourcest f2py_targetst target_dirsRt skip_f2pyRRR_RRRRRRRtnumpyRsttarget_cttarget_htsource_ctsource_htname_exttfilename((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyRs                #            %   cC`sg}g}i}g}g}d}d|jkrRd} t} |jjdn$|jrjd} t} n d} t} d} |jjdd} x|D]} tj j | \}}|dkrP|j rtj j |}|j }n$t|jtj j |}|}tj j| rBt| }|| dkr\td | || dfn| dkrt| } | dk} nt| }|dkrtjd | | fn\| |krtjd | | |f|dkrtjd t} qtjd | n| r d}ntj j|d||f}ntjd| | d}d} t||}tj j|stjd||ftj j |}t||}tj j|std|fntjd|n|j||j||jtj j||d|j| |d|| source %r does not define swig target, assuming %s swig targets0expected %r but source %r defines %r swig targetsAresetting swig target to c++ (some targets may have .c extension)s$assuming that %r has c++ swig targets.cpps %s_wrap%ss. source %s does not exist: skipping swig'ing.si target %s does not exist: Assuming %s_wrap.{c,cpp} was generated with "build_src --inplace" command.s %r missings& Yes! Using %r as up-to-date target.s.pys-pythons-IRs%s: %ss++ts-os-outdirs+ skipping '%s' swig interface (up-to-date)($R3RtremoveR4R(RRRJRERFR{R&RxRR R#Rtget_swig_modulenameRtget_swig_targetR RHRGt_find_swig_targetRfRR5t find_swigRRR$RRMRztspawnR(R6RRRRt swig_targetsRRt target_extttyptis_cppt skip_swigRRRR_Rt py_target_dirRttyp2RRR5tswig_cmdRR((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyR\s                              $  (s build-src=Rsdirectory to "build" sources toN(s f2py-opts=Ns!list of f2py command line options(sswig=Nspath to the SWIG executable(s swig-opts=Ns!list of SWIG command line options(sswig-cppNsAmake SWIG create C++ files (default is autodetected from sources)(s f2pyflags=Ns3additional flags to f2py (use --f2py-opts= instead)(s swigflags=Ns3additional flags to swig (use --swig-opts= instead)(R$R%s2forcibly build everything (ignore file timestamps)(t__name__t __module__t descriptionR(t user_optionstboolean_optionst help_optionsR7RSRURTR\RR]RXRYR[RRRRRRRRR(((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyR#.sB    :   $     ( '   %   s".*[.](f90|f95|f77|for|ftn|f|pyf)\Zs.*[.](inc|h|hpp)\ZsQ\s*%module\s*(.*\(\s*package\s*=\s*"(?P[\w_]+)".*\)|)\s*(?P[\w_]+)s-[*]-\s*c\s*-[*]-s-[*]-\s*c[+][+]\s*-[*]-cC`sYt|d}d}|j}t|r6d}nt|rKd}n|j|S(NRsc++RP(RR(treadlinet_has_cpp_headert _has_c_headerR(RR%tresulttline((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyRs      cC`sYt|d}d}x3|D]+}t|}|r|jd}PqqW|j|S(NRR(RR(t_swig_module_name_matchRR(RR%RRR!((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyRs   cC`sPxIddgD];}tjj|d||f}tjj|r Pq q W|S(Ns.cpps.cs %s_wrap%s(RERFRGR(RRR_R((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyRs s%\s*python\s*module\s*(?P[\w_]+)s4\s*python\s*module\s*(?P[\w_]*?__user__[\w_]*)cC`shd}t|}xE|D]=}t|}|rt|rCqn|jd}PqqW|j|S(NR(R(Rt_f2py_module_name_matcht_f2py_user_module_name_matchRR(RRR%RR!((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyRs     (2t__doc__t __future__RRRRERRCRIRtdistutils.commandRtdistutils.dep_utilRRtdistutils.utilRtdistutils.errorsRRtnumpy.distutilsR RcR R R R Rtnumpy.distutils.from_templateRRtnumpy.distutils.conv_templateRR"R#RtItmatchRRRRRRRRRRRR(((s@/tmp/pip-build-fiC0ax/numpy/numpy/distutils/command/build_src.pyts@     (