o 6a@sdZddlZddlZddlZddlmZddlZddlZddl m Z ddl m Z ddZ ejd d d gd d gejjddddZddZddZejdddgddZdS)z0See https://github.com/numpy/numpy/pull/11937. N) import_module) assert_equal)utilcCs,ts tdtstddSdS)NzNeeds C compilerzNeeds FORTRAN 77 compiler)rhas_c_compilerpytestskiphas_f77_compilerr r H/usr/lib/python3/dist-packages/numpy/f2py/tests/test_compile_function.py setup_modules  r extra_argsz--nooptz--debugz--noopt --debugz$Imported module seems never deleted.)reasonc Csd}t}t}t}tj|tt d}|dfD]:}zt |t j j ||||d}Wt |nt |wt|dtjdkrYt|}|} t| dtj|=qdS)NzT integer function foo() foo = 10 + 5 return end z.f) modulenamer source_fnrwin32)rget_module_dirget_temp_module_nameosgetcwdpathjoinstruuiduuid4chdirnumpyf2pycompilersysplatformrfoomodules) r fsourcemoddirmodnamecwdtargetrret_val return_check calc_resultr r r test_f2py_init_compiles.      r-cCstjd}t|ddS)Ninvalidr)rrr r)r*r r r test_f2py_init_compile_failureVs r/cCs8ztj}dt_tjd}t|dW|t_dS|t_w)Nzdoes not existr.)r! executablerrr r)tempr*r r r test_f2py_init_compile_bad_cmd]s   r3r%z'program test_f2py end program test_f2pys'program test_f2py end program test_f2pyc CsPt}ztt|tjj|ddd}t|dWt|dSt|w)Ntest_compile_from_stringsz.f90)r extensionr)rrrrrrr r)tmpdirr%r(r*r r r r4os r4)__doc__r!rr importlibrr numpy.f2pyr numpy.testingrrrr mark parametrizeleaks_referencesr-r/r3r4r r r r s.      9