
Xc           @` sJ  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 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   exec_command(   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=   /tmp/pip-build-X4mzal/numpy/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(   s   msvcR   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=   /tmp/pip-build-X4mzal/numpy/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 |   } Wn5 | | 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   retR<   (    (    s=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyt   _wrap_methodX   s    		
	c         C` s"   |  j  t j | | | | | f  S(   N(   RG   R   t   _compile(   R   t   bodyt   headerst   include_dirsRC   (    (    s=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyRH   g   s    c      	   C` se  |  j  j d k r| p g  } | p( g  } | d k r d } |  j r xi |  j j pY g  D]U } | j d  r t d d | g d t \ } }	 | s |	 } q 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| rr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 r=t |   n  |  j t j | | | | | | | f  S(   NR   R   R   t   cs   /usr/libt   cygpaths   -wt   use_tees   %s.libs   lib%s.as+   could not find library %r in directories %st   mingw32(   s   f77s   f90(   R   R'   R   t   library_dirst
   startswithR	   t   FalseR4   t	   librariest   ost   patht   joint   isfilet   TrueR   t
   temp_filesR   t   warnR
   RG   R   t   _link(   R   RI   RJ   RK   RS   RP   RC   t   dt   st   ot   libnamet
   fileexistst   libdirt   libfilet   libfile2(    (    s=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyR[   k   sZ    	    		RL   c         C` s    |  j    |  j d | g |  S(   Ns2   /* we need a dummy line to make distutils happy */(   R#   t   try_compile(   R   t   headerRK   RP   RC   (    (    s=   /tmp/pip-build-X4mzal/numpy/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#   Rd   (   R   t   symbolRJ   RK   RI   (    (    s=   /tmp/pip-build-X4mzal/numpy/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#   Rd   (   R   Rg   RJ   RK   RI   (    (    s=   /tmp/pip-build-X4mzal/numpy/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   typeRL   N(   R#   RR   RH   RX   R.   R/   R   t   _clean(   R   t	   type_nameRJ   RK   RP   RI   t   st(    (    s=   /tmp/pip-build-X4mzal/numpy/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;
}
Rk   RL   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   Rl   R   RX   (   R   Rm   RJ   RK   RP   t   expectedRI   Rp   t   lowt   midt   high(    (    s=   /tmp/pip-build-X4mzal/numpy/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#   Rk   RA   R4   R   RV   t   try_link(
   R   t   funcRJ   RK   RS   RP   t   declt   callt	   call_argsRI   (    (    s=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyt
   check_func2  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(   s/  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
            dictionay, 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) {Rv   s	     %s(%s);s     %s;s     return 0;Rw   s   
(   R#   t   itemsR4   RV   Rx   (   R   t   funcsRJ   RK   RS   RP   Rz   R{   R|   RI   t   ft   vRy   RD   (    (    s=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyt   check_funcs_onceT  s4    
	
c         C` s
   t  |   S(   sU   Return the inline keyword recognized by the compiler, empty string
        otherwise.(   R   (   R   (    (    s=   /tmp/pip-build-X4mzal/numpy/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=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyR     s    c         C` s
   t  |   S(   s*   Return True if the C compiler is gcc >= 4.(   R   (   R   (    (    s=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyR     s    c         C` s   t  |  | |  S(   N(   R   (   R   t	   attributeRj   (    (    s=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyR     s    c         C` s   t  |  |  S(   N(   R   (   R   R   (    (    s=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyR     s    c         C` s  t  j d t d d d d l m } m }	 |  j   d \ }
 } yt   } y5 |  j | | | | | |  \ } } } | j	   Wn | j
 } | j	     n Xt j j d |  } t | d	 d d
 | \ } } t t d  rDt j |  }
 t j |  rJt j |  } t j d | f  | t j k rAt  qAqJn | }
 t j d  Wn$ | |	 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    (   R   R   i   Rv   t   .t
   execute_inRN   t   WEXITSTATUSs    subprocess exited with signal %ds   success!s   failure.(   i   Rv   (   t   warningsRZ   t   DeprecationWarningR?   R   R   R#   t
   GrabStdoutR[   t   restoret   dataRT   RU   RV   R	   t   hasattrR   t   WIFSIGNALEDt   WTERMSIGR   t   errort   signalt   SIGINTt   KeyboardInterruptt   infoRl   (   R   RI   RJ   RK   RS   RP   RC   RN   R   R   t   exitcodet   outputt   grabbert   srct   objt   exet
   exitstatust   sig(    (    s=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyt
   get_output  s>    	
		

N(   s
   fcompiler=Ns!   specify the Fortran compiler type(   R,   t
   __module__R   t   user_optionsR   R   R#   RG   RH   R[   Rf   Rh   Ri   Ro   Ru   RR   R}   R   R   R   R   R   R   R   (    (    (    s=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyR      s6   		2			2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(   NRv   (   R%   t   stdoutt
   sys_stdoutR   (   R   (    (    s=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyt   __init__  s    	c         C` s#   |  j  j |  |  j | 7_ d  S(   N(   R   t   writeR   (   R   R   (    (    s=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyR     s    c         C` s   |  j  j   d  S(   N(   R   t   flush(   R   (    (    s=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyR     s    c         C` s   |  j  t _ d  S(   N(   R   R%   R   (   R   (    (    s=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyR     s    (   R,   R   R   R   R   R   (    (    (    s=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyR     s   			(!   t
   __future__R    R   R   RT   R   R   R%   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=   /tmp/pip-build-X4mzal/numpy/numpy/distutils/command/config.pyt   <module>   s$   (

 