
Xc           @` s  d  Z  d d l m Z m Z m Z d d d d g Z d d l Z d d l Z d d l Z d d l	 Z	 y e
 Wn! e k
 r d d l m Z
 n Xd d	 l m Z d d
 l m Z d d l m Z d d l m Z m Z m Z m Z m Z d d l m Z m Z d d l m Z m Z d d l  m! Z! d d l" m# Z# m$ Z$ m% Z% m& Z& m' Z' d d l( m) Z) d d l* m+ Z+ d d l, m- Z- e. Z/ d e0 f d     YZ1 d   Z2 d   Z3 d   Z4 d e f d     YZ5 d d d d d d d  d! d" d# f	 f d$ d d d d d d  d! f f d% d  d& d' d( d d) d* d+ d, d# d d! d- f f d. d  d) d d/ d& d d! d( f f d0 d1 d d  d! f f d2 d3 d d  f f d4 d/ d d  f f d5 d d  f f d6 d d  f f d7 d  d d( f f f
 Z6 e7 a8 e7 a9 d8   Z: e7 e7 e; e7 d9  Z< e7 e7 d:  Z= e7 e7 e; e7 d;  Z> e
   a? e7 e7 d d d e; e7 d<  Z@ e7 d=  ZA d>   ZB e jC d? e jD  jE ZF e jC d@ e jD  jG ZH e jC dA e jD  jG ZI e jC dB e jD  jG ZJ e jC dC e jD  jE ZK dD   ZL dE   ZM e jC dF e jD  ZN dG   ZO eP dH k reA   n  d S(I   s  numpy.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    (   t   divisiont   absolute_importt   print_functiont	   FCompilert   new_fcompilert   show_fcompilerst   dummy_fortran_fileN(   t   Set(   t   open_latin1(   t   get_python_lib(   t   FancyGetopt(   t   DistutilsModuleErrort   DistutilsExecErrort   CompileErrort	   LinkErrort   DistutilsPlatformError(   t   split_quotedt	   strtobool(   t	   CCompilert   gen_lib_options(   t   log(   t	   is_stringt   all_stringst   is_sequencet   make_temp_filet   get_shared_lib_extension(   t   EnvironmentConfig(   t   find_executable(   t   get_exceptiont   CompilerNotFoundc           B` s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyR   0   s   c         C` s   t  |   r t |   S|  Sd  S(   N(   R   R   (   t   s(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   flaglist3   s    
c         C` s    t  |   r t |   St |   S(   N(   R   R   t   bool(   R    (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   str2bool9   s    
c         C` s   t  |   o t |   S(   N(   R   R   (   t   seq(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   is_sequence_of_strings>   s    c        (   B` s  e  Z d  Z e d d d d d d e f d d d d e f d d d d e f d d d d e f  Z e d d d d d d d d d d d d d d d d d d  	Z e d d d  d! d" d# e f d$ d% d& d' e f d( d) d* d+ e f d, d- d d e f d. d/ d0 d. e f d1 d2 d d e f d3 d4 d d e f d5 d6 d7 d5 e f d8 d9 d d e f d: d; d d e f d d< d= d> e f d? d@ d d e f dA dB d d e f dC dD dE dF e f d dG dH dI e f d dJ dH dI e f d dK dL dM e f  Z	 i d  dN 6d  dO 6d  dP 6d  dQ 6d  dR 6d$ dS 6d$ dT 6d$ dU 6Z
 d$ d  g Z d Z d Z d Z g  Z i d  dV g d 6d  g d 6d$ g d 6d$ dW g d 6d$ dX g d 6d$ g d 6d dY g d 6d d 6Z d Z dZ Z d[ Z d[ Z d Z d\ Z g  Z dO dQ dR dN dS dU dP dT d] g	 Z d^ Z e   Z d_ Z d` Z da Z db Z i  Z  d d d d d d d d g Z! d Z" g  Z# g  Z$ dc   Z% dd   Z& de   Z' df   Z( e( d  Z) e( d  Z* e( d  Z+ e( d  Z, e( d  Z- e( d  Z. e( d  Z/ e( d  Z0 dg   Z1 dh   Z2 di   Z3 dj   Z4 dk   Z5 dl   Z6 dm   Z7 dn   Z8 do   Z9 dp   Z: dq   Z; dr   Z< ds   Z= dt   Z> du   Z? dv   Z@ dw   ZA e? ZB ZC e@ ZD ZE eA ZF ZG dx   ZH dy   ZI eJ dz g d{  ZK d d|  ZL d}   ZM d~   ZN d   ZO d   ZP d   ZQ d d d d d dz d d d d d 
 ZR d   ZS RS(   s0  Abstract 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
    t   distutils_sectiont	   config_fct   nooptt   noarcht   debugt   verboset   compiler_f77s   exe.compiler_f77t   F77t   f77exect   compiler_f90s   exe.compiler_f90t   F90t   f90exect   compiler_fixs   exe.compiler_fixt   version_cmds   exe.version_cmdt	   linker_sos   exe.linker_sot   LDSHAREDt   ldsharedt
   linker_exes   exe.linker_exet   LDt   ldt   archivert   ARt   art   ranlibt   RANLIBt   f77s	   flags.f77t   F77FLAGSt   f77flagst   f90s	   flags.f90t   F90FLAGSt   f90flagst   frees
   flags.freet	   FREEFLAGSt	   freeflagst   fixs	   flags.fixt   opts	   flags.optt   FOPTt   opt_f77s   flags.opt_f77t   opt_f90s   flags.opt_f90t   archs
   flags.archt   FARCHt   arch_f77s   flags.arch_f77t   arch_f90s   flags.arch_f90s   flags.debugt   FDEBUGt   fdebugt	   debug_f77s   flags.debug_f77t	   debug_f90s   flags.debug_f90t   flagss   self.get_flagst   FFLAGSt   fflagss   flags.linker_sot   LDFLAGSt   ldflagss   flags.linker_exes   flags.art   ARFLAGSt   arflagss   .fs   .fors   .Fs   .ftns   .f77s   .f90s   .F90s   .f95s   -vs   -fixeds   -shareds   -crs   -cs   -o s   -Is   .FORs   .os   .as   lib%s%ss   %s%st    c         O` s   t  j |  | |  |  j j |  j  |  _ |  j j |  j  |  _ |  j j |  j  |  _ |  j j   |  _ x0 |  j	 D]% } | |  j k rw d  |  j | <qw qw Wt |  _ d  S(   N(   R   t   __init__t   distutils_varst   clonet   _environment_hookt   command_varst	   flag_varst   executablest   copyt   _executable_keyst   Nonet   Falset   _is_customised(   t   selft   argst   kwt   e(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyR]      s    c         C` s   |  j  |  j  } | j j |  j  | j j | j  | _ | j j | j  | _ | j j | j  | _ | j	 j
   | _	 | S(   N(   t   __new__t	   __class__t   __dict__t   updateR^   R_   R`   Ra   Rb   Rc   Rd   (   Ri   t   obj(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   __copy__   s    c         C` s
   |  j    S(   N(   Rr   (   Ri   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyRd      s    c         ` s     f d   } t  d |  S(   Nc         ` s   |  j  s t  |  j   S(   N(   Rh   t   AssertionErrorRc   (   Ri   (   t   key(    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   fget   s    Ru   (   t   property(   Rt   Ru   (    (   Rt   sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   _command_property   s    c         C` s   |  j  | |  d  S(   N(   t   set_command(   Ri   Rt   t   value(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   set_executable
  s    c         K` s1   x* | j    D] \ } } |  j | |  q Wd  S(   N(   t   itemsRx   (   Ri   Rk   t   kt   v(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   set_commands  s    c         C` s   | |  j  k r. t d | |  j j f   n  t |  rI t |  } n  | d  k sw t | d  sw t | | f   | |  j	 | <d  S(   Ns$   unknown executable '%s' for class %si   (
   Re   t
   ValueErrorRn   R   R   R   Rf   R%   Rs   Rc   (   Ri   Rt   Ry   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyRx     s    .c         ` s8   j  s t   j   f d      f d   } d d    f d  }  j } | d  } | s | d  } | r t j d |  q t d |   n< | d d | } | s t j d	 |  n  | d
 d | | d d | d | | d d | d | | d d | d | | d  | d  d S(   s3  Go through the self.executables dictionary, and attempt to
        find and assign appropriate executables.

        Executable names are looked for in the environment (environment
        variables, the distutils.cfg, and command line), the 0th-element of
        the command list, and the self.possible_executables list.

        Also, if the 0th element is "<F77>" or "<F90>", 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   |    k r   |  St  |   } |   |  <  | <| S(   N(   R   (   t   exet   fc_exe(   t	   exe_cache(    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   cached_find_executable0  s
    c         ` s?   | d  k	 r; t |  r; t d |  |   j j f   n  d  S(   Ns"   %s value %r is invalid in class %s(   Rf   R%   R   Rn   R   (   t   nameRy   (   Ri   (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   verify_command_form6  s    c         ` s   j  j |  d   } | s d  St  j |   } | sM | | g  j } n | g  j } t   } g  } xk | D]c } | d k r | } n | d k r | } n  | ss | | k r qs n  | j |  | j |  qs Wx. | D]& }	   |	  }
 |
 r |
 | d <|
 Sq W j	 |  d   d  S(   Ns   <F77>s   <F90>i    (
   Rc   t   getRf   t   getattrRa   t   possible_executablest   sett   addt   appendRx   (   t   exe_keyR?   RB   t   cmdt   exe_from_environt	   possiblest   seent   unique_possiblesRl   R   R   (   R   Ri   (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   set_exe;  s2    			
R/   R,   s    %s: no Fortran 90 compiler founds   %s: f90 nor f77RB   s    %s: no Fortran 77 compiler foundR2   R4   R?   R7   R3   R:   R=   N(   Rh   Rs   t
   _exe_cacheRf   t   compiler_typeR   t   warnR   (   Ri   R   R   t   ctypeRB   R?   (    (   R   R   Ri   sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   find_executables   s*    	 	
c         C` s   d S(   sq  Called 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 <F77> or <F90> as
        the command, which will be replaced by the found F77 or F90
        compiler.
        N(    (   t   elf(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   update_executableso  s    	c         C` s   g  |  j  S(   s+   List of flags common to all compiler types.(   t	   pic_flags(   Ri   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt	   get_flagsz  s    c         C` s-   |  j  j | d   } | d  k r% g  S| d S(   Ni   (   Rc   R   Rf   (   Ri   Rt   R   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   _get_command_flags~  s    c         C` s   |  j  d  S(   s"   List of Fortran 77 specific flags.R,   (   R   (   Ri   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   get_flags_f77  s    c         C` s   |  j  d  S(   s"   List of Fortran 90 specific flags.R/   (   R   (   Ri   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   get_flags_f90  s    c         C` s   g  S(   s.   List of Fortran 90 free format specific flags.(    (   Ri   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   get_flags_free  s    c         C` s   |  j  d  S(   s/   List of Fortran 90 fixed format specific flags.R2   (   R   (   Ri   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   get_flags_fix  s    c         C` s   |  j  d  S(   s/   List of linker flags to build a shared library.R4   (   R   (   Ri   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   get_flags_linker_so  s    c         C` s   |  j  d  S(   s,   List of linker flags to build an executable.R7   (   R   (   Ri   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   get_flags_linker_exe  s    c         C` s   |  j  d  S(   s   List of archiver flags. R:   (   R   (   Ri   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   get_flags_ar  s    c         C` s   g  S(   s0   List of architecture independent compiler flags.(    (   Ri   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   get_flags_opt  s    c         C` s   g  S(   s.   List of architecture dependent compiler flags.(    (   Ri   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   get_flags_arch  s    c         C` s   g  S(   s=   List of compiler flags to compile with debugging information.(    (   Ri   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   get_flags_debug  s    c         C` s   |  j  S(   s   List of compiler libraries.(   t	   libraries(   Ri   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   get_libraries  s    c         C` s   |  j  S(   s%   List of compiler library directories.(   t   library_dirs(   Ri   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   get_library_dirs  s    i    c         C` sF   |  j  s t  t j |  d | d | } | d  k rB t    n  | S(   Nt   forcet	   ok_status(   Rh   Rs   R   t   get_versionRf   R   (   Ri   R   R   t   version(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyR     s
    c         ` s_  t  j d  j j  t  _  j j |   j j |   j	 j |   j
    j    j j d t  }  j j d |  }  j j d t  }  j j    j j  g   g   g  } g     r  j	 j  n   r	 j	 j   j	 j } n   j j   r. j	 j   n  g  g  g  } } }         f d   }	 | s|	 d |  | s|	 d |  qn  | r|	 d |  n   j	 j | | | }
   r j d   g  |
  n   r	 j d	  g |  |
  n   r- j d
  g  |
  n   j } | r j	 j } t j j d  rt d d  } t j j | d d  } t j j | d d  } | g | d | g } n   j d | |  n   j } | r j	 j }  j d | |  n   j j  } | r5 j	 j! }  j d | g |  n   j"  j#     j$  j%    d S(   s  Customize 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   | j  t  j |    t  d |   } x d    f d   f d   f g D]Z \ } } } d |  | f } | rW | t  d |  k	 rW | j  t  j |   qW qW Wd  S(   Nt
   get_flags_R?   RB   s   %s_%s(   t   extendR   Rb   (   t   tagRU   t   this_getR   t   ct   flagvart   t(   R?   RA   RB   RD   RH   t   fixflagsRi   (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyR     s    RI   RM   R,   R/   R2   t   aixt   standard_libi   t   configt	   ld_so_aixs
   python.exps   -bI:R4   R7   R:   N(&   R   t   infoRn   R   t   TrueRh   R^   t   use_distributionRa   Rb   R   R   R   Rg   R,   R/   R?   RB   RE   R2   RH   RU   R~   R4   t   syst   platformt
   startswithR	   t   ost   patht   joinR7   R:   R<   t   set_library_dirsR   t   set_librariesR   (   Ri   t   distR(   R)   R*   RG   t   oflagst   aflagst   dflagsR   RW   R4   t   linker_so_flagst
   python_libR   t
   python_expR7   t   linker_exe_flagsR<   R[   (    (   R?   RA   RB   RD   RH   R   Ri   sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt	   customize  st    	

!
"		c         C` s   g  } xq t  |  j j    d d d d d g D]G } t |  |  r/ t |  |  } | j | d d t |  f  q/ q/ W| j   t	 |  } xL | j
 d |  j j  D]1 } | d  d	 k r d
 | d } n  t |  q Wd S(   s0   Print out the attributes of a compiler instance.R   R   R   t   object_switcht   compile_switchs   = s   %s instance properties:i   s     --s     N(   t   listRc   t   keyst   hasattrR   R   Rf   t   reprt   sortR
   t   generate_helpRn   R   t   print(   Ri   t   propsRt   R}   t   pretty_printert   l(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   dump_properties  s    	'
c         C` sC  i  } t  |  rL t |  rL d } |  j }	 t |  } |  j pF g  }
 n t |  r d } |  j }	 |	 d k r t d |  j	 j
 | f   n  |  j p g  }
 nI d } |  j }	 |	 d k r t d |  j	 j
 | f   n  |  j p g  }
 |  j d d k r|  j j   | g } n |  j j   | g } |  j j   sCt  |  j | g } |
 rt j d | d	 d j |
  f  n  | j |  j g   } | rt j d
 d j |   n  |	 | | | | | |
 } d t j j |	 d  | | f } y |  j | d | Wn, t k
 r>t t    } t |   n Xd S(   s   Compile '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    s   extra %s options: %ri   s%   using compile options from source: %rs   %s: %si    t   displayN(   t	   is_f_filet   has_f90_headerR,   t   get_f77flagst   extra_f77_compile_argst   is_free_formatR/   Rf   R   Rn   R   t   extra_f90_compile_argsR2   R   t   stripR   Rs   R   R   R   R   R   R   R   t   basenamet   spawnt   strR   R   (   Ri   Rq   t   srct   extt   cc_argst   extra_postargst   pp_optst	   src_flagst   flavort   compilert   extra_compile_argst   o_argst   s_argst   extra_flagst   commandR   t   msg(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   _compile2  sN    					
c         C` s   g  } |  j  d  k	 rd |  j  d d k rG | j |  j  j   | g  q | j |  j  j   |  n! t d |  t d |  j j  |  j d  k	 r xS | g | D]  } | j d |  j | f  q Wn! t d |  t d |  j j  | S(   NiR   s'   XXX: module_build_dir=%r option ignoreds   XXX: Fix module_dir_switch for s   %s%ss"   XXX: module_dirs=%r option ignoreds#   XXX: Fix module_include_switch for (	   t   module_dir_switchRf   R   R   R   R   Rn   R   t   module_include_switch(   Ri   t   module_dirst   module_build_dirt   optionst   d(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   module_optionsd  s    !c         C` s   d | S(   Ns   -l(    (   Ri   t   lib(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   library_optionv  s    c         C` s   d | S(   Ns   -L(    (   Ri   t   dir(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   library_dir_optionx  s    c         C` s  |  j  | |  \ } } |  j | | |  \ } } } t |  | | |  } t |  ro t j j | |  } n | d  k	 r t d   n  |  j	 | |  r|  j
 d d k r |  j
 j   | g } n |  j
 j   | g } t |  j  r | |  j g } n | |  j } | | | } |	 r0d g | d *n  |
 rC|
 | d *n  | rY| j |  n  |  j t j j |   | t j k r|  j } n
 |  j } | | } y |  j |  Wqt k
 rt t    } t |   qXn t j d |  d  S(   Ns%   'output_dir' must be a string or NoneiR   s   -gi    s   skipping %s (up-to-date)(   t   _fix_object_argst   _fix_lib_argsR   R   R   R   R   Rf   t	   TypeErrort
   _need_linkt   library_switchR   t   objectsR   t   mkpatht   dirnameR   t
   EXECUTABLER7   R4   R   R   R   R   R   R   R*   (   Ri   t   target_descR  t   output_filenamet
   output_dirR   R   t   runtime_library_dirst   export_symbolsR*   t   extra_preargsR   t
   build_tempt   target_langt   lib_optsR   t   ld_argst   linkerR   R   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   link{  sB    	

c         C` s   | d  k r d  St |  r | j d  rK | d } t |  |  } |   S| j d  r | d } |  j | } | r | d Sd  Sq | j d  r | d } t |  d |  } |   Sn |   Sd  S(	   Ns   self.i   s   exe.i   i    s   flags.i   R   (   Rf   R   R   R   Rc   (   Ri   R   t	   hook_namet   hookt   var(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyR`     s$    



N(   s   exe.compiler_f77R-   R.   N(   s   exe.compiler_f90R0   R1   N(   s   exe.compiler_fixR0   R1   N(   s   exe.version_cmdNNN(   s   exe.linker_sos   LDSHAREDs   ldsharedN(   s   exe.linker_exeR8   R9   N(   Ns   ARs   arN(   Ns   RANLIBR=   N(    (T   R   R   t   __doc__R   Rf   R#   R^   Ra   R!   Rb   t   language_mapt   language_orderR   t   compiler_aliasest   version_patternR   Rc   t   suggested_f90_compilerR   R   R  R   R   R   t   src_extensionst   obj_extensionR   t   shared_lib_extensiont   static_lib_extensiont   static_lib_formatt   shared_lib_formatt   exe_extensionR   Re   t
   c_compilerR   R   R]   Rr   Rd   Rw   R3   R,   R/   R2   R4   R7   R:   R=   Rz   R~   Rx   R   R   R   R   R   R   R   R   R   R   R   R   R   R   t   get_flags_opt_f77t   get_flags_opt_f90t   get_flags_arch_f77t   get_flags_arch_f90t   get_flags_debug_f77t   get_flags_debug_f90R   R   Rg   R   R   R   R   R   R   R  R  R`   (    (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyR   A   s   	





!												O													


		e		2				+t   win32t   gnut   intelvt   absoftt   compaqvt   intelevt   gnu95t   g95t   intelvemt   intelems   cygwin.*s   linux.*t   intelt   laheyt   pgt   nagt   vastt   compaqt   intelet   pathf95s   darwin.*t   ibms   sunos.*t   suns   irix.*t   mipss   aix.*t   posixt   ntt   macc    
   	   C` sX  d d l  m  }  t d k	 r  d St j j t j j t  d  } i  a i  a x|  |  D] } t j j	 t j j
 |   \ } } d | } t |  t j | } t | d  rZ x | j D] } t | |  } | j | | j f } | t | j <xQ | j D]F }	 |	 t k r;t d |	 | j t |	 d j f   n  | t |	 <q Wq WqZ qZ Wd S(	   sc   Cache all the FCompiler classes found in modules in the
    numpy.distutils.fcompiler package.
    i    (   t   globNs   *.pys   numpy.distutils.fcompiler.t	   compilerss#   alias %r defined for both %s and %si   (   RF  t   fcompiler_classRf   R   R   R   R	  t   __file__t   fcompiler_aliasest   splitextR   t
   __import__R   t   modulesR   RG  R   R   t   descriptionR  R   R   (
   RF  t   pyst   fnamet   module_nameR   t   modulet   cnamet   klasst   desct   alias(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   load_all_fcompiler_classes  s,    !$

	c      	   C` s  d d l  m } | d t  } x^|  D]V} d  } y t d | d | d |  }	 |	 j |  |	 j   } | r |	 j d  k r d  } |	 j }
 |
 r t	 j
 d | |
 f  t d | d |
 d |  }	 |	 j |  |	 j   } | d  k	 r |
 } q q n  | r'|	 j d  k r't d |	 j j   n  WnA t k
 rKt	 j d	 |  n! t k
 rkt	 j d
 |  n X| d  k	 r& | Sq& Wd  S(   Ni    (   t   get_distributiont   alwayst   platR   R'  s?   Trying %r compiler as suggested by %r compiler for f90 support.s2   %s does not support compiling f90 codes, skipping.sH   _find_existing_fcompiler: compiler_type='%s' raised DistutilsModuleErrors6   _find_existing_fcompiler: compiler_type='%s' not found(   t   numpy.distutils.coreRX  R   Rf   R   R   R   R/   R  R   R   R   Rn   R   R   R*   R   (   t   compiler_typest   osnameR   t
   requiref90R'  RX  R   R   R}   R   t   new_compiler(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   _find_existing_fcompiler  s@    				c         C` s   |  d  k r t j }  n  | d  k r0 t j } n  g  } xh t D]` \ } } t j | |  sm t j | |   r= x- | D]" } | | k rt | j |  qt qt Wq= q= W| s | j d  n  | S(   NR/  (	   Rf   R   R   R   R   t   _default_compilerst   ret   matchR   (   R]  R   t   matching_compiler_typest   patternR   t   ct(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt!   available_fcompilers_for_platform  s    $c      
   C` s7   t  |  |  } t | d |  d | d | d | } | S(   sI   Determine the default Fortran compiler to use for the given
    platform.R]  R   R^  R'  (   Rg  R`  (   R]  R   R^  R'  Rd  R   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   get_default_fcompiler&  s    			c         C` s0  |  | f } | t  k r d
 St   |  d
 k r; t j }  n  | d
 k rb t |  d | d | } n  | t k r t | \ } }	 }
 n | t k r t | \ } }	 }
 nb d |  } | d
 k	 r | d | } | d d j t j	    } n  t
 j |  t  j |  d
 S|	 d | d | d	 |  } | | _ | S(   sh   Generate an instance of some FCompiler subclass for the supplied
    platform/compiler combination.
    R^  R'  s7   don't know how to compile Fortran code on platform '%s's    with '%s' compiler.s    Supported compilers are: %s)t   ,R+   t   dry_runR   N(   t   failed_fcompilersRf   RW  R   R   Rh  RH  RJ  R   R   R   R   R   R'  (   RZ  R   R+   Rj  R   R^  R'  t   fcompiler_keyRQ  RT  t   long_descriptionR   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyR   6  s0    
	c         C` s  |  d k r d d l m } d d l m } |   }  t j j t j	 d  |  _
 d g t j	 d |  _ y |  j j d  Wn t k
 r n X| |  j d <|  j   |  j   n  g  } g  } g  } t s t   n  t   } x| D] } d } t j d  y5 t d | d	 |  j  }	 |	 j |   |	 j   } WnG t t f k
 r}t   }
 t j d
 | f  t j t |
   n X| d k r| j d | d t | d f  q |	 j    | j d | d t | d d | f  q Wt! t" t j#    t" |   } g  | D]! } d | d t | d f ^ q} | j$   | j$   | j$   t% |  } | j& d  t% |  } | j& d  | rt% |  } | j& d  n  t' d  d S(   sb   Print list of available compilers (used by the "--help-fcompiler"
    option to "config_fc").
    i    (   t   Distribution(   R'   R'   i   s   --help-fcompileriR   R+   s   show_fcompilers: %s not founds
   fcompiler=i   s    (%s)s   Fortran compilers found:s5   Compilers available for this platform, but not found:s)   Compilers not available on this platform:s>   For compiler details, run 'config_fc --verbose' setup command.N((   Rf   t   distutils.distRn  t'   numpy.distutils.command.config_compilerR'   R   R   R   R   t   argvt   script_namet   script_argst   removeR   t   cmdclasst   parse_config_filest   parse_command_lineRH  RW  Rg  R   t   set_verbosityR   R+   R   R   R   R   R   R*   R   R   R   R   R   R   R   R
   t
   print_helpR   (   R   Rn  R'   RG  t   compilers_nat   compilers_nit   platform_compilersR   R}   R   Rl   t   fcR   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyR   ]  sd    	

		
"+


c          C` s4   t  d d  \ }  } |  j d  |  j   | d  S(   Nt   suffixs   .fs#         subroutine dummy()
      end
i(   R   t   writet   close(   t   foR   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyR     s    
s   .*[.](for|ftn|f77|f)\Zs   -[*]-\s*fortran\s*-[*]-s   -[*]-\s*f90\s*-[*]-s   -[*]-\s*fix\s*-[*]-s   [^c*!]\s*[^\s\d\t]c         C` s   d } t  |  d  } | j   } d } t |  r< d } n t |  rW d } d } n  x | d k r | r | j   } | r | d d k r | d 8} | d d k r t | d   s | d d	 k r d } Pq n  | j   } qZ W| j   | S(
   s(   Check if file is in free format Fortran.i    t   ri'  i   t   !s   	i   it   &(   R   t   readlinet   _has_f_headert   _has_f90_headert   rstript   _free_f90_startR  (   t   filet   resultt   ft   linet   n(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyR     s&    		
0
c         C` s;   t  |  d  } | j   } | j   t |  p: t |  S(   NR  (   R   R  R  R  t   _has_fix_header(   R   R  R  (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyR     s    
s=   (c|)f77flags\s*\(\s*(?P<fcname>\w+)\s*\)\s*=\s*(?P<fflags>.*)c         C` s   i  } t  |  d  } d } x} | D]u } | d 7} | d k rB Pn  t j |  } | s] q" n  | j d  j   } | j d  j   } t |  | | <q" W| j   | S(   s   
    Search the first 20 lines of fortran 77 code for line pattern
      `CF77FLAGS(<fcompiler type>)=<f77 flags>`
    Return a dictionary {<fcompiler type>:<f77 flags>}.
    R  i    i   i   t   fcnameRW   (   R   t   _f77flags_reRc  t   groupR   R   R  (   R   RU   R  t   iR  t   mR  RW   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyR     s    
  
t   __main__(Q   R  t
   __future__R    R   R   t   __all__R   R   Rb  t   typesR   t	   NameErrort   setsR   t   numpy.compatR   t   distutils.sysconfigR	   t   distutils.fancy_getoptR
   t   distutils.errorsR   R   R   R   R   t   distutils.utilR   R   t   numpy.distutils.ccompilerR   R   t   numpy.distutilsR   t   numpy.distutils.misc_utilR   R   R   R   R   t   numpy.distutils.environmentR   t   numpy.distutils.exec_commandR   t   numpy.distutils.compatR   t   typet   __metaclass__t	   ExceptionR   R!   R#   R%   R   Ra  Rf   RH  RJ  RW  Rg   R`  Rg  Rh  Rk  R   R   R   t   compilet   IRc  R   t   searchR  R  R  R  R   R   R  R   R   (    (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/fcompiler/__init__.pyt   <module>   s   		((			  !	"		!=				