+
    iP/                     r   R t ^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RIt^ RI	t	^ RI
t
^ RIHt ^ RIHt ^ RIt^ RIt^ RIHt ^ RIHt ^ RIHtHt R R ltRtR	t ! R
 R4      t]'       g   ]! 4       t]P;                  4        R tR tR t R t!Rs"Rs#]	PH                  R8X  d>   ]! ]%4      PL                  PL                  PL                  t'](! ]'P                  R4      4      t)R t*R t+R t,R t-]-. . . R3R l4       t.]-. . . RR3R l4       t/ ! R R]4      t0R R lt1 ! R R4      t2R t3]Ph                  R 4       t5R# )!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_WASMtemppathc                 <   \         P                  R 8X  d   \        P                  ! RRR7       \        P
                  ! 4       p \        P                  P                  VR4      p\        VR4      ;_uu_ 4       pVP                  R4       VP                  RV  R24       V'       dM   VP                  V  R	V  R24       VP                  V  R
V R24       VP                  RV  RV  RV  RV  R2	4       RRR4        \        P                  ! . RORVRR7      pXP                  ^ 8H  \        P                   ! V4       #   + '       g   i     LR; i  \        P                   d    \        P                  ! RRR7        Lgi ; i  \        P                   ! T4       i ; i)win32z*No Fortran tests on Windows (Issue #25134)T)allow_module_levelzmeson.buildwzproject('check_compilers')
zadd_languages('z')
z _compiler = meson.get_compiler('z_code = '''z'''
_have_z
_feature =z_compiler.compiles(z_code, name: 'z feature check')
NF)checkcwdcapture_outputz3meson not present, skipping compiler dependent test)mesonsetupbtmp)sysplatformpytestskiptempfilemkdtempospathjoinopenwrite
subprocessrunCalledProcessError
returncodeshutilrmtree)langcode_snippettmpdir
meson_filefrunmesons   &&    u/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/numpy/f2py/tests/util.pycheck_languager+       s`   
||w@UYZFWW\\&-8
*c""aGG23GGodV4014& @dKL4&L>?@TF*f/v 6#f$68 #	h!~~*#	H ""a'f- #"$ ,, 	hKKMbfg	h 	fsI   4F 8A;D=3F <E F =E	F -F =F ?F  F Fz]
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
c                   ,   a  ] tR t^Tt o R tR tRtV tR# )CompilerCheckerc                >    R V n         R V n        R V n        R V n        R# )FNcompilers_checkedhas_chas_f77has_f90selfs   &r*   __init__CompilerChecker.__init__U   s    !&
    c           	     ,   V P                   '       g   \        P                  R 8X  g   \        P                  P                  4       ;_uu_ 4       pVP                  \        R4      VP                  \        R\        4      VP                  \        R\        4      .pV^ ,          P                  4       V n        V^,          P                  4       V n        V^,          P                  4       V n        RRR4       RV n         R# R# R#   + '       g   i     L; i)cygwincfortranNT)r0   r   r   
concurrentfuturesThreadPoolExecutorsubmitr+   fortran77_codefortran90_coderesultr1   r2   r3   )r5   executorr>   s   &  r*   check_compilersCompilerChecker.check_compilers[   s    &&&1I##6688HOONC8OONI~NOONI~N %QZ..0
&qz002&qz002 9 &*D" 2J&88s   B DD	r/   N)__name__
__module____qualname____firstlineno__r6   rE   __static_attributes____classdictcell____classdict__s   @r*   r-   r-   T   s     * *r8   r-   c                  "    \         P                  # N)checkerr1    r8   r*   has_c_compilerrS   o   s    ==r8   c                  "    \         P                  # rP   )rQ   r2   rR   r8   r*   has_f77_compilerrU   r       ??r8   c                  "    \         P                  # rP   )rQ   r3   rR   r8   r*   has_f90_compilerrX   u   rV   r8   c                  R    \         P                  ;'       d    \         P                  # rP   )rQ   r3   r2   rR   r8   r*   has_fortran_compilerrZ   x   s    OO//0r8   i  r:   z**/*.dllc                      \         eD    \        P                  P                  \         4        \
        P                  ! \         4       R s R # R #   \         d     L.i ; i  \         d     L$i ; irP   )_module_dirr   r   remove
ValueErrorr"   r#   OSErrorrR   r8   r*   _cleanupr`      sa    	HHOOK(	MM+&    		  		s"   #A A AAA-,A-c                      \         fm   \        P                  ! 4       s \        P                  ! \
        4       \         \        P                  9  d%   \        P                  P                  ^ \         4       \         # rP   )	r\   r   r   atexitregisterr`   r   r   insertrR   r8   r*   get_module_dirre      sF    &&(!chh&HHOOA{+r8   c                      \        4        R \        ,          p \        ^,          sV \        P                  9   d   \	        R4      hV # )z_test_ext_module_%dz%Temporary module name already in use.)re   _module_numr   modulesRuntimeError)names    r*   get_temp_module_namerk      s;      ;.D1Ks{{BCCKr8   c                 >   a a / oV V3R  lpS P                   Vn         V# )c                     < \        W34      pVS9  d    S! V / VB SV&   SV,          p\        V\        4      '       d   VhV#   \         d   pTST&   h R p?ii ; irP   )repr	Exception
isinstance)akwkeyeretfuncmemos   *,   r*   wrapper_memoize.<locals>.wrapper   sk    A7md? !NrNS	 3ic9%%I
  S	s   A AAA)rG   )rv   rx   rw   s   f @r*   _memoizerz      s     D }}GNr8   c           	        R\         P                  : R2p\        4       p\        4       '       g   \        P
                  ! R4       . p. pV  F  p	\        P                  P                  V	4      '       g   \        V	 R24      h\        P                  P                  V\        P                  P                  V	4      4      p
\        P                  ! W4       VP                  V
4       \        P                  P                  V
4      w  rVR9   g   K  VP                  V
4       K  	  V'       g   Q hVf   \        4       p. pRV9  d   RV9  d   R.pRRV.V,           V,           V,           pVR	R
.,          pV'       d   VR.V,           ,          pV'       d   VR.V,           ,          p\        P                   ! 4       p \        P"                  ! V4       \         P$                  RV.V,           p\&        P(                  ! V\&        P*                  \&        P,                  R7      pVP/                  4       w  ppVP0                  ^ 8w  d"   \        RVR,           R\3        V4       24      h \        P"                  ! V4       V F  p	\        P4                  ! V	4       K  	  \         P6                  R8X  dn   \8        P;                  \<        P<                  ! \        P                  P                  WdR R24      4      4       \&        P>                  ! . RO\8        ,           4       \A        V4      #   \        P"                  ! T4       T F  p	\        P4                  ! T	4       K  	  i ; i)z@
Compile and import a f2py module, built from the given files.

zimport sys; sys.path = z&; import numpy.f2py; numpy.f2py.main()No Fortran compiler availablez is not a filez--freethreading-compatiblez--no-freethreading-compatiblez-cz-mz	--backendr   zskip:zonly:)stdoutstderrzRunning f2py failed: :   NN
r:   s*).f90z.f95.fz.c.pyf)z/usr/bin/rebasez
--databasez--obliviousz	--verbose)!r   r   re   rZ   r   r   r   isfileri   r   basenamer"   copyfileappendsplitextrk   getcwdchdir
executabler   PopenPIPESTDOUTcommunicater!   r   unlinkr   _module_listextendglob
check_callr   )source_filesoptionsr   onlymodule_namecodeddst_sourcesf2py_sourcesfndstbaseextgil_options	f2py_optsr   cmdpouterrs   &&&&&               r*   build_moduler      s    %SXXL0VWDA!!34 KLww~~b!!"^455ggll1bgg..r23 3GG$$S)	66$  < *,K#727V^e7e34t[)G3kALPI+w''IgY%%	gY%%	 ))+C
~~tT*Y6S$.OO$.$5$57 ==?S<<1!6s2wir)C.AQRSS  	 BIIbM  ||x 	IIbggll1Qq&9:;	
 	I	
 %%) 	 BIIbM s   =B*L* *7M!c           
        Vf   Rp\        VR7      ;_uu_ 4       p\        VR4      ;_uu_ 4       pVP                  V 4       RRR4       \        V.VVVVR7      uuRRR4       #   + '       g   i     L+; i  + '       g   i     R# ; i)z.
Compile and import Fortran code using f2py.

Nr   )suffixr   r   r   r   r   )r   r   r   r   )source_coder   r   r   r   r   r   r(   s   &&&&&&  r*   
build_coder     sk     ~		 	 D$__GGK  TF$+!%!%(3	5 
!	 _ 
!	 	 s"   A8A%	A8%A50A88B		c                   8   a a ] tR tRt oV 3R ltR tRtVtV ;t# )SimplifiedMesonBackendi0  c                (   < \         SV `  ! V/ VB  R # rP   )superr6   )r5   argskwargs	__class__s   &*,r*   r6   SimplifiedMesonBackend.__init__1  s    $)&)r8   c                r    V P                  V P                  4       V P                  V P                  4       R # rP   )write_meson_build	build_dir	run_mesonr4   s   &r*   compileSimplifiedMesonBackend.compile4  s$    t~~.t~~&r8   rR   )	rG   rH   rI   rJ   r6   r   rK   rL   __classcell__)r   rN   s   @@r*   r   r   0  s     *' 'r8   r   c           	     $   \        4       '       g   \        P                  ! R4       \        4       pVf   \	        4       p\        R/ RVbRV bRVP                  R. 4      bRVbRVP                  R. 4      bRVP                  R. 4      bRVP                  R. 4      bR	VP                  R	. 4      bR
VP                  R
. 4      bRVP                  R. 4      bRVP                  R. 4      bRVP                  R. 4      bRVP                  R. 4      bRVP                  R. 4      bRVP                  RR4      bRVP                  R/ 4      b pVP                  4        \        P                  P                  ^ V RVP                   24       \        V4      # )z)
Build a module via Meson and import it.
r|   
modulenamesourcesextra_objectsr   include_dirslibrary_dirs	librariesdefine_macrosundef_macros
f2py_flagssysinfo_flagsfc_flags
flib_flagssetup_flagsremove_build_dirF	extra_dat/rR   )rZ   r   r   re   rk   r   getr   r   r   rd   meson_build_dirr   )r   r   r   r   backends   &&,  r*   build_mesonr   9  s     !!34 I*, %  jj"5 	
 ZZ3 ZZ3 **["- jj"5 ZZ3 ::lB/ jj"5 J+ ::lB/ JJ}b1  $6>  **["-!G& OO HHOOA)Ag&=&=%>?@%%r8   c                   n   a  ] tR tRt o RtRt. t. t. tRt	Rt
RtRtRt]R 4       t]R 4       tR tRtV tR# )F2PyTestif  Nr   c                    \        V 4      pR VP                  P                  R^4      R,           R VP                   R2# )_._ext_module)typerH   rsplitrG   )r5   clss   & r*   r   F2PyTest.module_namer  s;    4j3>>((a045Qs||nKPPr8   c                    \         P                  R 8X  d   \        P                  ! R4       \	        4       \
        n        \        4       \
        n        \        4       \
        n
        \        4       \
        n        R# )r	   z)Fails with MinGW64 Gfortran (Issue #9673)N)r   r   r   r   rS   r   _has_c_compilerrU   _has_f77_compilerrX   _has_f90_compilerrZ   _has_fortran_compiler)r   s   &r*   setup_classF2PyTest.setup_classw  sG    <<7"KKCD#1#3 %5%7"%5%7")=)?&r8   c           	     r   V P                   e   R # V P                  ;'       g    . pV P                  '       d   VP                  V P                  4       \
        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      p\
        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      p\
        ;QJ d    R V 4       F  '       g   K   RM	  RM! R V 4       4      pV'       d)   V P                  '       g   \        P                  ! R4       V'       d)   V P                  '       g   \        P                  ! R4       V'       d)   V P                  '       g   \        P                  ! R4       V P                  eS   \        V P                  V P                  V P                  V P                  V P                  V P                  R	7      V n         V P                  eJ   \        V P                  V P                  V P                  V P                  V P                  R
7      V n         R # R # )Nc              3   V   "   T F  p\        V4      P                  R 4      x  K!  	  R# 5i)r   Nstrendswith.0r   s   & r*   	<genexpr>(F2PyTest.setup_method.<locals>.<genexpr>  s"     ?2B((..   ')TFc              3   V   "   T F  p\        V4      P                  R 4      x  K!  	  R# 5i)r   Nr   r   s   & r*   r   r     "     A5RB((005r   c              3   V   "   T F  p\        V4      P                  R 4      x  K!  	  R# 5i)r   Nr   r   s   & r*   r   r     r   r   z No Fortran 77 compiler availablez No Fortran 90 compiler availabler|   )r   r   r   r   r   r   )moduler   r   r   r   anyr   r   r   r   r   r   r   r   r   r   )r5   codes	needs_f77	needs_f90	needs_pyfs   &    r*   setup_methodF2PyTest.setup_method  sp   ;;"""999LL%C??CCC???	CA5ACCCA5AA	CA5ACCCA5AA	T333KK:;T333KK:;T777KK78 99 $		YYYY{{ ,,DK <<#&YYYY ,,DK $r8   )r   )rG   rH   rI   rJ   r   r   r   r   r   r   r   r   r   r   propertyr   classmethodr   r   rK   rL   rM   s   @r*   r   r   f  sm     DGGDDFFOQ Q @ @% %r8   r   c                      \        \        P                  P                  4      P                  P                  4       pVP                  ! V !  # rP   )r   numpyf2py__file__parentresolvejoinpath)rq   r   s   * r*   getpathr    s3    UZZ  !((002A::q>r8   c              #      "   \         P                  ! 4       p\        P                  ! V 4        R x  \        P                  ! V4       R #   \        P                  ! T4       i ; i5irP   )r   r   r   r   )r   curpaths   & r*   	switchdirr    s;     hhjGHHTN
s   ,A&A A&A##A&rP   )6__doc__rb   concurrent.futuresr=   
contextlibr   r   r"   r   r   r   	importlibr   pathlibr   r   r   numpy._utilsr   numpy.f2py._backends._mesonr   numpy.testingr   r   r+   rA   rB   r-   rQ   rE   rS   rU   rX   rZ   r\   rg   r   r   r   NUMPY_INSTALL_ROOTlistr   r`   re   rk   rz   r   r   r   r   r   r  contextmanagerr  rR   r8   r*   <module>r     sc       	   
  #    " 4 +>* *. G1 <<8h..55<<*//
;<L	2 
') K& 
K&\ 
5 
56'\ '%&Z? ?N  r8   