+
    eiP/  c                   sr   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                 s<   \         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)Zallow_module_levelzmeson.buildwzproject('check_compilers')
zadd_languages('z')
z _compiler = meson.get_compiler('z_code = '''z'''
Z_have_z
_feature =z_compiler.compiles(z_code, name: 'z feature check')
NF)ZcheckcwdZcapture_outputz3meson not present, skipping compiler dependent test)mesonZsetupZbtmp)sysplatformpytestskiptempfilemkdtempospathjoinopenwrite
subprocessZrunZCalledProcessError
returncodeshutilrmtree)ZlangZcode_snippetZtmpdirZ
meson_filefZrunmesons   &&    </usr/lib64/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                   s,   a  ] tR t^Tt o R tR tRtV tR# )CompilerCheckerc                s>    R V n         R V n        R V n        R V n        R# )FNcompilers_checkedhas_chas_f77has_f90self   &r   __init__ZCompilerChecker.__init__U   s    !&
    c           	     s,   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)cygwinZcZfortranNT)r   r
   r   
concurrentfuturesZThreadPoolExecutorZsubmitr   fortran77_codefortran90_codeZresultr   r    r!   )r#   Zexecutorr)   s   &  r   check_compilersZ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__r%   r,   __static_attributes____classdictcell____classdict__   @r   r   r   T   s     * *r&   r   c                  "    \         P                  # N)checkerr    r&   r   has_c_compilerr:   o   s    ==r&   c                  r6   r7   )r8   r    r9   r&   r   has_f77_compilerr;   r       ??r&   c                  r6   r7   )r8   r!   r9   r&   r   has_f90_compilerr=   u   r<   r&   c                  sR    \         P                  ;'       d    \         P                  # r7   )r8   r!   r    r9   r&   r   has_fortran_compilerr>   x   s    OO//0r&   i  r'   z**/*.dllc                  s    \         eD    \        P                  P                  \         4        \
        P                  ! \         4       R s R # R #   \         d     L.i ; i  \         d     L$i ; ir7   )_module_dirr
   r   ZremoveZ
ValueErrorr   r   ZOSErrorr9   r&   r   _cleanupr@      sa    	HHOOK(	MM+&    		  		s"   #A A AAA-,A-c                  s    \         fm   \        P                  ! 4       s \        P                  ! \
        4       \         \        P                  9  d%   \        P                  P                  ^ \         4       \         # r7   )	r?   r   r   atexitZregisterr@   r
   r   insertr9   r&   r   get_module_dirrC      sF    &&(!chh&HHOOA{+r&   c                  s    \        4        R \        ,          p \        ^,          sV \        P                  9   d   \	        R4      hV # )z_test_ext_module_%dz%Temporary module name already in use.)rC   _module_numr
   ZmodulesRuntimeError)Znames    r   get_temp_module_namerF      s;      ;.D1Ks{{BCCKr&   c                 s>   a a / oV V3R  lpS P                   Vn         V# )c                  s   < \        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r7   )ZreprZ	ExceptionZ
isinstance)aZkwZkeyZeZretfuncmemos   *,   r   wrapperZ_memoize.<locals>.wrapper   sk    A7md? !NrNS	 3ic9%%I
  S	s   A AAA)r-   )rH   rJ   rI   s   f @r   _memoizerK      s     D }}GNr&   c           	     s   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:)ZstdoutZstderrzRunning f2py failed: :i   NNZ
r'   ZsZ*).f90z.f95.fz.c.pyf)z/usr/bin/rebasez
--databasez--obliviousz	--verbose)!r
   r   rC   r>   r   r   r   ZisfilerE   r   Zbasenamer   ZcopyfileappendZsplitextrF   ZgetcwdchdirZ
executabler   ZPopenZPIPEZSTDOUTZcommunicater   r   Zunlinkr   _module_listZextendglobZ
check_callr    )source_filesoptionsr   onlymodule_namecodedZdst_sourcesZf2py_sourcesfnZdstZbaseZextZgil_optionsZ	f2py_optsr   ZcmdZpZoutZ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           
     s   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.

NrN   )suffixr   rU   r   rV   rW   )r   r   r   r[   )Zsource_coderU   r   rV   r\   rW   r   r   s   &&&&&&  r   
build_coder^     sk     ~		 	 D$__GGK  TF$+!%!%(3	5 
!	 _ 
!	 	 s"   A8A%	A8%A50A88B		c                   s8   a a ] tR tRt oV 3R ltR tRtVtV ;t# )SimplifiedMesonBackendi0  c                s(   < \         SV `  ! V/ VB  R # r7   )Zsuperr%   )r#   Zargskwargs	__class__s   &*,r   r%   ZSimplifiedMesonBackend.__init__1  s    $)&)r&   c                sr    V P                  V P                  4       V P                  V P                  4       R # r7   )Zwrite_meson_build	build_dirZ	run_mesonr"   r$   r   compileZSimplifiedMesonBackend.compile4  s$    t~~.t~~&r&   r9   )	r-   r.   r/   r0   r%   rc   r1   r2   Z__classcell__)ra   r4   s   @@r   r_   r_   0  s     *' 'r&   r_   c           	     s$   \        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.
rL   Z
modulenamesourcesZextra_objectsrb   Zinclude_dirsZlibrary_dirsZ	librariesZdefine_macrosZundef_macrosZ
f2py_flagsZsysinfo_flagsZfc_flagsZ
flib_flagsZsetup_flagsZremove_build_dirFZ	extra_datZ/r9   )r>   r   r   rC   rF   r_   Zgetrc   r
   r   rB   Zmeson_build_dirr    )rT   rW   r`   rb   Zbackends   &&,  r   build_mesonre   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&=&=%>?@%%r&   c                   sn   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  NrN   c                s    \        V 4      pR VP                  P                  R^4      R,           R VP                   R2# )Z_Z.Z_ext_modulei)Ztyper.   Zrsplitr-   )r#   cls   & r   rW   ZF2PyTest.module_namer  s;    4j3>>((a045Qs||nKPPr&   c                s    \         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   r:   rf   _has_c_compilerr;   _has_f77_compilerr=   _has_f90_compilerr>   _has_fortran_compiler)rg   r$   r   setup_classZF2PyTest.setup_classw  sG    <<7"KKCD#1#3 %5%7"%5%7")=)?&r&   c           	     sr   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)rN   NZstrZendswithZ.0rZ   rh   r   	<genexpr>(F2PyTest.setup_method.<locals>.<genexpr>  s"     ?2B((..   ')TFc              3   rn   )rM   Nro   rp   rh   r   rq   rr     "     A5RB((005rs   c              3   rn   )rO   Nro   rp   rh   r   rq   rr     rt   rs   z No Fortran 77 compiler availablez No Fortran 90 compiler availablerL   )rU   r   rV   r\   rW   r]   )modulerd   rX   rP   r\   Zanyrj   r   r   rk   rl   r^   rU   rV   rW   r[   )r#   ZcodesZ	needs_f77Z	needs_f90Z	needs_pyfs   &    r   setup_methodZ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 $r&   )ru   )r-   r.   r/   r0   rX   rd   rU   r   rV   r\   ru   ri   rj   rk   ZpropertyrW   Zclassmethodrm   rv   r1   r2   r3   r5   r   rf   rf   f  sm     DGGDDFFOQ Q @ @% %r&   rf   c                  s    \        \        P                  P                  4      P                  P                  4       pVP                  ! V !  # r7   )r   numpyZf2py__file__parentZresolveZjoinpath)rG   rY   s   * r   getpathrz     s3    UZZ  !((002A::q>r&   c              #   s   "   \         P                  ! 4       p\        P                  ! V 4        R x  \        P                  ! V4       R #   \        P                  ! T4       i ; i5ir7   )r   r   r   rQ   )r   Zcurpathrh   r   	switchdirr{     s;     hhjGHHTN
s   ,A&A A&A##A&r7   )6Z__doc__rA   Zconcurrent.futuresr(   Z
contextlibrS   r   r   r   r
   r   Z	importlibr    Zpathlibr   r   rw   Znumpy._utilsr   Znumpy.f2py._backends._mesonr   Znumpy.testingr   r   r   r*   r+   r   r8   r,   r:   r;   r=   r>   r?   rD   r   rx   ry   ZNUMPY_INSTALL_ROOTZlistrR   r@   rC   rF   rK   r[   r^   r_   re   rf   rz   Zcontextmanagerr{   r9   r&   r   <module>r|      sc       	   
  #    " 4 +>* *. G1 <<8h..55<<*//
;<L	2 
') K& 
K&\ 
5 
56'\ '%&Z? ?N  r&   