U
    Mf9                     @   s   d Z ddlmZmZmZ ddlZddlmZmZ ddl	T ddl
mZ ddlmZ ddlmZ ejd d	k rxd
dlmZ n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.

    )divisionabsolute_importprint_functionN)DistutilsExecErrorCompileError)*)replace_method)get_exception)_commandline_dep_string      )logc              	   C   s  | j }|d dkrFd|kr$|d d|kr6|d |dg7 }|| _ dtjkrddlm} dtjd  }	d|dd  }
d| j }|	|kr||
|	}| | _ d| j	}|	|kr| |	  | _	d	tj
| j d |f }t| d
drdd|d g}ng }z*| j| j | |d|g | | |d W n( tk
rd   tt }t|Y nX |rt|d d}|t||| W 5 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displayaN)compiler_soremoveosenvirondistutils.sysconfigr   joinsplitreplace	linker_sopathbasenamegetattrspawnr   strr	   r   openwriter
   )selfobjsrcextZcc_argsZextra_postargsZpp_optsZccompr   optZgcv_optZccomp_sZllink_sr   depsmsgf r,   A/tmp/pip-unpacked-wheel-rs3wi1eo/numpy/distutils/unixccompiler.pyUnixCCompiler__compile   sF    






r.   _compilec           
   	   C   s@  |  ||\}}| j||d}| ||r0zt| W n ttfk
rR   Y nX | tj	| || j
 }|r|dd }|dd }dtj| jd t||f }| j| j|g | |d qp| jr<dtj| jd |f }z| j| j|g |d W n( tk
r,   tt }	t|	Y nX nt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))Z_fix_object_argsZlibrary_filenameZ
_need_linkr   unlinkIOErrorOSErrormkpathr   dirnameobjectsr   archiverlenr    Zranlibr   r!   r	   LibErrorr   debug)
r$   r7   Zoutput_libnamer0   r;   Ztarget_langZoutput_filenameZtmp_objectsr   r*   r,   r,   r-   UnixCCompiler_create_static_libG   sD    
 

r<   Zcreate_static_lib)Nr   N)__doc__
__future__r   r   r   r   distutils.errorsr   r   Zdistutils.unixccompilerZnumpy.distutils.ccompilerr   Znumpy.distutils.compatr	   Znumpy.distutils.misc_utilr
   sysversion_info r   Znumpy.distutilsr.   ZUnixCCompilerr<   r,   r,   r,   r-   <module>   s&   /     
C