U
    |h                     @   sZ   d Z ddlZddlZddlZddlZddlZddlZddlmZm	Z	 dddZ
dd ZdS )	zFHelpers to check build environment before actual build of scikit-learn    N)customize_compilernew_compilerc           	   
   C   s  t  }t| tjd}t }zzt| tdd}|	|  W 5 Q R X t
d |jdgd|d ttjdd|j }|j|d||d d	tjkrtd
}|tjjpd }ng }W n tk
r    Y nX W 5 t| X W 5 Q R X |S )z.Check that some C code can be compiled and run.ztest_program.cwobjects)
output_dirextra_postargs*Ztest_program)extra_preargsr   ZPYTHON_CROSSENVz./test_programzutf-8)r   r   ospathabspathtempfileTemporaryDirectorychdiropenwritemkdircompileglobjoinZobj_extensionZlink_executableenviron
subprocesscheck_outputdecodesysstdoutencoding
splitlines	Exception)	coder
   r   Z	ccompiler	start_dirZtmp_dirfr   output r$   J/tmp/pip-unpacked-wheel-ig1s1lm8/sklearn/_build_utils/pre_build_helpers.pycompile_test_program   s:    


  

r&   c                  C   s$   dt jkrdS td} t|  dS )z-Check basic compilation and linking of C codeZPYODIDE_PACKAGE_ABINzX        #include <stdio.h>
        int main(void) {
        return 0;
        }
        )r   r   textwrapdedentr&   )r    r$   r$   r%   basic_check_build=   s    

r)   )NN)__doc__r   r   r   r   r   r'   Zsetuptools.command.build_extr   r   r&   r)   r$   r$   r$   r%   <module>   s   
0