2[c@`sdZddlmZmZmZddddgZddlZddlZddlZddl Z ddl m Z dd l m Z dd lmZdd lmZmZmZmZmZdd lmZmZdd lmZmZddlmZddlmZm Z m!Z!m"Z"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)e*Z+de,fdYZ-dZ.dZ/dZ0defdYZ1dddddddd d!d"d#f fd$ddddddd ffd%dd&d'd(dd)d*d+d,d"dd d-d.ffd/dd)dd0d&dd d(ffd1d2ddd ffd3d4ddffd5d0ddffd6ddffd7ddffd8ddd(fff Z2e3a4e3a5d9Z6e3e3e7e3d:Z8e3e3d;Z9e3e3e7e3d<Z:e;a<e3e3ddde7e3d=Z=e3d>Z>d?Z?ej@d@ejAjBZCej@dAejAjDZEej@dBejAjDZFej@dCejAjDZGej@dDejAjBZHdEZIdFZJej@dGejAZKdHZLeMdIkre>ndS(Jsnumpy.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(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__(((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyR,scC`st|rt|S|SdS(N(RR(ts((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytflaglist/s  cC`s t|rt|St|S(N(RRtbool(R((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytstr2bool5s  cC`st|ot|S(N(RR(tseq((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytis_sequence_of_strings:sc(B`s(eZdZeddddddefddddefddddefddddefZeddddd 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 ZRdZSdZTdZURS(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 overridden. c`s6|kr|St|}||<|<|S(N(R(texetfc_exe(t exe_cache(sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytcached_find_executable,s   c`s?|dk r;t| r;td||jjfndS(Ns"%s value %r is invalid in class %s(ReR$R~RmR(tnameRx(Rh(sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytverify_command_form2sc `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( RbtgetRetgetattrR`tpossible_executablestsettaddtappendRw( texe_keyR>RAtcmdtexe_from_environt possiblestseentunique_possiblesRkRR(RRh(sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytset_exe7s2          R.R+s %s: no Fortran 90 compiler founds%s: f90 nor f77RAs %s: no Fortran 77 compiler foundR1R3R>R6R2R9R<N(RgRrt _exe_cacheRet compiler_typeRtwarnR(RhRRtctypeRAR>((RRRhsA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytfind_executabless*     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((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytupdate_executablesks cC`s g|jS(s+List of flags common to all compiler types.(t pic_flags(Rh((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyt get_flagsvscC`s-|jj|d}|dkr%gS|dS(Ni(RbRRe(RhRsR((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyt_get_command_flagszs cC`s |jdS(s"List of Fortran 77 specific flags.R+(R(Rh((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyt get_flags_f77scC`s |jdS(s"List of Fortran 90 specific flags.R.(R(Rh((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyt get_flags_f90scC`sgS(s.List of Fortran 90 free format specific flags.((Rh((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytget_flags_freescC`s |jdS(s/List of Fortran 90 fixed format specific flags.R1(R(Rh((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyt get_flags_fixscC`s |jdS(s/List of linker flags to build a shared library.R3(R(Rh((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytget_flags_linker_soscC`s |jdS(s,List of linker flags to build an executable.R6(R(Rh((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytget_flags_linker_exescC`s |jdS(sList of archiver flags. R9(R(Rh((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyt get_flags_arscC`sgS(s0List of architecture independent compiler flags.((Rh((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyt get_flags_optscC`sgS(s.List of architecture dependent compiler flags.((Rh((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytget_flags_archscC`sgS(s=List of compiler flags to compile with debugging information.((Rh((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytget_flags_debugscC`s|jS(sList of compiler libraries.(t libraries(Rh((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyt get_librariesscC`s|jS(s%List of compiler library directories.(t library_dirs(Rh((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytget_library_dirssicC`sF|jsttj|d|d|}|dkrBtn|S(Ntforcet ok_status(RgRrRt get_versionReR(RhRRtversion((sA/tmp/pip-build-fiC0ax/numpy/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>RAs%s_%s(textendRRa(ttagRTtthis_getRtctflagvartt(R>R@RARCRGtfixflagsRh(sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyRs RHRLR+R.R1taixt standard_libitconfigt ld_so_aixs python.exps-bI:R3R6R9N(&RtinfoRmRtTrueRgR]tuse_distributionR`RaRRRRfR+R.R>RARDR1RGRTR}R3tsystplatformt startswithRtostpathtjoinR6R9R;tset_library_dirsRt set_librariesR(RhtdistR'R(R)RFtoflagstaflagstdflagsRRVR3tlinker_so_flagst python_libRt python_expR6tlinker_exe_flagsR;RZ((R>R@RARCRGRRhsA/tmp/pip-build-fiC0ax/numpy/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(tlistRbtkeysthasattrRRRetreprtsortR t generate_helpRmRtprint(RhtpropsRsR|tpretty_printertl((sA/tmp/pip-build-fiC0ax/numpy/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.ReR RmRtextra_f90_compile_argsR1RtstripRRrRRRRRRRtbasenametspawntstrRR (RhRptsrctexttcc_argstextra_postargstpp_optst src_flagstflavortcompilertextra_compile_argsto_argsts_argst extra_flagstcommandRtmsg((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyt_compile/sN           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_switchReRRRRRmRtmodule_include_switch(Rht module_dirstmodule_build_dirtoptionstd((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytmodule_optionsas!cC`sd|S(Ns-l((Rhtlib((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytlibrary_optionsscC`sd|S(Ns-L((Rhtdir((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytlibrary_dir_optionuscC`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_argsRRRRRRet TypeErrort _need_linktlibrary_switchRtobjectsRtmkpathtdirnameRt EXECUTABLER6R3RR RRR RR)(Rht target_descRtoutput_filenamet output_dirRRtruntime_library_dirstexport_symbolsR)t extra_preargsRt build_tempt target_langtlib_optsRtld_argstlinkerRR((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytlinkxsB          cC`s|dkrdSt|r|jdrK|d}t||}|S|jdr|d}|j|}|r|dSdSq|jdr|d}t|d|}|Sn|SdS( Nsself.isexe.iisflags.iR(ReRRRRb(RhRt hook_namethooktvar((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyR_s$       cC`stS(sc Check if the given C compiler can link objects produced by this compiler. (R(Rht ccompiler((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytcan_ccompiler_linkscC`s tdS(s Convert a set of object files that are not compatible with the default linker, to a file that is compatible. Parameters ---------- objects : list List of object files to include. output_dir : str Output directory to place generated object files. extra_dll_dir : str Output directory to place extra DLL files that need to be included on Windows. Returns ------- converted_objects : list of str List of converted object files. Note that the number of output files is not necessarily the same as inputs. N(tNotImplementedError(RhRR t extra_dll_dir((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pytwrap_unlinkable_objectssN(sexe.compiler_f77R,R-N(sexe.compiler_f90R/R0N(sexe.compiler_fixR/R0N(sexe.version_cmdNNN(s exe.linker_soR4R5N(sexe.linker_exeR7R8N(NR:R;N(NR=R<N((VRRt__doc__RReR"R]R`R Rat language_maptlanguage_orderRtcompiler_aliasestversion_patternRRbtsuggested_f90_compilerRRRRRRtsrc_extensionst obj_extensionRtshared_lib_extensiontstatic_lib_extensiontstatic_lib_formattshared_lib_formatt exe_extensionRRdt c_compilerRRR\RqRcRvR2R+R.R1R3R6R9R<RyR}RwRRRRRRRRRRRRRRtget_flags_opt_f77tget_flags_opt_f90tget_flags_arch_f77tget_flags_arch_f90tget_flags_debug_f77tget_flags_debug_f90RRRfRRRRRRRRR_RR(((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyR=s             !                   O                  e  2    +  twin32tgnutintelvtabsofttcompaqvtintelevtgnu95tg95tintelvemtintelemtflangscygwin.*slinux.*tinteltlaheytpgtnagtvasttcompaqtinteletpathf95tnagforsdarwin.*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((Retdistutils.distRtt'numpy.distutils.command.config_compilerR&RRRRtargvt script_namet script_argstremoveR~tcmdclasstparse_config_filestparse_command_lineRNR]RmRt set_verbosityRR*RRR RRR)RRRRRRRR t print_helpR( RRtR&RMt compilers_nat compilers_nitplatform_compilersRR|RRktfcR((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyR|sd              "+        cC`s4tdd\}}|jd|j|d S(Ntsuffixs.fs# subroutine dummy() end i(Rtwritetclose(tfoR((sA/tmp/pip-build-fiC0ax/numpy/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((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyRs&       0 cC`s;t|d}|j}|jt|p:t|S(NR(RRRRt_has_fix_header(RRR((sA/tmp/pip-build-fiC0ax/numpy/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 {:}. RiiitfcnameRV(Rt _f77flags_reRitgroupRRR(RRTRtiRtmRRV((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyRs    t__main__(NRt __future__RRRt__all__RRRhttypest numpy.compatRtdistutils.sysconfigRtdistutils.fancy_getoptR tdistutils.errorsR R R R Rtdistutils.utilRRtnumpy.distutils.ccompilerRRtnumpy.distutilsRtnumpy.distutils.misc_utilRRRRRtnumpy.distutils.environmentRtnumpy.distutils.exec_commandRtnumpy.distutils.compatRttypet __metaclass__t ExceptionRR R"R$RRgReRNRPR]RfRfRmRnRRqRRRtcompiletIRiRtsearchRRRRRRRRR(((sA/tmp/pip-build-fiC0ax/numpy/numpy/distutils/fcompiler/__init__.pyts      ((   !  "    ! =