Vfi 1pdZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl m Z ddl mZddlZddlZddlmZddlmZddlmZmZd!dZd Zd ZGd d ZeseZed ZdZdZ dZ!da"da#e j$dkr8ee%j&j&j&Z'e(e'dZ)dZ*dZ+dZ,dZ-e-gggdfdZ.e-gggddfdZ/GddeZ0d!dZ1GddZ2dZ3ej4d Z5dS)"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) import_module)Path) asunicode) MesonBackend)IS_WASMtemppathc tjdkrtjddt j} t j|d}t|d5}| d| d|d |rX| |d |d | |d |d | d |d|d|d|d dddn #1swxYwY tj gdd|d}n+#tj $rtjddYnwxYw|jdktj|S#tj|wxYw)Nwin32z*No Fortran tests on Windows (Issue #25134)T)allow_module_levelz meson.buildwzproject('check_compilers') zadd_languages('z') z _compiler = meson.get_compiler('z _code = '''z''' _have_z _feature =z_compiler.compiles(z_code, name: 'z feature check') )mesonsetupbtmpF)checkcwdcapture_outputz3meson not present, skipping compiler dependent testr)sysplatformpytestskiptempfilemkdtempospathjoinopenwrite subprocessrunCalledProcessError returncodeshutilrmtree)lang code_snippettmpdir meson_filefrunmesons Dc:\PYTHON\DbComparer\venv\Lib\site-packages\numpy/f2py/tests/util.pycheck_languager, s' |w @UYZZZZ    FW\\&-88 *c " " a GG2 3 3 3 GG0d000 1 1 1 4KKKKKLLL4??L???@@@8T88880488#888                h!~***# HH , h h h KMbf g g g g g g h"a' f fsT0E1+B D4 E1DE1DE1 D'&E1'%E E1E E11Fz] C Example Fortran 77 code PROGRAM HELLO PRINT *, 'Hello, Fortran 77!' END z ! Example Fortran 90 code program hello90 type :: greeting character(len=20) :: text end type greeting type(greeting) :: greet greet%text = 'hello, fortran 90!' print *, greet%text end program hello90 ceZdZdZdZdS)CompilerCheckerc>d|_d|_d|_d|_dS)NF)compilers_checkedhas_chas_f77has_f90selfs r+__init__zCompilerChecker.__init__Us#!&   c*|jstjdkstj5}|td|tdt|tdtg}|d |_ |d |_ |d |_ dddn #1swxYwYd|_dSdSdS)NcygwincfortranrT)r0rr concurrentfuturesThreadPoolExecutorsubmitr,fortran77_codefortran90_coderesultr1r2r3)r5executorr?s r+check_compilerszCompilerChecker.check_compilers[s%& *1I1I#6688 3HOONC88OONI~NNOONI~NN %QZ..00 &qz0022 &qz0022  3 3 3 3 3 3 3 3 3 3 3 3 3 3 3&*D " " " * *1I1IsB:C==DDN)__name__ __module__ __qualname__r6rFr7r+r.r.Ts2 * * * * *r7r.ctjSN)checkerr1rJr7r+has_c_compilerrNos =r7ctjSrL)rMr2rJr7r+has_f77_compilerrPr ?r7ctjSrL)rMr3rJr7r+has_f90_compilerrSurQr7c2tjo tjSrL)rMr3r2rJr7r+has_fortran_compilerrUxs O /0r7ir9z**/*.dllcte tjtn#t$rYnwxYw t jtn#t$rYnwxYwdadSdSrL) _module_dirrrremove ValueErrorr#r$OSErrorrJr7r+_cleanupr[s  HOOK ( ( ( (    D   M+ & & & &    D  s$. ;;A A&%A&ctdtjatjt tt jvr%t jdttS)Nr) rWrratexitregisterr[rrinsertrJr7r+get_module_dirr`sO&(( !!! ch & & HOOA{ + + + r7ctdtz}tdz a|tjvrt d|S)Nz_test_ext_module_%dr<z%Temporary module name already in use.)r` _module_numrmodules RuntimeError)names r+get_temp_module_namerfsE ; .D1K s{BCCC Kr7c2ifd}j|_|S)Nct||f}|vr% |i||<n#t$r }||<d}~wwxYw|}t|tr||SrL)repr Exception isinstance)akwkeyeretfuncmemos r+wrapperz_memoize..wrappersAr7mm d??  D!NrNNS    S  3i c9 % % I s $ 949)rG)rqrsrrs` @r+_memoizerts8 D      }G Nr7c  dtjd}t}tst jdg}g}|D]} t j| st| dt j |t j | } tj | | | | t j| \} } | dvr| | |sJ|t}g} d|vrd|vrdg} d d |g|z| z|z}|d d gz }|r |d g|zz }|r |dg|zz }t j} t j|tjd |g|z}t'j|t&jt&j}|\}}|jdkr*td|dddt3| t j||D]} t j| n2#t j||D]} t j| wxYwtjdkrlt8t=jt j ||ddt'jgdt8ztA|S)zH Compile and import a f2py module, built from the given files. zimport sys; sys.path = z&; import numpy.f2py; numpy.f2py.main()No Fortran compiler availablez is not a file).f90z.f95.fz.c.pyfNz--freethreading-compatiblez--no-freethreading-compatiblez-cz-mz --backendrzskip:zonly:)stdoutstderrrzRunning f2py failed:  r9s*)z/usr/bin/rebasez --databasez --obliviousz --verbose)!rrr`rUrrrisfilerdrbasenamer#copyfileappendsplitextrfgetcwdchdir executablerPopenPIPESTDOUT communicater"runlinkr _module_listextendglob check_callr) source_filesoptionsronly module_namecoded dst_sources f2py_sourcesfndstbaseext gil_options f2py_optsrcmdpouterrs r+ build_modulersJ XSX W W WDA  ! !5 3444KL % %w~~b!! 6"44455 5gll1bg..r2233C   3G$$S)) c 6 6 6    $ $ $ <*,, K#7227V^e7e7e34 t[)G3kALPI +w''I &gY%%  &gY%%  )++C  ~tT*Y6  S$.O$.$5 7 7 7==??S <1  Rs122wRR)C..RRSS S     B IbMMMM     B IbMMMM  |x  Ibgll1&9&9&9&9:: ; ;     I I I     % %%s =BI /I8c|d}t|5}t|d5}||dddn #1swxYwYt|g||||cdddS#1swxYwYdS)z6 Compile and import Fortran code using f2py. Nrx)suffixr rrrr)rrrr) source_coderrrrrrr)s r+ build_coders~  5D $__ ! GGK  ! ! ! ! ! ! ! ! ! ! ! ! ! ! !TF$+!%!%(3 555555555555555555555s3A4A A4A A4A A44A8;A8c$eZdZfdZdZxZS)SimplifiedMesonBackendc:tj|i|dSrL)superr6)r5argskwargs __class__s r+r6zSimplifiedMesonBackend.__init__1s%$)&)))))r7cn||j||jdSrL)write_meson_build build_dir run_mesonr4s r+compilezSimplifiedMesonBackend.compile4s2 t~... t~&&&&&r7)rGrHrIr6r __classcell__)rs@r+rr0sG*****'''''''r7rc tstjdt}|t }t did|d|d|dgd|d|dgd|dgd |d gd |d gd |d gd |d gd |d gd|dgd|dgd|dgd|ddd|di}|tj d|d|j t|S)z1 Build a module via Meson and import it. rvN modulenamesources extra_objectsr include_dirs library_dirs libraries define_macros undef_macros f2py_flags sysinfo_flagsfc_flags flib_flags setup_flagsremove_build_dirF extra_datr/rJ) rUrrr`rfrgetrrrr_meson_build_dirr)rrrrbackends r+ build_mesonr9s ! !5 3444  I*,, %; jj"555)  ZZ333  ZZ333 **["---jj"555ZZ333::lB///jj"555J+++::lB///JJ}b111 $6>>> **["---!G& OOHOOA)??g&=??@@@  % %%r7cheZdZdZdZgZgZgZdZdZ dZ dZ dZ e dZedZdZdS)F2PyTestNrxczt|}d|jdddd|jdS)N_.r< _ext_module)typerHrsplitrG)r5clss r+rzF2PyTest.module_namers?4jjP3>((a004PPs|PPPPr7ctjdkrtjdt t _tt _tt _ tt _ dS)Nr z)Fails with MinGW64 Gfortran (Issue #9673)) rrrrrNr_has_c_compilerrP_has_f77_compilerrS_has_f90_compilerrU_has_fortran_compiler)rs r+ setup_classzF2PyTest.setup_classws^ <7 " " KC D D D#1#3#3 %5%7%7"%5%7%7")=)?)?&&&r7c|jdS|jpg}|jr||jt d|D}t d|D}t d|D}|r|jstjd|r|j stjd|r|j stjd|j8t|j|j |j|j |j|j|_|j4t|j|j |j|j |j|_dSdS) Nc3ZK|]&}t|dV'dS)rxNstrendswith.0rs r+ z(F2PyTest.setup_method..s6??2B((..??????r7c3ZK|]&}t|dV'dS)rwNrrs r+rz(F2PyTest.setup_method..6AARB((00AAAAAAr7c3ZK|]&}t|dV'dS)ryNrrs r+rz(F2PyTest.setup_method..rr7z No Fortran 77 compiler availablez No Fortran 90 compiler availablerv)rrrrrr)modulerrrranyrrrrrrrrrr)r5codes needs_f77 needs_f90 needs_pyfs r+ setup_methodzF2PyTest.setup_methods{ ; " F " 9 & LL % % %??????? AA5AAAAA AA5AAAAA  r7c#Ktj}tj| dVtj|dS#tj|wxYwrL)rrrr)rcurpaths r+ switchdirrsXhjjGHTNNN  s AArL)6__doc__r]concurrent.futuresr> contextlibrrr#rrr importlibrpathlibrrr numpy._utilsrnumpy.f2py._backends._mesonr numpy.testingrrr,rBrCr.rMrFrNrPrSrUrWrbrrrNUMPY_INSTALL_ROOTlistrr[r`rfrtrrrrrrcontextmanagerrrJr7r+rs   ###### """"""444444++++++++ > ********.oG 111  <8h.5<4*// ;;<