ó
¢áSc           @` sÆ  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	 Td  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 d  d
 l m Z d  d l m Z m Z m Z m Z d  d l m Z d „  Z d d „ Z! e e" d e! ƒ d  d d „ Z# e e" d e# ƒ d d d d  d d d d „ Z$ e e" d e$ ƒ dH d „ Z% e e" d e% ƒ d „  Z& d „  Z' e e" d e' ƒ d  d „ Z( e e" d e( ƒ d d d d „ Z) e* d  g d „ Z+ e e" d e+ ƒ d  „  Z, e e" d! e, ƒ dI e- d% <dJ e- d( <dK e- d+ <dL e- d/ <e j. dM dN dO dP f 7_. e j/ d1 k r¥dQ e- d5 <e ƒ  r¥e j0 d6 ƒ dS e j. e _. q¥n  e1 Z2 d d d  d  d  d8 „ Z1 e1 e _1 e3 Z4 d9 „  Z3 e3 e _3 xV d: d; d< d= d> g D]? Z5 e j6 j7 d? e5 d@ ƒ Z8 e8 d k	 rúe9 e8 dA e3 ƒ qúqúWe: Z; dB „  Z: e: e _: d  d l Z d  d l< Z< e j= dC e< j> ƒ Z? e j= dD ƒ Z@ e j= dE ƒ ZA e j= dF ƒ ZB dG „  ZC eC e _C d S(T   i    (   t   divisiont   absolute_importt   print_functionN(   t   copy(   t   *(   t	   ccompiler(   t   DistutilsExecErrort   DistutilsModuleErrort   DistutilsPlatformError(   t   customize_compiler(   t   LooseVersion(   t   log(   t   exec_command(   t	   cyg2win32t   is_sequencet   mingw32t
   quote_args(   t   get_exceptionc         ` sN   t  j d d k  r+ t j ˆ  d  |  ƒ } n ‡  f d †  } t |  | | ƒ d  S(   Ni    i   c         ` s   ˆ  |  | | Ž S(   N(    (   t   selft   argst   kw(   t   func(    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   <lambda>   s    (   t   syst   version_infot   typest
   MethodTypet   Nonet   setattr(   t   klasst   method_nameR   t   m(    (   R   sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   replace_method   s    c         C` så   | d k r9 | } t | ƒ r9 d j t | ƒ ƒ } q9 n  t j | ƒ t | ƒ \ } } | rá t | ƒ r‚ d j t | ƒ ƒ } n  y t | ƒ Wn t k
 r£ n Xt	 j
 d | ƒ r¿ d } n d } t d | | | f ƒ ‚ n  d S(   s¯  
    Execute a command in a sub-process.

    Parameters
    ----------
    cmd : str
        The command to execute.
    display : str or sequence of str, optional
        The text to add to the log file kept by `numpy.distutils`.
        If not given, `display` is equal to `cmd`.

    Returns
    -------
    None

    Raises
    ------
    DistutilsExecError
        If the command failed, i.e. the exit status was not 0.

    t    s   Too many open filess2   
Try rerunning setup command until build succeeds.t    s)   Command "%s" failed with exit status %d%sN(   R   R   t   joint   listR   t   infoR   t   printt   UnicodeErrort   ret   searchR   (   R   t   cmdt   displayt   st   ot   msg(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   CCompiler_spawn    s"    	t   spawnR"   c         C` sG  | d k r d } n  g  } x%| D]} t j j t j j | ƒ ƒ \ } } t j j | ƒ d } | t j j | ƒ } | j d ƒ rÓ | j d ƒ d } | |  }	 t j j	 t j j
 |	 ƒ ƒ }	 |	 | | } n  | |  j k rû t d | | f ƒ ‚ n  | rt j j	 | ƒ } n  t j j | | |  j ƒ }
 | j |
 ƒ q" W| S(   sÞ  
    Return the name of the object files for the given source files.

    Parameters
    ----------
    source_filenames : list of str
        The list of paths to source files. Paths can be either relative or
        absolute, this is handled transparently.
    strip_dir : bool, optional
        Whether to strip the directory from the returned paths. If True,
        the file name prepended by `output_dir` is returned. Default is False.
    output_dir : str, optional
        If given, this path is prepended to the returned paths to the
        object files.

    Returns
    -------
    obj_names : list of str
        The list of paths to the object files corresponding to the source
        files in `source_filenames`.

    R"   i   s   ..i   s"   unknown file type '%s' (from '%s')N(   R   t   ost   patht   splitextt   normpatht
   splitdrivet   isabst
   startswitht   rfindt   basenamet   abspatht   src_extensionst   UnknownFileErrorR#   t   obj_extensiont   append(   R   t   source_filenamest	   strip_dirt
   output_dirt	   obj_namest   src_namet   baset   extt   it   dt   obj_name(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   CCompiler_object_filenamesL   s&    	$
t   object_filenamesc	         C` sQ  | s
 g  St  j d d k  r0 d d l m }	 n d d l m }	 t |  |	 ƒ rÆ g  }
 x\ d d d g D]K } t |  d | ƒ } | d k r� qe n  |
 j d	 | d
 j	 | ƒ f ƒ qe Wd j	 |
 ƒ }
 n |  j
 } d d
 j	 | ƒ f }
 t j |
 ƒ |  j | | | | | | ƒ \ } } } } } |  j | | | ƒ } d d
 j	 | ƒ }
 | rg|
 d d
 j	 | ƒ 7}
 n  t j |
 ƒ t |  |	 ƒ rt | j ƒ  ƒ } xµ | D]k } | | k rœ| | \ } } |  j d k rèt | ƒ } t | ƒ } n  |  j | | | | | | ƒ qœqœWn? x< | j ƒ  D]. \ } \ } } |  j | | | | | | ƒ qW| S(   sÁ  
    Compile one or more source files.

    Please refer to the Python distutils API reference for more details.

    Parameters
    ----------
    sources : list of str
        A list of filenames
    output_dir : str, optional
        Path to the output directory.
    macros : list of tuples
        A list of macro definitions.
    include_dirs : list of str, optional
        The directories to add to the default include file search path for
        this compilation only.
    debug : bool, optional
        Whether or not to output debug symbols in or alongside the object
        file(s).
    extra_preargs, extra_postargs : ?
        Extra pre- and post-arguments.
    depends : list of str, optional
        A list of file names that all targets depend on.

    Returns
    -------
    objects : list of str
        A list of object file names, one per source file `sources`.

    Raises
    ------
    CompileError
        If compilation fails.

    i    i   i   (   t	   FCompilert   f77t   f90t   fixt	   compiler_s   Fortran %s compiler: %sR!   s   
s   C compiler: %s
s   compile options: '%s's   
extra options: '%s't   absoftN(   R   R   t	   fcompilerRK   t   numpy.distutils.fcompilert
   isinstancet   getattrR   R>   R#   t   compiler_soR   R%   t   _setup_compilet   _get_cc_argsR$   t   keyst   compiler_typeR   t   _compilet   items(   R   t   sourcesRA   t   macrost   include_dirst   debugt   extra_preargst   extra_postargst   dependsRK   R+   t   fct   fcompt   ccompt   objectst   pp_optst   buildt   cc_argst   objects_to_buildt   objt   srcRE   (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   CCompiler_compile{   sF    )$	& t   compilec         ` sK  t  j d |  j j ˆ  j j f ƒ ‡  ‡ f d †  } | d ƒ rT |  j ˆ  j ƒ n  | d ƒ r� x* ˆ  j D] \ } } |  j | | ƒ qj Wn  | d ƒ r½ x! ˆ  j D] } |  j	 | ƒ q£ Wn  | d ƒ rã |  j
 |  j ˆ  j ƒ n  | d ƒ r	|  j |  j ˆ  j ƒ n  | d ƒ r(|  j ˆ  j ƒ n  | d	 ƒ rG|  j ˆ  j ƒ n  d
 S(   sã  
    Customize compiler using distutils command.

    Parameters
    ----------
    cmd : class instance
        An instance inheriting from `distutils.cmd.Command`.
    ignore : sequence of str, optional
        List of `CCompiler` commands (without ``'set_'``) that should not be
        altered. Strings that are checked for are:
        ``('include_dirs', 'define', 'undef', 'libraries', 'library_dirs',
        'rpath', 'link_objects')``.

    Returns
    -------
    None

    s   customize %s using %sc         ` s"   t  ˆ  |  d  ƒ d  k	 o! |  ˆ k S(   N(   RT   R   (   t   attr(   R*   t   ignore(    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   allowé   s    R^   t   definet   undeft	   librariest   library_dirst   rpatht   link_objectsN(   R   R%   t	   __class__t   __name__t   set_include_dirsR^   Rr   t   define_macroRs   t   undefine_macrot   set_librariesRt   t   set_library_dirsRu   t   set_runtime_library_dirsRv   t   set_link_objectsRw   (   R   R*   Rp   Rq   t   namet   valuet   macro(    (   R*   Rp   sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   CCompiler_customize_cmdÔ   s&    t   customize_cmdc   	   
   C` s  g  } d } t  |  j j ƒ  ƒ } xH d d d d d d d d	 d
 d g
 D]" } | | k rF | j | ƒ qF qF Wx] | D]U } t |  | ƒ rs t |  | ƒ } t | t | ƒ ƒ } | j | t | ƒ f ƒ qs qs Wg  } d t | d ƒ d } x | D] } | j | | ƒ qñ Wd j	 | ƒ S(   Ni    t   versionRt   Ru   t   object_switcht   compile_switchR^   Rr   Rs   Rv   Rw   s   %-i   s   s = %ss   
(
   R$   t   executablesRX   R>   t   hasattrRT   t   maxt   lent   reprR#   (	   t   compilert   propst   mxRX   t   keyt   vt   linest   formatt   prop(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   _compiler_to_stringÿ   s$     c         C` sj   y |  j  ƒ  Wn n Xt j j d k  rf t d d ƒ t |  j ƒ t t |  ƒ ƒ t d d ƒ n  d S(   s×   
    Print the compiler customizations to stdout.

    Parameters
    ----------
    None

    Returns
    -------
    None

    Notes
    -----
    Printing is only done if the distutils log threshold is < 2.

    i   R   iP   N(   t   get_versionR   t   _global_logt	   thresholdR&   Rx   R–   (   R   (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   CCompiler_show_customization  s    t   show_customizationc         C` s(  t  j d |  j j ƒ t |  ƒ | r$y |  j j d ƒ Wn t t f k
 rT n Xt	 |  d ƒ rá d |  j
 d k rá |  j s!|  j
 d j d ƒ r¥ d \ } } n d \ } } |  j
 d j | | ƒ g |  j
 d	 |  _ q!q$t	 |  d ƒ r
t  j d
 |  j
 f ƒ n  t  j d |  j j ƒ n  d S(   sm  
    Do any platform-specific customization of a compiler instance.

    This method calls `distutils.sysconfig.customize_compiler` for
    platform-specific customization, as well as optionally remove a flag
    to suppress spurious warnings in case C++ code is being compiled.

    Parameters
    ----------
    dist : object
        This parameter is not used for anything.
    need_cxx : bool, optional
        Whether or not C++ has to be compiled. If so (True), the
        ``"-Wstrict-prototypes"`` option is removed to prevent spurious
        warnings. Default is False.

    Returns
    -------
    None

    Notes
    -----
    All the default options used by distutils can be extracted with::

      from distutils import sysconfig
      sysconfig.get_config_vars('CC', 'CXX', 'OPT', 'BASECFLAGS',
                                'CCSHARED', 'LDSHARED', 'SO')

    s   customize %ss   -Wstrict-prototypesRŽ   t   cci    t   gccs   g++s   c++i   s   #### %s #######s   Missing compiler_cxx fix for N(   s   gccs   g++(   s   ccs   c++(   R   R%   Rx   Ry   R	   RU   t   removet   AttributeErrort
   ValueErrorRŠ   RŽ   t   compiler_cxxR7   t   replacet   warn(   R   t   distt   need_cxxt   at   b(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   CCompiler_customize8  s$    
"	t	   customizes   [-.\d]+c         ` s   ‡  ‡ ‡ f d †  } | S(   sU  
    Simple matching of version numbers, for use in CCompiler and FCompiler.

    Parameters
    ----------
    pat : str, optional
        A regular expression matching version numbers.
        Default is ``r'[-.\d]+'``.
    ignore : str, optional
        A regular expression matching patterns to skip.
        Default is ``''``, in which case nothing is skipped.
    start : str, optional
        A regular expression matching the start of where to start looking
        for version numbers.
        Default is ``''``, in which case searching is started at the
        beginning of the version string given to `matcher`.

    Returns
    -------
    matcher : callable
        A function that is appropriate to use as the ``.version_match``
        attribute of a `CCompiler` class. `matcher` takes a single parameter,
        a version string.

    c         ` s·   | j  d d ƒ } d } ˆ rI t j ˆ | ƒ } | s: d  S| j ƒ  } n  x^ t r© t j ˆ | | ƒ } | sr d  Sˆ  r¥ t j ˆ  | j d ƒ ƒ r¥ | j ƒ  } qL n  PqL W| j d ƒ S(   Ns   
R!   i    (   R¢   R(   t   matchR   t   endt   TrueR)   t   group(   R   t   version_stringt   posR   (   Rp   t   patt   start(    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   matcherŒ  s     	!(    (   R°   Rp   R±   R²   (    (   Rp   R°   R±   sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   simple_version_matchr  s    c         ` s  | r t  |  d ƒ r |  j S|  j ƒ  y |  j } Wn t k
 rH d SX| s[ | d r_ d Sy |  j } WnB t k
 r° y |  j ‰  Wn t k
 r� d SX‡  f d †  } n Xt | d d ƒ\ } } d } | | k rÿ | | ƒ } | rÿ t	 | ƒ } qÿ n  | |  _ | S(   s…  
    Return compiler version, or None if compiler is not available.

    Parameters
    ----------
    force : bool, optional
        If True, force a new determination of the version, even if the
        compiler already has a version attribute. Default is False.
    ok_status : list of int, optional
        The list of status values returned by the version look-up process
        for which a version string is returned. If the status value is not
        in `ok_status`, None is returned. Default is ``[0]``.

    Returns
    -------
    version : str or None
        Version string, in the format of `distutils.version.LooseVersion`.

    R†   i    c         ` s/   t  j ˆ  |  ƒ } | s d  S| j d ƒ } | S(   NR†   (   R(   Rª   R   R­   (   R®   R   R†   (   R°   (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyR²   Å  s
    t   use_teeN(
   RŠ   R†   t   find_executablest   version_cmdRŸ   R   t   version_matcht   version_patternR   R
   (   R   t   forcet	   ok_statusR¶   R²   t   statust   outputR†   (    (   R°   sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   CCompiler_get_version¡  s2    
	R—   c         C` s¯   |  j  d k r |  St |  ƒ } | j d g | j d | _ t j j d ƒ r� d | j d k r� | j d | j d g | j d | _ n | j d g | j d | _ | S(   s²   
    Return the C++ compiler.

    Parameters
    ----------
    None

    Returns
    -------
    cxx : class instance
        The C++ compiler, as a `CCompiler` instance.

    t   msvci    i   t   aixt	   ld_so_aixi   (   RY   R   R¡   RU   R   t   platformR7   t	   linker_so(   R   t   cxx(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   CCompiler_cxx_compilerØ  s     %t   cxx_compilert   intelccompilert   IntelCCompilers(   Intel C Compiler for 32-bit applicationst   intelt   IntelItaniumCCompilers7   Intel C Itanium Compiler for Itanium-based applicationst   intelet   IntelEM64TCCompilers(   Intel C Compiler for 64-bit applicationst   intelemt   pathccompilert   PathScaleCCompilers2   PathScale Compiler for SiCortex-based applicationst   pathccs   linux.*t   win32t   mingw32ccompilert   Mingw32CCompilers>   Mingw32 port of GNU C Compiler for Win32(for MSC built Python)R   s+   Setting mingw32 as default compiler for nt.t   ntc         C` s£  |  d  k r t j }  n  y2 | d  k r6 t |  ƒ } n  t | \ } } } WnD t k
 r� d |  } | d  k	 r� | d | } n  t | ƒ ‚ n Xd | } y t | ƒ Wn� t k
 r,t	 t
 ƒ  ƒ } t j d t	 | ƒ ƒ | d } y t | ƒ Wq-t k
 r(t	 t
 ƒ  ƒ } t d | ƒ ‚ q-Xn Xy! t j | }	 t |	 ƒ | }
 Wn+ t k
 r{t d d | | f ƒ ‚ n X|
 d  | | ƒ } t j d	 |
 ƒ | S(
   Ns5   don't know how to compile C/C++ code on platform '%s's    with '%s' compilers   numpy.distutils.s,   %s in numpy.distutils; trying from distutilsi   s4   can't compile C/C++ code: unable to load module '%s's4   can't compile C/C++ code: unable to find class '%s' s   in module '%s's   new_compiler returns %s(   R   R1   R�   t   get_default_compilert   compiler_classt   KeyErrorR   t
   __import__t   ImportErrort   strR   R   R%   R   R   t   modulest   varsR_   (   t   platRŽ   t   verboset   dry_runR¹   t   module_namet
   class_namet   long_descriptionR.   t   moduleR   (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   new_compiler  sD    

	
c         C` sw   t  | ƒ } t  | ƒ } t |  | | | ƒ } g  } x= | D]5 } t | ƒ rb | j t | ƒ ƒ q: | j | ƒ q: W| S(   N(   R   t   _distutils_gen_lib_optionsR   t   extendR$   R>   (   RŽ   Ru   t   runtime_library_dirsRt   t   rt   lib_optsRF   (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   gen_lib_options9  s    	R¾   t   bcppt   cygwinct   emxct   unixcs
   distutils.RŽ   Ré   c         C` s   t  | ƒ } t |  | ƒ S(   N(   R   t!   _distutils_gen_preprocess_options(   R]   R^   (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   gen_preprocess_optionsP  s    s   [^\\\'\"%s ]*s   '(?:[^'\\]|\\.)*'s   "(?:[^"\\]|\\.)*"s   \sc         C` sö  |  j  ƒ  }  g  } d } x×|  rñt j |  | ƒ } | j ƒ  } | t |  ƒ k rf | j |  |  ƒ Pn  |  | t j k r£ | j |  |  ƒ |  | j ƒ  }  d } n(|  | d k rÖ |  |  |  | d }  | d } nõ |  | d k rû t	 j |  | ƒ } n9 |  | d k r t
 j |  | ƒ } n t d |  | ƒ ‚ | d  k rWt d |  | ƒ ‚ n  | j ƒ  \ } } t j |  | d | d !ƒ r¿|  |  |  | d | d !|  | }  | j ƒ  d } n | j ƒ  } | t |  ƒ k r | j |  ƒ Pq q W| S(	   Ni    s   \i   t   't   "s!   this can't happen (bad char '%c')s"   bad string (mismatched %s quotes?)i   (   t   stript   _wordchars_reRª   R«   RŒ   R>   t   stringt
   whitespacet   lstript
   _squote_ret
   _dquote_ret   RuntimeErrorR   R    t   spant   _has_white_reR)   (   R,   t   wordsR¯   R   R«   t   beg(    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   split_quoted`  s@    		%(    (   s   intelccompilers   IntelCCompilers(   Intel C Compiler for 32-bit applications(   s   intelccompilers   IntelItaniumCCompilers7   Intel C Itanium Compiler for Itanium-based applications(   s   intelccompilers   IntelEM64TCCompilers(   Intel C Compiler for 64-bit applications(   s   pathccompilers   PathScaleCCompilers2   PathScale Compiler for SiCortex-based applications(   s   linux.*s   intel(   s   linux.*s   intele(   s   linux.*s   intelem(   s   linux.*s   pathcc(   s   mingw32ccompilers   Mingw32CCompilers>   Mingw32 port of GNU C Compiler for Win32(for MSC built Python)(   s   nts   mingw32(   (   s   nts   mingw32(D   t
   __future__R    R   R   R(   R1   R   R   R   t   distutils.ccompilert	   distutilsR   t   distutils.errorsR   R   R   t   distutils.sysconfigR	   t   distutils.versionR
   t   numpy.distutilsR   t   numpy.distutils.exec_commandR   t   numpy.distutils.misc_utilR   R   R   R   t   numpy.distutils.compatR   R    R   R/   t	   CCompilerRI   Rm   R„   R–   Rš   R¨   R³   t   FalseR½   RÄ   RÕ   t   _default_compilersRÁ   R%   Rã   t   _distutils_new_compilerRé   Rä   t   _ccRÚ   t   gett   _mR   Rï   Rî   Rô   Rn   Rõ   Ró   R÷   Rø   Rû   Rþ   (    (    (    sS   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/numpy/distutils/ccompiler.pyt   <module>   sž   
"		*-	U)		#8/5	 
 
 
 

 
	%						/