
Ee]c           @` sV  d  d l  m Z m Z m Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l Z d  d l	 m
 Z d  d l	 m Z d  d l m Z d  d l m Z d  d l m Z m Z d  d l 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 d e d <d e d <d e f d     YZ
 d e  f d     YZ! d S(   i    (   t   divisiont   absolute_importt   print_functionN(   t   config(   t   LANG_EXT(   t   log(   t	   copy_file(   t   CompileErrort	   LinkError(   t   filepath_from_subprocess_output(   t   generate_manifest(   t   check_gcc_function_attributet   check_gcc_variable_attributet   check_inlinet   check_restrictt   check_compiler_gcc4(   t   get_exceptions   .ft   f77s   .f90t   f90R   c           B` s"  e  Z e j d g 7_ d   Z d   Z d   Z d   Z d   Z	 d d d d  Z
 d d d	  Z d d d
  Z d d d d  Z d d d d d  Z d d d d e e d d  Z d d d d e e d d  Z d   Z d   Z d   Z d   Z d   Z d d d d d d d  Z RS(   s
   fcompiler=s!   specify the Fortran compiler typec         C` s   d  |  _ t j |   d  S(   N(   t   Nonet	   fcompilert
   old_configt   initialize_options(   t   self(    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyR   #   s    	c      	   C` s  t  j |   d d l m } m } t j d k r|  j j d k r|  j j	 s y |  j j
   Wq t k
 r t   } d | |  j j j f } t d  t j j |   q Xn  d d	 l m } | j   d
 k rx? |  j j |  j j g D]" } d | k r | j d  q q Wqn  t |  j |  s| d |  j d |  j d d d |  j  |  _ |  j d  k	 r|  j j |  j  |  j j   r|  j j |   |  j j    qqn  d  S(   Ni    (   t	   FCompilert   new_fcompilert   win32t   msvct   intelwt   intelemws  Could not initialize compiler instance: do you have Visual Studio
installed?  If you are trying to build with MinGW, please use "python setup.py
build -c mingw32" instead.  If you have Visual Studio installed, check it is
correctly installed, and the right version (VS 2008 for python 2.6, 2.7 and 3.2,
VS 2010 for >= 3.3).

