ó
ÿ¼÷Xc           @` sF  d  Z  d d l m Z m Z m Z d d l Z d d l m Z d d l Z d d l m	 Z
 d d l m Z m Z 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 m Z m Z e
 j Z xV e e e ƒ ƒ D]B Z e e d d k ræ e e d d f e e d e e <qæ qæ Wd e
 f d „  ƒ  YZ	 d S(   sC    Modified version of build_clib that handles fortran source files.
i    (   t   divisiont   absolute_importt   print_functionN(   t   glob(   t
   build_clib(   t   DistutilsSetupErrort   DistutilsErrort   DistutilsFileError(   t   log(   t   newer_group(   t   filter_sourcest   has_f_sourcest   has_cxx_sourcest   all_stringst   get_lib_source_filest   is_sequencet   get_numpy_include_dirss
   build-clibs
   build-tempt   =i   R   c           B` s|   e  Z d  Z e j d d d g Z e j d g Z d	 „  Z d
 „  Z d „  Z	 d „  Z
 d „  Z d „  Z d „  Z d „  Z RS(   s1   build C/C++/F libraries used by Python extensionss
   fcompiler=s!   specify the Fortran compiler typet   inplacet   is   Build in-places	   parallel=t   js   number of parallel jobsc         C` s,   t  j |  ƒ d  |  _ d |  _ d  |  _ d  S(   Ni    (   t   old_build_clibt   initialize_optionst   Nonet	   fcompilerR   t   parallel(   t   self(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/command/build_clib.pyR   '   s    		c         C` sc   |  j  rB y t |  j  ƒ |  _  WqB t k
 r> t d ƒ ‚ qB Xn  t j |  ƒ |  j d d ƒ d  S(   Ns)   --parallel/-j argument must be an integert   buildR   (   s   parallels   parallel(   R   t   intt
   ValueErrorR   t   finalize_optionst   set_undefined_options(   R   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/command/build_clib.pyR   -   s    	c         C` s:   x3 |  j  D]( \ } } t | j d g  ƒ ƒ r
 t Sq
 Wt S(   Nt   sources(   t	   librariesR   t   gett   Truet   False(   R   t   lib_namet
   build_info(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/command/build_clib.pyt   have_f_sources6   s    c         C` s:   x3 |  j  D]( \ } } t | j d g  ƒ ƒ r
 t Sq
 Wt S(   NR    (   R!   R   R"   R#   R$   (   R   R%   R&   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/command/build_clib.pyt   have_cxx_sources<   s    c         C` sb  |  j  s d  Sg  } |  j d ƒ xK |  j  D]@ \ } } | j d d  ƒ } | r* | | k r* | j | ƒ q* q* Wd d l m } | d |  j d |  j d |  j	 ƒ |  _ |  j j
 |  j d |  j ƒ  ƒ|  j  } d  |  _  |  j j |  ƒ | |  _  |  j j ƒ  |  j ƒ  r½d d	 l m } | d |  j d
 |  j d |  j d |  j	 d d | k d |  j ƒ |  _ |  j d  k	 rÆ|  j j
 |  j ƒ |  j  } d  |  _  |  j j |  ƒ | |  _  |  j j ƒ  qÆn	 d  |  _ |  j |  j  ƒ |  j r^x| |  j j D]k } |  j j | j ƒ } t j j |  j | ƒ }	 t j j | j | ƒ }
 |  j | j ƒ t  j! |	 |
 ƒ qìWn  d  S(   Nt	   build_srct   languagei    (   t   new_compilert   compilert   dry_runt   forcet   need_cxx(   t   new_fcompilert   verboset
   requiref90t   f90t
   c_compiler("   R!   t   run_commandR"   R   t   appendt   distutils.ccompilerR+   R,   R-   R.   t	   customizet   distributionR(   t   customize_cmdt   show_customizationR'   t   numpy.distutils.fcompilerR0   R   R1   t   _f_compilert   build_librariesR   t   installed_librariest   library_filenamet   namet   ost   patht   joinR   t
   target_dirt   mkpatht   shutilt   copy(   R   t	   languagesR%   R&   t   lR+   R!   R0   t   libnamet   sourcet   target(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/command/build_clib.pyt   runB   sV    	 												c         C` sA   |  j  |  j ƒ g  } x$ |  j D] } | j t | ƒ ƒ q  W| S(   N(   t   check_library_listR!   t   extendR   (   R   t	   filenamest   lib(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/command/build_clib.pyt   get_source_files|   s
    c         C` s.   x' | D] \ } } |  j  | | | ƒ q Wd  S(   N(   t   build_a_library(   R   R!   R%   R&   (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/command/build_clib.pyR>   ƒ   s    c   "      C` s  |  j  } |  j } | j d ƒ } | d  k s: t | ƒ rU t d d d | ƒ ‚ n  t | ƒ } t | ƒ \ } } }	 }
 |
 p– | j d d ƒ d k } g  } | rµ | j d ƒ n  | rË | j d ƒ n  | rá | j d ƒ n |	 r÷ | j d	 ƒ n  | | d
 <| j	 | d |  j
 ƒ} | | j d g  ƒ } |  j pGt | | d ƒ s^t j d | ƒ d  St j d | ƒ | j d i  ƒ } | d  k	 r<| r<t j d | f ƒ d d l m } | d | j d |  j d |  j d |  j d | d |  j  ƒ } | d  k	 r<|  j } | j d ƒ j ƒ  } | j | ƒ | j | ƒ q<n  |	 sH|
 rg| d  k rgt d | ƒ ‚ n  | d  k	 r¦| j d ƒ p…g  | _ | j d ƒ pg  | _ n  | j d ƒ } | j d ƒ } | d  k rÙg  } n  | j d ƒ pëg  } | j t ƒ  ƒ | j d  ƒ pg  } t j  j! | ƒ } | r;|  j" | ƒ n  | j d! k r]| | 7} g  } n  g  } | r¬t j d" ƒ | j# | d |  j$ d | d | d# |  j d$ | ƒ} n  | rt j d% ƒ | j% ƒ  } | j# | d |  j$ d | d | d# |  j d$ | ƒ} | j | ƒ n  |	 s|
 räg  } g  } | rc| j& d  k rJt' d& ƒ } n  | | j( | | ƒ 7} n  |
 r°t j d' ƒ | | j# |
 d |  j$ d | d | d# |  j d$ | ƒ7} n  | r”|  j j& d  k r”xÉ t' d& ƒ D]¸ } | | k ríqÕn  t j  j) | | ƒ } t j  j* | ƒ t j  j* | ƒ k r,qÕn  t j  j+ | ƒ rNt j, | ƒ n  y |  j- | | ƒ WqÕt. k
 rŒt j/ d( | | f ƒ qÕXqÕWn  |	 rêt j d) ƒ | | j# |	 d |  j$ d | d | d# |  j d$ | ƒ7} qên g  } | j | ƒ | j0 | | d |  j
 d# |  j ƒ| j d* g  ƒ } x< | D]4 \ }  }! |  | k r2| j |! j d* g  ƒ ƒ q2q2W| r}| | d* <n  d  S(+   NR    s&   in 'libraries' option (library '%s'), s&   'sources' must be present and must be s   a list of source filenamesR*   t   cR3   s   c++t   f77t   source_languagest
   output_dirt   dependst   newers"   skipping '%s' library (up-to-date)s   building '%s' libraryt	   config_fcsE   using additional config_fc from setup script for fortran compiler: %si    (   R0   R,   R1   R-   R.   R2   R4   s<   library %s has Fortran sources but no Fortran compiler foundt   extra_f77_compile_argst   extra_f90_compile_argst   macrost   include_dirst   extra_compiler_argst   module_dirst   msvcs   compiling C sourcest   debugt   extra_postargss   compiling C++ sourcess   *.mods#   compiling Fortran 90 module sourcess   failed to move %r to %rs   compiling Fortran sourcesR!   (1   R,   R=   R"   R   R   R   t   listR
   R6   R@   R   R.   R	   R   Rc   t   infoR<   R0   t   compiler_typeR1   R-   R9   t   get_option_dictRH   t   updateR8   R   R\   R]   RP   R   RB   RC   t   dirnameRF   t   compilet
   build_tempt   cxx_compilert   module_dir_switchR   t   module_optionsRD   t   abspatht   isfilet   removet	   move_fileR   t   warnt   create_static_lib("   R   R&   R%   R!   R,   R   R    t	   c_sourcest   cxx_sourcest	   f_sourcest   fmodule_sourcesR2   RW   t   lib_fileRY   R[   R0   t   distt   base_config_fcR^   R_   Rd   Ra   t   module_build_dirt   objectsRm   t   cxx_objectst	   f_objectst   existing_modulest   ft   tt   clib_librariest   lnamet   binfo(    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/command/build_clib.pyRT   ‡   s   		    
						 
									$				
 N(   s
   fcompiler=Ns!   specify the Fortran compiler type(   s   inplaceR   s   Build in-place(   s	   parallel=R   s   number of parallel jobs(   t   __name__t
   __module__t   descriptionR   t   user_optionsR   t   boolean_optionsR   R   R'   R(   RN   RS   R>   RT   (    (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/command/build_clib.pyR      s      
						:		(   s
   build-clibs
   build-temp(    t   __doc__t
   __future__R    R   R   RB   R   RG   t   distutils.command.build_clibR   R   t   distutils.errorsR   R   R   t   numpy.distutilsR   t   distutils.dep_utilR	   t   numpy.distutils.misc_utilR
   R   R   R   R   R   R   RŠ   t   _lt   ranget   lent   _i(    (    (    sA   /tmp/pip-build-2Vcwy8/numpy/numpy/distutils/command/build_clib.pyt   <module>   s   4	,