U
    ¸mœdZ  ã                   @   s¨   d Z ddlZddlZddlZddlmZ ddlZddlZddl	m
Z
 dd„ Zej dd	d
gddg¡ejjdd�dd„ ƒƒZdd„ Zdd„ Zej dddg¡dd„ ƒZdS )z0See https://github.com/numpy/numpy/pull/11937.

é    N)Úimport_moduleé   )Úutilc                   C   s(   t  ¡ st d¡ t  ¡ s$t d¡ d S )NzNeeds C compilerzNeeds FORTRAN 77 compiler)r   Zhas_c_compilerÚpytestÚskipZhas_f77_compiler© r   r   ú_/home/sam/Atlas/atlas_env/lib/python3.8/site-packages/numpy/f2py/tests/test_compile_function.pyÚsetup_module   s    
r	   Ú
extra_argsz--nooptz--debugz--noopt --debugÚ z$Imported module seems never deleted.)Úreasonc           
   
   C   s¬   d}t  ¡ }t  ¡ }t ¡ }tj |tt 	¡ ƒd ¡}|d fD ]:}t  
|¡�& tjj||| |d�}|dksnt‚W 5 Q R X q>tjdkr¨t|ƒ}| ¡ }	|	dks t‚tj|= d S )NzT
        integer function foo()
        foo = 10 + 5
        return
        end
    z.f)Ú
modulenamer
   Ú	source_fnr   Úwin32é   )r   Zget_module_dirZget_temp_module_nameÚosÚgetcwdÚpathÚjoinÚstrÚuuidÚuuid4Ú	switchdirÚnumpyÚf2pyÚcompileÚAssertionErrorÚsysÚplatformr   ZfooÚmodules)
r
   ÚfsourceZmoddirÚmodnameÚcwdÚtargetr   Úret_valZreturn_checkZcalc_resultr   r   r   Útest_f2py_init_compile   s$    
ý
r%   c                  C   s   t j d¡} | dkst‚d S )Nó   invalidr   )r   r   r   r   )r$   r   r   r   Útest_f2py_init_compile_failureO   s    r'   c                  C   s6   z(t j} dt _tj d¡}|dks&t‚W 5 | t _X d S )Nzdoes not existr&   é   )r   Ú
executabler   r   r   r   )Útempr$   r   r   r   Útest_f2py_init_compile_bad_cmdV   s    r+   r    z'program test_f2py
end program test_f2pys'   program test_f2py
end program test_f2pyc              	   C   s8   t  | ¡�$ tjj|ddd�}|dks*t‚W 5 Q R X d S )NÚtest_compile_from_stringsz.f90)r   Ú	extensionr   )r   r   r   r   r   r   )Ztmpdirr    r$   r   r   r   r,   h   s    	þr,   )Ú__doc__r   r   r   Ú	importlibr   r   Z
numpy.f2pyr   r   r   r	   ÚmarkZparametrizeZleaks_referencesr%   r'   r+   r,   r   r   r   r   Ú<module>   s,   	ÿ4þþ