U
    ºÛui”  ã                   @   sn   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 d dlZdd„ Zej	dd„ ƒZ
dd„ Zd	d
„ Zdd„ ZdS )é    N)Ú	ccompilerc                 C   s*   t jdkrt ¡ dkr| S tttj| ƒƒS )z<
    Convert paths to strings for legacy compatibility.
    )é   é   ÚWindows)ÚsysÚversion_infoÚplatformÚsystemÚlistÚmapÚosÚfspath)Úpaths© r   úN/tmp/pip-unpacked-wheel-9osl9suo/setuptools/_distutils/tests/test_ccompiler.pyÚ
_make_strs   s    r   c                 C   sd   | d }d}t  ¡ dk}d| }|| }d dd„ |D ƒ¡}t d¡ ¡  d	|¡}|j|d
d |S )Nzfoo.c)zPython.hr   )z	windows.hÚ
c                 s   s   | ]}d |› dV  qdS )z
#include <z>
Nr   )Ú.0Úheaderr   r   r   Ú	<genexpr>   s     zc_file.<locals>.<genexpr>z;
        #headers
        void PyInit_foo(void) {}
        z#headerszutf-8)Úencoding)r   r	   ÚjoinÚtextwrapÚdedentÚlstripÚreplaceÚ
write_text)Ztmp_pathÚc_fileZgen_headersZ
is_windowsZplat_headersZall_headersÚheadersÚpayloadr   r   r   r      s    ÿ ùÿ
r   c                 C   sP   t  ¡ }t ¡ d }| |g¡ | t| gƒ¡ | |g¡ | t| gƒ¡ dS )z‹
    Extensions should build even if set_include_dirs is invoked.
    In particular, compiler-specific paths should not be overridden.
    ÚincludeN)r   Únew_compilerÚ	sysconfigÚ	get_pathsÚset_include_dirsÚcompiler   ©r   ÚcompilerÚpythonr   r   r   Útest_set_include_dirs*   s    r)   c               	   C   sº   t  ¡ } |  d¡st‚|  d¡s$t‚tjdd | jddgdsFt‚W 5 Q R X tjdd | jddgdrrt‚W 5 Q R X |  d¡rŠt‚tjdd | jddgdr¬t‚W 5 Q R X d S )	NÚabortÚexitzincludes is deprecated)Úmatchzstdlib.h)ZincludesZsetuptools_does_not_existzstdio.h)r   r!   Zhas_functionÚAssertionErrorÚpytestZdeprecated_call)r'   r   r   r   Útest_has_function_prototype9   s     ÿr/   c                 C   sd   t  ¡ }t ¡ d }| |g¡ | t| gƒ¡ |j|gks@t‚| t| gƒ¡ |j|gks`t‚dS )z}
    Calling compile multiple times should not change the include dirs
    (regression test for setuptools issue #3591).
    r    N)	r   r!   r"   r#   r$   r%   r   Úinclude_dirsr-   r&   r   r   r   Ú.test_include_dirs_after_multiple_compile_callsP   s    r1   )r   r   r   r"   r   Ú	distutilsr   r.   r   Zfixturer   r)   r/   r1   r   r   r   r   Ú<module>   s   	
