9Zc@`sdZddlmZmZmZddddgZddlZddlZddlZddl Z ye Wn!e k rddl m Z nXdd lmZdd lmZdd lmZdd lmZmZmZmZmZdd lmZmZddlmZmZddl m!Z!ddl"m#Z#m$Z$m%Z%m&Z&m'Z'ddl(m)Z)ddl*m+Z+ddl,m-Z-e.Z/de0fdYZ1dZ2dZ3dZ4defdYZ5ddddddd d!d"d#f fd$dddddd d!ffd%d d&d'd(dd)d*d+d,d#dd!d-f fd.d d)dd/d&dd!d(ffd0d1dd d!ffd2d3dd ffd4d/dd ffd5dd ffd6dd ffd7d dd(fff Z6e7a8e7a9d8Z:e7e7e;e7d9Z<e7e7d:Z=e7e7e;e7d;Z>e a?e7e7ddde;e7d<Z@e7d=ZAd>ZBejCd?ejDjEZFejCd@ejDjGZHejCdAejDjGZIejCdBejDjGZJejCdCejDjEZKdDZLdEZMejCdFejDZNdGZOePdHkreAndS(Isnumpy.distutils.fcompiler Contains FCompiler, an abstract base class that defines the interface for the numpy.distutils Fortran compiler abstraction model. Terminology: To be consistent, where the term 'executable' is used, it means the single file, like 'gcc', that is executed, and should be a string. In contrast, 'command' means the entire command line, like ['gcc', '-c', 'file.c'], and should be a list. But note that FCompiler.executables is actually a dictionary of commands. i(tdivisiontabsolute_importtprint_functiont FCompilert new_fcompilertshow_fcompilerstdummy_fortran_fileN(tSet(t open_latin1(tget_python_lib(t FancyGetopt(tDistutilsModuleErrortDistutilsExecErrort CompileErrort LinkErrortDistutilsPlatformError(t split_quotedt strtobool(t CCompilertgen_lib_options(tlog(t is_stringt all_stringst is_sequencetmake_temp_filetget_shared_lib_extension(tEnvironmentConfig(tfind_executable(t get_exceptiontCompilerNotFoundcB`seZRS((t__name__t __module__(((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyR0scC`st|rt|S|SdS(N(RR(ts((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytflaglist3s  cC`s t|rt|St|S(N(RRtbool(R ((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytstr2bool9s  cC`st|ot|S(N(RR(tseq((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytis_sequence_of_strings>sc(B`seZdZeddddddefddddefddddefddddefZeddddd ddddddddddddd Zeddd d!d"d#efd$d%d&d'efd(d)d*d+efd,d-ddefd.d/d0d.efd1d2ddefd3d4ddefd5d6d7d5efd8d9ddefd:d;ddefdd<d=d>efd?d@ddefdAdBddefdCdDdEdFefddGdHdIefddJdHdIefddKdLdMefZ id dN6d dO6d dP6d dQ6d dR6d$dS6d$dT6d$dU6Z d$d gZ dZ dZ dZgZid dVgd6d gd6d$gd 6d$dWgd6d$dXgd6d$gd6ddYgd6dd6ZdZdZZd[Zd[ZdZd\ZgZdOdQdRdNdSdUdPdTd]g Zd^ZeZd_Zd`ZdaZdbZiZ ddd dddddgZ!dZ"gZ#gZ$dcZ%ddZ&deZ'dfZ(e(dZ)e(dZ*e(d Z+e(dZ,e(dZ-e(dZ.e(dZ/e(dZ0dgZ1dhZ2diZ3djZ4dkZ5dlZ6dmZ7dnZ8doZ9dpZ:dqZ;drZ<dsZ=dtZ>duZ?dvZ@dwZAe?ZBZCe@ZDZEeAZFZGdxZHdyZIeJdzgd{ZKdd|ZLd}ZMd~ZNdZOdZPdZQddddddzddddd ZRdZSRS(s0Abstract base class to define the interface that must be implemented by real Fortran compiler classes. Methods that subclasses may redefine: update_executables(), find_executables(), get_version() get_flags(), get_flags_opt(), get_flags_arch(), get_flags_debug() get_flags_f77(), get_flags_opt_f77(), get_flags_arch_f77(), get_flags_debug_f77(), get_flags_f90(), get_flags_opt_f90(), get_flags_arch_f90(), get_flags_debug_f90(), get_flags_fix(), get_flags_linker_so() DON'T call these methods (except get_version) after constructing a compiler instance or inside any other method. All methods, except update_executables() and find_executables(), may call the get_version() method. After constructing a compiler instance, always call customize(dist=None) method that finalizes compiler construction and makes the following attributes available: compiler_f77 compiler_f90 compiler_fix linker_so archiver ranlib libraries library_dirs tdistutils_sectiont config_fctnoopttnoarchtdebugtverboset compiler_f77sexe.compiler_f77tF77tf77exect compiler_f90sexe.compiler_f90tF90tf90exect compiler_fixsexe.compiler_fixt version_cmdsexe.version_cmdt linker_sos exe.linker_sotLDSHAREDtldsharedt linker_exesexe.linker_exetLDtldtarchivertARtartranlibtRANLIBtf77s flags.f77tF77FLAGStf77flagstf90s flags.f90tF90FLAGStf90flagstfrees flags.freet FREEFLAGSt freeflagstfixs flags.fixtopts flags.opttFOPTtopt_f77s flags.opt_f77topt_f90s flags.opt_f90tarchs flags.archtFARCHtarch_f77sflags.arch_f77tarch_f90sflags.arch_f90s flags.debugtFDEBUGtfdebugt debug_f77sflags.debug_f77t debug_f90sflags.debug_f90tflagssself.get_flagstFFLAGStfflagssflags.linker_sotLDFLAGStldflagssflags.linker_exesflags.artARFLAGStarflagss.fs.fors.Fs.ftns.f77s.f90s.F90s.f95s-vs-fixeds-shareds-crs-cs-o s-Is.FORs.os.aslib%s%ss%s%stcO`stj||||jj|j|_|jj|j|_|jj|j|_|jj|_x0|j D]%}||jkrwd|j|" or "", the Fortran 77 or the Fortran 90 compiler executable is used, unless overridden by an environment setting. Subclasses should call this if overriden. c`s6|kr|St|}||<|<|S(N(R(texetfc_exe(t exe_cache(sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytcached_find_executable0s   c`s?|dk r;t| r;td||jjfndS(Ns"%s value %r is invalid in class %s(RfR%RRnR(tnameRy(Ri(sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytverify_command_form6sc `sjj|d}|sdStj|}|sM||gj}n|gj}t}g}xk|D]c}|dkr|}n|dkr|}n| ss||krqsn|j||j|qsWx.|D]&} | } | r| |d<| SqWj |ddS(Nssi( RctgetRftgetattrRatpossible_executablestsettaddtappendRx( texe_keyR?RBtcmdtexe_from_environt possiblestseentunique_possiblesRlRR(RRi(sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytset_exe;s2          R/R,s %s: no Fortran 90 compiler founds%s: f90 nor f77RBs %s: no Fortran 77 compiler foundR2R4R?R7R3R:R=N(RhRst _exe_cacheRft compiler_typeRtwarnR(RiRRtctypeRBR?((RRRisU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytfind_executables s*     cC`sdS(sqCalled at the beginning of customisation. Subclasses should override this if they need to set up the executables dictionary. Note that self.find_executables() is run afterwards, so the self.executables dictionary values can contain or as the command, which will be replaced by the found F77 or F90 compiler. N((telf((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytupdate_executablesos cC`s g|jS(s+List of flags common to all compiler types.(t pic_flags(Ri((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyt get_flagszscC`s-|jj|d}|dkr%gS|dS(Ni(RcRRf(RiRtR((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyt_get_command_flags~s cC`s |jdS(s"List of Fortran 77 specific flags.R,(R(Ri((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyt get_flags_f77scC`s |jdS(s"List of Fortran 90 specific flags.R/(R(Ri((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyt get_flags_f90scC`sgS(s.List of Fortran 90 free format specific flags.((Ri((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytget_flags_freescC`s |jdS(s/List of Fortran 90 fixed format specific flags.R2(R(Ri((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyt get_flags_fixscC`s |jdS(s/List of linker flags to build a shared library.R4(R(Ri((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytget_flags_linker_soscC`s |jdS(s,List of linker flags to build an executable.R7(R(Ri((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytget_flags_linker_exescC`s |jdS(sList of archiver flags. R:(R(Ri((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyt get_flags_arscC`sgS(s0List of architecture independent compiler flags.((Ri((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyt get_flags_optscC`sgS(s.List of architecture dependent compiler flags.((Ri((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytget_flags_archscC`sgS(s=List of compiler flags to compile with debugging information.((Ri((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytget_flags_debugscC`s|jS(sList of compiler libraries.(t libraries(Ri((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyt get_librariesscC`s|jS(s%List of compiler library directories.(t library_dirs(Ri((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytget_library_dirssicC`sF|jsttj|d|d|}|dkrBtn|S(Ntforcet ok_status(RhRsRt get_versionRfR(RiRRtversion((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyRs   c`s_tjdjjt_jj|jj|j j|j j jj dt }jj d|}jj dt }jjjjggg}grj jnr j jj j}njjr.j jnggg}}}fd} |s| d||s| d|qn|r| d|nj j|||} rjdg| nr jd g|| nr-jd g| nj} | rj j} tjjd rtd d } tjj| dd}tjj| dd}|g| d|g} njd| | nj}|rj j}jd||njj }|r5j j!}jd|g|nj"j#j$j%dS(sCustomize Fortran compiler. This method gets Fortran compiler specific information from (i) class definition, (ii) environment, (iii) distutils config files, and (iv) command line (later overrides earlier). This method should be always called after constructing a compiler instance. But not in __init__ because Distribution instance is needed for (iii) and (iv). s customize %sR(R)R*c`s|jtj|td|}xdfdfdfgD]Z\}}}d||f}|rW|td|k rW|jtj|qWqWWdS(Nt get_flags_R?RBs%s_%s(textendRRb(ttagRUtthis_getRtctflagvartt(R?RARBRDRHtfixflagsRi(sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyRs RIRMR,R/R2taixt standard_libitconfigt ld_so_aixs python.exps-bI:R4R7R:N(&RtinfoRnRtTrueRhR^tuse_distributionRaRbRRRRgR,R/R?RBRER2RHRUR~R4tsystplatformt startswithR tostpathtjoinR7R:R<tset_library_dirsRt set_librariesR(RitdistR(R)R*RGtoflagstaflagstdflagsRRWR4tlinker_so_flagst python_libRt python_expR7tlinker_exe_flagsR<R[((R?RARBRDRHRRisU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyt customizest        !  "      cC`sg}xqt|jjdddddgD]G}t||r/t||}|j|d dt|fq/q/W|jt |}xL|j d|j j D]1}|d d krd |d}nt |qWd S( s0Print out the attributes of a compiler instance.RRRt object_switchtcompile_switchs= s%s instance properties:is --s N(tlistRctkeysthasattrRRRftreprtsortR t generate_helpRnRtprint(RitpropsRtR}tpretty_printertl((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytdump_propertiess '   cC`sCi}t|rLt| rLd}|j} t|}|jpFg} nt|rd}|j} | dkrtd|j j |fn|j pg} nId}|j } | dkrtd|j j |fn|j pg} |j ddkr|j j|g} n|j j|g} |jjsCt|j|g} | rtjd|d dj| fn|j|jg} | rtjd dj| n| || | | || }d tjj| d ||f}y|j|d |Wn,tk r>tt}t|nXdS(sCompile 'src' to product 'obj'.s:f77s:f90s%f90 not supported by %s needed for %ss:fixs-f90 (fixed) not supported by %s needed for %sit sextra %s options: %ris%using compile options from source: %rs%s: %sitdisplayN(t is_f_filethas_f90_headerR,t get_f77flagstextra_f77_compile_argstis_free_formatR/RfR RnRtextra_f90_compile_argsR2RtstripRRsRRRRRRRtbasenametspawntstrRR (RiRqtsrctexttcc_argstextra_postargstpp_optst src_flagstflavortcompilertextra_compile_argsto_argsts_argst extra_flagstcommandRtmsg((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyt_compile2sN           cC`sg}|jdk rd|jddkrG|j|jj|gq|j|jj|n!td|td|jj|jdk rxS|g|D] }|jd|j|fqWn!td|td|jj|S(NiRs'XXX: module_build_dir=%r option ignoredsXXX: Fix module_dir_switch for s%s%ss"XXX: module_dirs=%r option ignoreds#XXX: Fix module_include_switch for ( tmodule_dir_switchRfRRRRRnRtmodule_include_switch(Rit module_dirstmodule_build_dirtoptionstd((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytmodule_optionsds!cC`sd|S(Ns-l((Ritlib((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytlibrary_optionvscC`sd|S(Ns-L((Ritdir((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytlibrary_dir_optionxscC`s|j||\}}|j|||\}}}t||||}t|rotjj||}n|dk rtdn|j ||r|j ddkr|j j |g}n|j j |g}t|j r||j g}n ||j }|||}| r0dg|d*n| rC| |d*n| rY|j | n|jtjj||tjkr|j}n |j}||}y|j|Wqtk rtt}t|qXntjd|dS(Ns%'output_dir' must be a string or NoneiRs-gisskipping %s (up-to-date)(t_fix_object_argst _fix_lib_argsRRRRRRft TypeErrort _need_linktlibrary_switchRtobjectsRtmkpathtdirnameRt EXECUTABLER7R4RR RRRRR*(Rit target_descRtoutput_filenamet output_dirRRtruntime_library_dirstexport_symbolsR*t extra_preargsRt build_tempt target_langtlib_optsRtld_argstlinkerRR((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pytlink{sB          cC`s|dkrdSt|r|jdrK|d}t||}|S|jdr|d}|j|}|r|dSdSq|jdr|d}t|d|}|Sn|SdS( Nsself.isexe.iisflags.iR(RfRRRRc(RiRt hook_namethooktvar((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyR`s$       N(sexe.compiler_f77R-R.N(sexe.compiler_f90R0R1N(sexe.compiler_fixR0R1N(sexe.version_cmdNNN(s exe.linker_soR5R6N(sexe.linker_exeR8R9N(NR;R<N(NR>R=N((TRRt__doc__RRfR#R^RaR!Rbt language_maptlanguage_orderRtcompiler_aliasestversion_patternRRctsuggested_f90_compilerRRRRRRtsrc_extensionst obj_extensionRtshared_lib_extensiontstatic_lib_extensiontstatic_lib_formattshared_lib_formatt exe_extensionRRet c_compilerRRR]RrRdRwR3R,R/R2R4R7R:R=RzR~RxRRRRRRRRRRRRRRtget_flags_opt_f77tget_flags_opt_f90tget_flags_arch_f77tget_flags_arch_f90tget_flags_debug_f77tget_flags_debug_f90RRRgRRRRRRRRR`(((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyRAs             !                   O                  e  2    +twin32tgnutintelvtabsofttcompaqvtintelevtgnu95tg95tintelvemtintelemscygwin.*slinux.*tinteltlaheytpgtnagtvasttcompaqtinteletpathf95sdarwin.*tibmssunos.*tsunsirix.*tmipssaix.*tposixtnttmacc C`sXddlm}tdk r dStjjtjjtd}iaiax||D]}tjj tjj |\}}d|}t |t j |}t|drZx|jD]}t||}|j||jf}|t|jFor compiler details, run 'config_fc --verbose' setup command.N((Rftdistutils.distRnt'numpy.distutils.command.config_compilerR'RRRRtargvt script_namet script_argstremoveRtcmdclasstparse_config_filestparse_command_lineRHRWRgRt set_verbosityRR+RRR RRR*RRRRRRRR t print_helpR( RRnR'RGt compilers_nat compilers_nitplatform_compilersRR}RRltfcR((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyR]sd              "+        cC`s4tdd\}}|jd|j|d S(Ntsuffixs.fs# subroutine dummy() end i(Rtwritetclose(tfoR((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyRs  s.*[.](for|ftn|f77|f)\Zs-[*]-\s*fortran\s*-[*]-s-[*]-\s*f90\s*-[*]-s-[*]-\s*fix\s*-[*]-s[^c*!]\s*[^\s\d\t]cC`sd}t|d}|j}d}t|r<d}nt|rWd}d}nx|dkr|r|j}|r|ddkr|d8}|ddkrt|d s|dd krd}Pqn|j}qZW|j|S( s(Check if file is in free format Fortran.itri'it!s iit&(Rtreadlinet _has_f_headert_has_f90_headertrstript_free_f90_startR(tfiletresulttftlinetn((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyRs&       0 cC`s;t|d}|j}|jt|p:t|S(NR(RRRRt_has_fix_header(RRR((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyRs  s=(c|)f77flags\s*\(\s*(?P\w+)\s*\)\s*=\s*(?P.*)cC`si}t|d}d}x}|D]u}|d7}|dkrBPntj|}|s]q"n|jdj}|jdj}t|||)=` Return a dictionary {:}. RiiitfcnameRW(Rt _f77flags_reRctgroupRRR(RRURtiRtmRRW((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyRs    t__main__(QRt __future__RRRt__all__RRRbttypesRt NameErrortsetsRt numpy.compatRtdistutils.sysconfigR tdistutils.fancy_getoptR tdistutils.errorsR R R RRtdistutils.utilRRtnumpy.distutils.ccompilerRRtnumpy.distutilsRtnumpy.distutils.misc_utilRRRRRtnumpy.distutils.environmentRtnumpy.distutils.exec_commandRtnumpy.distutils.compatRttypet __metaclass__t ExceptionRR!R#R%RRaRfRHRJRWRgR`RgRhRkRRRtcompiletIRcRtsearchRRRRRRRRR(((sU/opt/alt/python27/lib64/python2.7/site-packages/numpy/distutils/fcompiler/__init__.pyts       ((    !  "   ! =