a ;jgP-@sdZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl ZddlmZddlmZddlmZmZddlmZddlmZdadaejd kreejjjZe ed Z!d d Z"d dZ#ddZ$ddZ%e%gggdfddZ&e%gggddfddZ'd-ddZ(dZ)dZ*GdddZ+es\e+Z,e,-ddZ.dd Z/d!d"Z0Gd#d$d$eZ1d.d%d&Z2Gd'd(d(Z3d)d*Z4e j5d+d,Z6dS)/z Utility functions for - building and importing modules on test time, using a temporary location - detecting if compilers are present - determining paths to tests N)Path) asunicode)temppathIS_WASM) import_module) MesonBackendicygwinz**/*.dllcCsVtdurRztjtWnty*Yn0zttWntyLYn0dadSN) _module_dirsyspathremove ValueErrorshutilrmtreeOSErrorrr?/usr/local/lib/python3.9/site-packages/numpy/f2py/tests/util.py_cleanup)s  rcCs6tdur2tattttjvr2tjdttS)Nr) r tempfilemkdtempatexitregisterrr r insertrrrrget_module_dir7s   rcCs,tdt}td7a|tjvr(td|S)Nz_test_ext_module_%dz%Temporary module name already in use.)r _module_numr modules RuntimeError)namerrrget_temp_module_nameAs  r csifdd}j|_|S)Nc stt||f}|vrZz|i||<Wn.tyX}z||<WYd}~n d}~00|}t|trp||Sr )repr Exception isinstance)akwkeyeretfuncmemorrwrapperPs  z_memoize..wrapper)__name__)r*r,rr)r_memoizeMs r.c Csdtjd}t}g}g}|D]j} tj| s}z(F2PyTest.setup_method..css|]}t|dVqdS)r/Nrrrrrr~rcss|]}t|dVqdS)r1Nrrrrrrrz No Fortran 77 compiler availablez No Fortran 90 compiler availablezNo Fortran compiler available)rNrOrPr^rQr`)modulerrRr;r^anyrrrOrrdrNrPrQr])rpcodesZ needs_f77Z needs_f90Z needs_pyfrrr setup_methodus>         zF2PyTest.setup_method)r-r|r}rRrrNrOrPr^rrrrpropertyrQ classmethodrrrrrrr\s  rcGsttjjj}|j|Sr )rnumpyZf2py__file__parentresolvejoinpath)r$rSrrrgetpathsrc cs8t}t|zdVWt|n t|0dSr )rrXr6r>)r Zcurpathrrr switchdirs  r)N)N)7__doc__rJr6r r@rrrtextwraprer contextlibrconcurrent.futuresrupathlibrZ numpy._utilsrZ numpy.testingrr importlibrZnumpy.f2py._backends._mesonrr rrGrrZNUMPY_INSTALL_ROOTlistrHrrr r.r]rdrirwrxrjr~r{rrrrrrrcontextmanagerrrrrrsh       H   .F