3
h                 @   s~   d Z ddl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	 Ze	ed
e dddZe	ede dS )z>
unixccompiler - can handle very long argument lists for ar.

    N)CompileErrorDistutilsExecErrorLibError)UnixCCompiler)replace_method)_commandline_dep_string)logc             C   s  | j }|d dkrFd|kr$|jd d|kr6|jd |dg7 }|| _ dtjkrddlm} djtjd j }	dj|dd j }
dj| j }|	|kr|j|
|	}|j | _ dj| j	}|	|kr|j |	j  | _	d	tj
j| j d |f }t| d
drdd|d g}ng }y*| j| j | |d|g | | |d W n4 tk
rp } zt|}t|W Y dd}~X nX |rt|d d}|jt||| W dQ R X dS )z9Compile a single source files with a Unix-style compiler.r   ZaCCz-Aez-Aaz-AAOPT)get_config_vars z%s: %sZ_auto_dependsFz-MMDz-MFz.dz-o)displayNa)compiler_soremoveosenvirondistutils.sysconfigr
   joinsplitreplace	linker_sopathbasenamegetattrspawnr   strr   openwriter   )selfobjsrcextcc_argsextra_postargspp_optsZccompr
   optZgcv_optZccomp_sZllink_sr   depsemsgf r*   >/tmp/pip-build-fibhr3ey/numpy/numpy/distutils/unixccompiler.pyUnixCCompiler__compile   s@    




r,   _compilec             C   sP  | j ||\}}| j||d}| j||r@ytj| W n ttfk
rR   Y nX | jtjj	| || j
 }xZ|r|dd }|dd }dtjj| jd t||f }| j| j|g | |d qrW | jrLdtjj| jd |f }y| j| j|g |d W n4 tk
r< }	 zt|	}
t|
W Y dd}	~	X nX ntjd| dS )	a  
    Build a static library in a separate sub-process.

    Parameters
    ----------
    objects : list or tuple of str
        List of paths to object files used to build the static library.
    output_libname : str
        The library name as an absolute or relative (if `output_dir` is used)
        path.
    output_dir : str, optional
        The path to the output directory. Default is None, in which case
        the ``output_dir`` attribute of the UnixCCompiler instance.
    debug : bool, optional
        This parameter is not used.
    target_lang : str, optional
        This parameter is not used.

    Returns
    -------
    None

    )
output_dirN2   z %s: adding %d object files to %sr   )r   z%s:@ %szskipping %s (up-to-date))_fix_object_argslibrary_filename
_need_linkr   unlinkIOErrorOSErrormkpathr   dirnameobjectsr   archiverlenr   Zranlibr   r   r   r   debug)r   r8   output_libnamer.   r;   target_langoutput_filenameZtmp_objectsr   r'   r(   r*   r*   r+   UnixCCompiler_create_static_lib@   s8    
r?   create_static_lib)Nr   N)__doc__r   Zdistutils.errorsr   r   r   Zdistutils.unixccompilerr   Znumpy.distutils.ccompilerr   Znumpy.distutils.misc_utilr   Znumpy.distutilsr   r,   r?   r*   r*   r*   r+   <module>   s   /
B