Original exception was: %s, and the Compiler class was %s
============================================================================sL   ============================================================================(   t   msvc9compileri
   s	   /MANIFESTt   compilert   dry_runt   forcei   t
   c_compiler(   R   R   R   (!   R   t   _check_compilert   numpy.distutils.fcompilerR   R   t   syst   platformR   t   compiler_typet   initializedt
   initializet   IOErrorR   t	   __class__t   __name__t   printt	   distutilst   errorst   DistutilsPlatformErrorR   t   get_build_versiont   ldflags_sharedt   ldflags_shared_debugt   appendt
   isinstanceR   R    R   t	   customizet   distributiont   get_versiont   customize_cmdt   show_customization(   R   R   R   t   et   msgR   t   ldflags(    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyR#   '   s:    			c         C` s   d d l  m } d d l m } |  j } | d k rD |  j |  _ n  y | |  f |   } Wn3 | | f k
 r t t    | |  _ |  n X| |  _ | S(   Ni    (   R   (   t   DistutilsExecErrorR   R   (   R   R   (   t   distutils.ccompilerR   t   distutils.errorsR>   R   R   t   strR   (   R   t   mtht   langt   argsR   R>   t   save_compilert   ret(    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyt   _wrap_methodY   s    		
	c         C` sH   |  j  t j | | | | | f  \ } } |  j j | d  | | f S(   Ns   .d(   RG   R   t   _compilet
   temp_filesR4   (   R   t   bodyt   headerst   include_dirsRC   t   srct   obj(    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyRH   h   s    c      	   C` sz  |  j  j d k r3| p g  } | p( g  } | d k rd } |  j rx~ |  j j pY g  D]j } | j d  r y t j d d | g  } Wn t t j f k
 r q Xt	 |  } n  | j
 |  qZ Wx9 |  j j p g  D]" } | | k r | j
 |  q q Wqn  xH| D]} | j d  r)qn  t }	 xI | p;g  D]; }
 t j j |
 d |  } t j j |  r<t }	 Pq<q<W|	 rqn  t }	 xy | D]q }
 t j j |
 d	 |  } t j j |  rt j j |
 d |  } t | |  |  j j
 |  t }	 PqqW|	 rqn  t j d
 | | f  qWn |  j  j d k rRt |   n  |  j t j | | | | | | | f  S(   NR   R   R   t   cs   /usr/libt   cygpaths   -ws   %s.libs   lib%s.as+   could not find library %r in directories %st   mingw32(   R   R   (   R   R'   R   t   library_dirst
   startswitht
   subprocesst   check_outputt   OSErrort   CalledProcessErrorR	   R4   t	   librariest   Falset   ost   patht   joint   isfilet   TrueR   RI   R   t   warnR
   RG   R   t   _link(   R   RJ   RK   RL   RX   RR   RC   t   dt   libnamet
   fileexistst   libdirt   libfilet   libfile2(    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyR`   p   s^    		   		RO   c         C` s    |  j    |  j d | g |  S(   Ns2   /* we need a dummy line to make distutils happy */(   R#   t   try_compile(   R   t   headerRL   RR   RC   (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyt   check_header   s    
c         C` s-   |  j    d | | f } |  j | | |  S(   NsH   
int main(void)
{
#ifndef %s
    (void) %s;
#endif
    ;
    return 0;
}(   R#   Rg   (   R   t   symbolRK   RL   RJ   (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyt
   check_decl   s    
	c         C` s*   |  j    d | f } |  j | | |  S(   Ns[   
int main(void)
{
#if %s
#else
#error false or undefined macro
#endif
    ;
    return 0;
}(   R#   Rg   (   R   Rj   RK   RL   RJ   (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyt   check_macro_true   s    

c         C` s   |  j    d i | d 6} t } zO y+ |  j | i | d 6| | d  t } Wn t j j k
 rn t } n XWd |  j   X| S(   sY   Check type availability. Return True if the type can be compiled,
        False otherwises_   
int main(void) {
  if ((%(name)s *) 0)
    return 0;
  if (sizeof (%(name)s))
    return 0;
}
t   namet   typeRO   N(   R#   RY   RH   R^   R.   R/   R   t   _clean(   R   t	   type_nameRK   RL   RR   RJ   t   st(    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyt
   check_type   s    


c         C` s  |  j    d } |  j | i | d 6| | d  |  j   | r d } x_ | D]T } y: |  j | i | d 6| d 6| | d  |  j   | SWqN t k
 r qN XqN Wn  d } d } d }	 xm t r*y7 |  j | i | d 6|	 d 6| | d  |  j   PWq t k
 r&|	 d } d	 |	 d }	 q Xq W|	 }
 x| | |
 k r|
 | d	 | }	 y< |  j | i | d 6|	 d 6| | d  |  j   |	 }
 Wq4t k
 r|	 d } q4Xq4W| S(
   s   Check size of a given type.s   
typedef %(type)s npy_check_sizeof_type;
int main (void)
{
    static int test_array [1 - 2 * !(((long) (sizeof (npy_check_sizeof_type))) >= 0)];
    test_array [0] = 0

    ;
    return 0;
}
Rn   RO   s   
typedef %(type)s npy_check_sizeof_type;
int main (void)
{
    static int test_array [1 - 2 * !(((long) (sizeof (npy_check_sizeof_type))) == %(size)s)];
    test_array [0] = 0

    ;
    return 0;
}
t   sizes   
typedef %(type)s npy_check_sizeof_type;
int main (void)
{
    static int test_array [1 - 2 * !(((long) (sizeof (npy_check_sizeof_type))) <= %(size)s)];
    test_array [0] = 0

    ;
    return 0;
}
i    i   i   (   R#   RH   Ro   R   R^   (   R   Rp   RK   RL   RR   t   expectedRJ   Rs   t   lowt   midt   high(    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyt   check_type_size   sL    


	



c	   
      C` s  |  j    g  }	 | rL t |  t k r8 |	 j |  qL |	 j d |  n  |	 j d  |	 j d |  |	 j d  |	 j d  | r | d  k r d } n  |	 j d | | f  n |	 j d |  |	 j d	  |	 j d
  d j |	  d }	 |  j |	 | | | |  S(   Ns   int %s (void);s   #ifdef _MSC_VERs   #pragma function(%s)s   #endifs   int main (void) {t    s	     %s(%s);s     %s;s     return 0;t   }s   
(   R#   Rn   RA   R4   R   R\   t   try_link(
   R   t   funcRK   RL   RX   RR   t   declt   callt	   call_argsRJ   (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyt
   check_func;  s(    
	c	         C` s  |  j    g  }	 | rP x7 | j   D]& \ }
 } | r# |	 j d |
  q# q# Wn  |	 j d  x | D] } |	 j d |  qd W|	 j d  |	 j d  | r#x | D]v }
 |
 | k r| |
 r| o |
 | k o | |
 s d } n
 | |
 } |	 j d |
 | f  q |	 j d |
  q Wn" x | D] }
 |	 j d |
  q*W|	 j d	  |	 j d
  d j |	  d }	 |  j |	 | | | |  S(   s0  Check a list of functions at once.

        This is useful to speed up things, since all the functions in the funcs
        list will be put in one compilation unit.

        Arguments
        ---------
        funcs : seq
            list of functions to test
        include_dirs : seq
            list of header paths
        libraries : seq
            list of libraries to link the code snippet to
        library_dirs : seq
            list of library paths
        decl : dict
            for every (key, value), the declaration in the value will be
            used for function in key. If a function is not in the
            dictionary, no declaration will be used.
        call : dict
            for every item (f, value), if the value is True, a call will be
            done to the function f.
        s   int %s (void);s   #ifdef _MSC_VERs   #pragma function(%s)s   #endifs   int main (void) {Ry   s	     %s(%s);s     %s;s     return 0;Rz   s   
(   R#   t   itemsR4   R\   R{   (   R   t   funcsRK   RL   RX   RR   R}   R~   R   RJ   t   ft   vR|   RD   (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyt   check_funcs_once]  s4    
	
c         C` s
   t  |   S(   sU   Return the inline keyword recognized by the compiler, empty string
        otherwise.(   R   (   R   (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyR     s    c         C` s
   t  |   S(   sW   Return the restrict keyword recognized by the compiler, empty string
        otherwise.(   R   (   R   (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyR     s    c         C` s
   t  |   S(   s*   Return True if the C compiler is gcc >= 4.(   R   (   R   (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyR     s    c         C` s   t  |  | |  S(   N(   R   (   R   t	   attributeRm   (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyR     s    c         C` s   t  |  |  S(   N(   R   (   R   R   (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyR     s    c         C` s  t  j d t d d |  j   d \ } }	 ynt   }
 y5 |  j | | | | | |  \ } } } |
 j   Wn' t k
 r |
 j }	 |
 j     n Xt	 j
 j d |  } y t j | g d d }	 WnA t j k
 r } | j } d }	 n) t k
 rd } d }	 n Xt |	  }	 t t	 d	  rt	 j |  } t	 j |  rt	 j |  } t j d
 | f  | t j k rt  qqn | } t j d  Wn$ t t f k
 rt j d  n X|  j   | |	 f S(   s   Try to compile, link to an executable, and run a program
        built from 'body' and 'headers'. Returns the exit status code
        of the program and its output.
        s   
+++++++++++++++++++++++++++++++++++++++++++++++++
Usage of get_output is deprecated: please do not 
use it anymore, and avoid configuration checks 
involving running executable on the target machine.
+++++++++++++++++++++++++++++++++++++++++++++++++
t
   stackleveli   i   Ry   t   .t   cwdi   t   WEXITSTATUSs    subprocess exited with signal %ds   success!s   failure.(   i   Ry   (   t   warningsR_   t   DeprecationWarningR#   t
   GrabStdoutR`   t   restoret	   Exceptiont   dataRZ   R[   R\   RT   RU   RW   t
   returncodeRV   R	   t   hasattrR   t   WIFSIGNALEDt   WTERMSIGR   t   errort   signalt   SIGINTt   KeyboardInterruptt   infoR   R   Ro   (   R   RJ   RK   RL   RX   RR   RC   t   use_teet   exitcodet   outputt   grabberRM   RN   t   exet   exct
   exitstatust   sig(    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyt
   get_output  sJ    	
		
		

N(   s
   fcompiler=Ns!   specify the Fortran compiler type(   R,   t
   __module__R   t   user_optionsR   R   R#   RG   RH   R`   Ri   Rk   Rl   Rr   Rx   RY   R   R   R   R   R   R   R   R   (    (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyR      s6   		2			6T :					R   c           B` s,   e  Z d    Z d   Z d   Z d   Z RS(   c         C` s"   t  j |  _ d |  _ |  t  _ d  S(   NRy   (   R%   t   stdoutt
   sys_stdoutR   (   R   (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyt   __init__  s    	c         C` s#   |  j  j |  |  j | 7_ d  S(   N(   R   t   writeR   (   R   R   (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyR     s    c         C` s   |  j  j   d  S(   N(   R   t   flush(   R   (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyR     s    c         C` s   |  j  t _ d  S(   N(   R   R%   R   (   R   (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyR     s    (   R,   R   R   R   R   R   (    (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyR     s   			("   t
   __future__R    R   R   RZ   R   R   R%   RT   t   distutils.command.configR   R   R   R.   R   t   distutils.file_utilR   R?   R   R   t   numpy.distutils.exec_commandR	   t    numpy.distutils.mingw32ccompilerR
   t    numpy.distutils.command.autodistR   R   R   R   R   t   numpy.distutils.compatR   t   objectR   (    (    (    s=   lib/python2.7/site-packages/numpy/distutils/command/config.pyt   <module>   s&   (

 