+
    Qio                     4   ^ 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Ht ^ RIHt ^RIHt R t]! RR	4      tRQR
 lt]
P*                  ! RR7      R 4       t]
P*                  ! RR7      R 4       t]
P*                  ! RR7      R 4       t]
P*                  ! RR7      R 4       t]
P*                  ! RR7      R 4       t]
P*                  ! RR7      R 4       tR tR tR tR tR t R t!]
PD                  PG                  ]PH                  RR8*  RR7      R 4       t%]
PD                  PG                  ] PL                  ! 4       R8g  ;'       g    ]PH                  RR8*  RR7      R 4       t']
PD                  PP                  R 4       t)R  t*R! t+R" t,R# t-R$ t.R% t/R& t0R' t1R( t2R) t3R* t4R+ t5R, t6R- t7]
PD                  Pq                  R.R7      R/ 4       t9R0 t:R1 t;R2 t<]
PD                  PG                  ] PL                  ! 4       R8g  R3R7      R4 4       t=R5 t>R6 t?R7 t@R8 tAR9 tBR: tC]
PD                  Pq                  R.R7      R; 4       tD]
PD                  PG                  ] PL                  ! 4       R8g  ;'       g    ]PH                  RR8*  R<R7      R= 4       tE]
PD                  PG                  ] PL                  ! 4       R8g  ;'       g    ]PH                  RR8*  R<R7      R> 4       tFR? tGR@ tHRA tIRB tJRC tKRD tLRE tMRF tNRG tORH tPRI tQRJ tRRK tSRL tTRM tURN tVRO tWRP tXR# )S    N)
namedtuple)Path)main)NOGIL_BUILD)utilc                      \         P                  ! 4       '       g   \        P                  ! R 4       R# \	        4        R# )z$CLI command needs a Fortran compilerN)r   has_fortran_compilerpytestskipf2pycli     b/Users/mibo/.openclaw/workspace/.venv/lib/python3.14/site-packages/numpy/f2py/tests/test_f2py2e.pycompiler_check_f2pyclir      s#    $$&&:;	r   PPathsz(finp, f90inp, pyf, wrap77, wrap90, cmodfc                    \        V 4      p\        VP                  R4      VP                  R4      VP                  R4      VP                  V R24      VP                  V R24      VP                  V R24      R7      # )a8  Takes in a temporary file for testing and returns the expected output and input paths

Here expected output is essentially one of any of the possible generated
files.

..note::

     Since this does not actually run f2py, none of these are guaranteed to
     exist, and module names are typically incorrect

Parameters
----------
fname_inp : str
            The input filename
mname : str, optional
            The name of the module, untitled by default

Returns
-------
genp : NamedTuple PPaths
        The possible paths which are generated, not all of which exist
z.fz.f90.pyfz-f2pywrappers.fz-f2pywrappers2.f90module.c)finpf90inppyfwrap77wrap90cmodf)r   r   with_suffix	with_name)	fname_inpmnamebpaths   && r   get_io_pathsr    %   s~    . OEt$  (f%%89%(:;<oox01 r   session)scopec                    \         P                  ! RRRR4      P                  4       pV P                  4       R,          pVP	                  VRR7       V# )'Generates a single f90 file for testingtestssrcclizhiworld.f90z	hello.f90asciiencodingr   getpath	read_textgetbasetemp
write_texttmpdir_factoryfdatfns   &  r   hello_world_f90r4   L   sI     <<}=GGID		#	#	%	3BMM$M)Ir   c                    \         P                  ! RRRR4      P                  4       pV P                  4       R,          pVP	                  VRR7       V# )z(F90 file for testing warnings in gh23598r%   r&   crackfortranzgh23598Warn.f90r(   r)   r+   r0   s   &  r   gh23598_warnr7   U   sK     <<8IJTTVD		#	#	%(9	9BMM$M)Ir   c                    \         P                  ! RRRR4      P                  4       pV P                  4       R,          pVP	                  VRR7       V# )z8F90 file for testing disallowed CLI arguments in ghff819r%   r&   r'   zgh_22819.pyfr(   r)   r+   r0   s   &  r   gh22819_clir9   ^   sI     <<~>HHJD		#	#	%	6BMM$M)Ir   c                    \         P                  ! RRRR4      P                  4       pV P                  4       R,          pVP	                  VRR7       V# )'Generates a single f77 file for testingr%   r&   r'   zhi77.fzhello.fr(   r)   r+   r0   s   &  r   hello_world_f77r<   g   sI     <<x8BBDD		#	#	%		1BMM$M)Ir   c                    \         P                  ! RRRR4      P                  4       pV P                  4       R,          pVP	                  VRR7       V# )r;   r%   r&   return_realzfoo77.fzfoo.fr(   r)   r+   r0   s   &  r   retreal_f77r?   p   sI     <<yAKKMD		#	#	%	/BMM$M)Ir   c                J   \         P                  ! RRRR4      P                  4       p\         P                  ! RRRR4      P                  4       pV P                  4       R,          pV P                  4       R,          pVP	                  VRR	7       VP	                  VRR	7       V# )
r$   r%   r&   f2cmapzisoFortranEnvMap.f90z.f2py_f2cmapz
f2cmap.f90mapfiler(   r)   r+   )r1   r2   rA   r3   fmaps   &    r   
f2cmap_f90rD   x   s     <<2HISSUD\\'5(NCMMOF		#	#	%	4B%%')3DMM$M)OOFWO-Ir   c                   \        V4      pVP                  \        RRV 2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        VP                  P                  R4       Uu. uF&  qDP                  4       '       g   K  VP                  NK(  	  ppRV9  g   Q hRV9  g   Q hRV9   g   Q hRV9   g   Q h RRR4       R# u upi   + '       g   i     R# ; i)	zCheck that module names are handled correctly
gh-22819
Essentially, the -m name cannot be used to import the module, so the module
named in the .pyf needs to be used instead

CLI :: -m and a .pyf file
argvf2py -m blah *zblahmodule.czblah-f2pywrappers.fztest_22819-f2pywrappers.fztest_22819module.cN)r   setattrsyssplitr   	switchdirparentr   rglobis_filename)capfdr9   monkeypatchipathitem	gen_pathss   &&&   r   test_gh22819_clirV      s     EV}UG%<%B%B%DE		%	%	+0<<+=+=c+BU+B4llnYTYY+B	UY...$I555*i777#y000 
&	%U 
&	%	%s$   (C&C! C!0&C&!C&&C7	c           	        \        V4      pVP                  \        RRV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        P                  ! \        RR7      ;_uu_ 4        \        4        RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)z6Only one .pyf file allowed
gh-22819
CLI :: .pyf files
rF   rG   z
 hello.pyfzOnly one .pyf file per call)matchN)r   rI   rJ   rK   r   rL   rM   r
   raises
ValueErrorr   )rQ   r9   rR   rS   s   &&& r   test_gh22819_many_pyfr[      s}    
 EV}UG:%F%L%L%NO		%	%]]:-JKKI L 
&	%KK 
&	%	%s$   %B2B	B2B/*B22C	c                 p   \        VR R7      pVP                  pVP                  \        RRV R2P	                  4       4       \
        P                  ! VP                  4      ;_uu_ 4        \        4        VP                  P                  4       pRV9  g   Q h RRR4       R#   + '       g   i     R# ; i)testr   rF   f2py z -m testzintproductf2pywrap, intprN)r    r   rI   rJ   rK   r   rL   rM   r   r   r-   )rQ   r7   rR   foutlrS   wrappers   &&&   r   test_gh23598_warnrb      s    V4ELLEV
wh%%') 
	%	%	,,((**'999 
&	%	%	%s   +.B$$B5	c                   \        V4      p\        V4      P                  R,           pVP                  \        RRV RV 2P	                  4       4       \
        P                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rVRV9   g   Q h\        V 4      P                  4       '       g   Q h RRR4       R#   + '       g   i     R# ; i)zAEnsures that a signature file is generated via the CLI
CLI :: -h
r   rF   zf2py -h  Saving signatures to fileN)r   stemrI   rJ   rK   r   rL   rM   r   
readouterrexists)rQ   r4   rR   rS   opathout_s   &&&    r   test_gen_pyfrl      s     !E!&&/EVxwaw%?%E%E%GH		%	%	!!#*c111ug&&((((	 
&	%	%	%s   ;ACC	c                T   \        V4      pVP                  \        RRV 2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rERV9   g   Q hRV9   g   Q h RRR4       R#   + '       g   i     R# ; i)z@Ensures that a signature file can be dumped to stdout
CLI :: -h
rF   zf2py -h stdout re   zfunction hi() ! in N	r   rI   rJ   rK   r   rL   rM   r   rg   rQ   r4   rR   rS   rj   rk   s   &&&   r   test_gen_pyf_stdoutrp      s     !EVug%>%D%D%FG		%	%	!!#*c111$+++	 
&	%	%	%s   /BB'	c           	        \        V4      pVP                  \        RRV 2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        R4      P                  RRR7       \        P                  ! \        4      ;_uu_ 4        \        4        V P                  4       w  rERV9   g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)	zbEnsures that the CLI refuses to overwrite signature files
CLI :: -h without --overwrite-signature
rF   f2py -h faker.pyf 	faker.pyf	Fake newsr(   r)   z&Use --overwrite-signature to overwriteN)r   rI   rJ   rK   r   rL   rM   r/   r
   rY   
SystemExitr   rg   )rQ   r4   rR   rS   rk   errs   &&&   r   test_gen_pyf_no_overwriterw      s     !EV'9%%A%G%G%IJ		%	%[$$[7$C]]:&&I%%'FA;sBBB ' 
&	%&& 
&	%	%s$   ?C'&C	C'C$C''C8	zPython 3.12 required)reasonc                B   \        V4      pVP                  \        RRV 2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rERV9   g   Q h RRR4       R#   + '       g   i     R# ; i)z8Check that modules are named correctly

CLI :: defaults
rF   zf2py --backend meson -c zuntitledmodule.cN)	r   rI   rJ   rK   r   rL   rM   r   rg   ro   s   &&&   r   test_untitled_clirz      sw     !EV'?w%G%M%M%OP		%	% !!#!S((( 
&	%	%	%s   &BB	LinuxzCompiler and 3.12 requiredc           	        Rp\        WR7      pVP                  pVP                  \        RRV RV 2P	                  4       4       \
        P                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rgRV9   g   Q h RRR4       VP                  \        RRR	.4       \
        P                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rgR
V9   g   Q h RRR4       RpVP                  \        RRV RV R2P	                  4       4       \
        P                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rgRV9   g   Q h RRR4       R#   + '       g   i     EL; i  + '       g   i     L; i  + '       g   i     R# ; i)ziCheck that no distutils imports are performed on 3.12
CLI :: --fcompiler --help-link --backend distutils
hir^   rF   r_   z -c --fcompiler=gfortran -m z%--fcompiler cannot be used with mesonNf2pyz--help-linkzUse --dep for meson buildshi2z -c -m z --backend distutilsz.Cannot use distutils backend with Python>=3.12)r    r   rI   rJ   rK   r   rL   rM   r   rg   r   )rQ   r4   rR   MNAMEr`   rS   rj   rk   s   &&&     r   !test_no_py312_distutils_fcompilerr      su   
 E6ELLEVuUG#?wGMMO 
	%	% !!#6#=== 
& Vfm, 
	%	%	!!#+s222 
& EVuUG75'1EFLLN 
	%	%	!!#?3FFF 
&	% 
&	%	% 
&	% 
&	%	%s$   .&F&F(#&F;F%	(F8	;G	c                   \        VRR7      pVP                  pRpRpVP                  \        RRV RV 2P	                  4       4       \
        P                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rxVP	                  4        F  p	RV	 R	2V9   d   K  Q h	  VP	                  4        F  p
R
V
 R2V9   d   K  Q h	  RRR4       R#   + '       g   i     R# ; i)z1Tests that functions can be skipped
CLI :: skip:
r]   r^   t0 t4 t8 sd s8 s4td s0rF   r_   z -m test skip: z=buildmodule: Could not found the body of interfaced routine "". Skipping.Constructing wrapper function ""N
r    r   rI   rJ   rK   r   rL   rM   r   rg   )rQ   r?   rR   r`   rS   toskip	remainingrj   rv   skeyrkeys   &&&        r   test_f2py_skipr     s    
 F3EJJE FIV
wofX.4468 
	%	%	##%LLNDOPTvUab # OO%D4TF!<CCC & 
&	%	%	%   18C .C C  C1	c                   \        VRR7      pVP                  pRpRpVP                  \        RRV RV 2P	                  4       4       \
        P                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rxVP	                  4        F  p	RV	 R	2V9   d   K  Q h	  VP	                  4        F  p
R
V
 R2V9   d   K  Q h	  RRR4       R#   + '       g   i     R# ; i)z6Test that functions can be kept by only:
CLI :: only:
r]   r^   r   r   rF   r_   z -m test only: <buildmodule: Could not find the body of interfaced routine "r   r   r   Nr   )rQ   r?   rR   r`   rS   r   tokeeprj   rv   r   r   s   &&&        r   test_f2py_onlyr   $  s     F3EJJE FFV
wofX.4468 
	%	%	##%LLNDNtfT`a # LLND4TF!<CCC # 
&	%	%	%r   c                   \        VRR7      pVP                  pRp\        V4      pRpRp	VP                  \        RRV RV	 R	V R
V 2P                  4       4       \        P                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rVP                  4        F  pRV R2V9   d   K  Q h	  VP                  4        F  pRV R2V
9   d   K  Q h	  RRR4       R#   + '       g   i     R# ; i)zZTests that it is possible to return to file processing mode
CLI :: :
BUG: numpy-gh #20520
r]   r^   r   ztd s0 hiblahrF   r_    -m z only: z : r   r   r   r   N)r    r   r   rI   rJ   rK   r   rL   rM   r   rg   )rQ   r4   r?   rR   r`   rS   r   ipath2r   r   rj   rv   r   r   s   &&&&          r   test_file_processing_switchr   ;  s     F3EJJE F/"FFE
wd5'F8<BB 	
 
	%	%	##%LLNDNtfT`a # LLND4TF!<CCC # 
&	%	%	%s   8C3C3%C33D	c                   Rp\        WR7      pVP                  pVP                  \        RRV RV 2P	                  4       4       \
        P                  ! VP                  4      ;_uu_ 4        \        4        RRR4       \        P                  ! VP                  4      '       g   Q h\        P                  ! VP                  4      '       g   Q hR#   + '       g   i     Lb; i)z@Checks the generation of files based on a module name
CLI :: -m
r}   r^   rF   r_   r   N)r    r   rI   rJ   rK   r   rL   rM   r   r   rh   r   r   )rQ   r4   rR   r   r`   rS   s   &&&   r   test_mod_gen_f77r   Y  s     E6ELLEVuUG4w%?%E%E%GH		%	%	 
& ;;u{{####;;u||$$$$ 
&	%s   .CC#	c           	        Rp\        WR7      pVP                  pVP                  \        RRV RV R2P	                  4       4       \
        P                  ! VP                  4      ;_uu_ 4        \        4        \        R4      P                  4       ;_uu_ 4       pVP                  4       pRV9   g   Q h R	R	R	4       R	R	R	4       R	#   + '       g   i     L; i  + '       g   i     R	# ; i)
zuCheck that pyf files are correctly generated with module structure
CLI :: -m <name> -h pyf_file
BUG: numpy-gh #20520
r}   r^   rF   r_   r   z
 -h hi.pyfzhi.pyfzpython module hiN)r    r   rI   rJ   rK   r   rL   rM   r   r   openread)rQ   r<   rR   r   r`   rS   hipyfpyfdats   &&&     r   test_mod_gen_gh25263r   j  s    
 E6EJJEVuUG4wj%I%O%O%QR		%	%	(^  ""eZZ\F%/// # 
&	%"" 
&	%	%s$   /,CC	6CCCC,	c                b   \        VRR7      pVP                  p\        P                  ! R4      p\        P                  ! R4      pVP	                  \
        RRV R2P                  4       4       \        P                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rxVP                  V4      f   Q hVP                  V4      e   Q h RRR4       VP	                  \
        RRV R	2P                  4       4       \        P                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rxVP                  V4      e   Q hVP                  V4      f   Q h RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)
z@Lowers cases by flag or when -h is present

CLI :: --[no-]lower
r]   r^   zHI\(\)zhi\(\)rF   r_   z -m test --lowerNz -m test --no-lower)r    r   recompilerI   rJ   rK   r   rL   rM   r   rg   search	rQ   r<   rR   r`   rS   capshicapslorj   rk   s	   &&&      r   test_lower_cmodr   z  sK   
 7EJJEZZ	"FZZ	"FVuUG3C%D%J%J%LM		%	%	!!#}}S!---}}S!)))	 
& Vw&9:@@BD		%	%	!!#}}S!)))}}S!---	 
&	% 
&	% 
&	%	%s   AF
8AF
F	F.	c           	        \        VRR7      pVP                  p\        P                  ! R4      p\        P                  ! R4      pVP	                  \
        RRV RVP                   R2P                  4       4       \        P                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rxVP                  V4      f   Q hVP                  V4      e   Q h R	R	R	4       VP	                  \
        RRV RVP                   R
2P                  4       4       \        P                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rxVP                  V4      e   Q hVP                  V4      f   Q h R	R	R	4       R	#   + '       g   i     L; i  + '       g   i     R	# ; i)zVLowers cases in signature files by flag or when -h is present

CLI :: --[no-]lower -h
r]   r^   z	Block: HIz	Block: hirF   r_   z -h z -m test --overwrite-signatureNz) -m test --overwrite-signature --no-lower)r    r   r   r   rI   rJ   r   rK   r   rL   rM   r   rg   r   r   s	   &&&      r   test_lower_sigr     si   
 7EJJEZZ%FZZ%F 
wd599+%CDJJL 
	%	%	!!#}}S!---}}S!)))	 
& 
wd599+%NO		 
	%	%	!!#}}S!)))}}S!---	 
&	% 
&	% 
&	%	%s   $AF$AF7$F4	7G	c           
     ^   \        V4      pRpRpVP                  \        RRV RV RV 2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rgRV R2V9   g   Q h R	R	R	4       R	#   + '       g   i     R	# ; i)
zFEnsures that the build directory can be specified

CLI :: --build-dir
r   tttmprF   f2py -m rd   z --build-dir zWrote C/API module "r   Nrn   )rQ   r4   rR   rS   r   odirrj   rk   s   &&&     r   test_build_dirr     s    
 !EEDV"5'5'tfEKKMO 
	%	%	!!#&ugR0C777 
&	%	%	%s   &*BB,	c                |   \        V4      pVP                  \        RRV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        R4      P                  RRR7       \        4        V P                  4       w  rERV9   g   Q h R	R	R	4       R	#   + '       g   i     R	# ; i)
zPEnsures that the build directory can be specified

CLI :: --overwrite-signature
rF   rr   z --overwrite-signaturers   rt   r(   r)   re   N)
r   rI   rJ   rK   r   rL   rM   r/   r   rg   ro   s   &&&   r   test_overwriter     s    
 !EV
UG#9:@@BD 
	%	%[$$[7$C	!!#*c111	 
&	%	%	%s   AB**B;	c           	        \        V4      pRpVP                  \        RRV RV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rVRV9   g   Q h\        V R24      P                  4       ;_uu_ 4       pRVP                  4       9   g   Q h R	R	R	4       R	R	R	4       R	#   + '       g   i     L; i  + '       g   i     R	# ; i)
zBEnsures that TeX documentation is written out

CLI :: --latex-doc
r   rF   r   rd   z --latex-docDocumentation is saved to file
module.tex\documentclassNr   rI   rJ   rK   r   rL   rM   r   rg   r   r   rQ   r4   rR   rS   r   rj   rk   otexs   &&&     r   test_latexdocr     s    
 !EEV"5'5'>DDFH 
	%	%	!!#/3666UG:&',,..$$		333 /	 
&	% /.	 
&	%	%s%   "A
C*,C	C*C'"C**C;	c           	     N   \        V4      pRpVP                  \        RRV RV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rVRV9  g   Q h RRR4       R#   + '       g   i     R# ; i)zEEnsures that TeX documentation is written out

CLI :: --no-latex-doc
r   rF   r   rd   z --no-latex-docr   Nrn   rQ   r4   rR   rS   r   rj   rk   s   &&&    r   test_nolatexdocr     s    
 !EEV"5'5'AGGIK 
	%	%	!!#/s::: 
&	%	%	%   "&BB$	c           	        \        V4      pRpVP                  \        RRV RV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rVRV9   g   Q h\        RV R24      P                  4       ;_uu_ 4       pR	VP                  4       9  g   Q h R
R
R
4       R
R
R
4       R
#   + '       g   i     L; i  + '       g   i     R
# ; i)zEnsures that truncated documentation is written out

TODO: Test to ensure this has no effect without --latex-doc
CLI :: --latex-doc --short-latex
r   rF   r   rd   z --latex-doc --short-latexr   ./r   r   Nr   r   s   &&&     r   test_shortlatexr     s     !EE
5'5'!;<BBD 
	%	%	!!#/3666BugZ()..00D$DIIK777 1	 
&	% 10	 
&	%	%%   "AC+-C	C+C(#C++C<	c           	        \        V4      pRpVP                  \        RRV RV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rVRV9   g   Q h\        RV R24      P                  4       ;_uu_ 4       pR	VP                  4       9   g   Q h R
R
R
4       R
R
R
4       R
#   + '       g   i     L; i  + '       g   i     R
# ; i)zAEnsures that RsT documentation is written out

CLI :: --rest-doc
r   rF   r   rd   z --rest-doc#ReST Documentation is saved to filer   zmodule.restz.. -*- rest -*-Nr   )rQ   r4   rR   rS   r   rj   rk   orsts   &&&     r   test_restdocr     s    
 !EEV"5'5'=CCEG 
	%	%	!!#4;;;Bug[)*//11T%444 2	 
&	% 21	 
&	%	%r   c           	     N   \        V4      pRpVP                  \        RRV RV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rVRV9  g   Q h RRR4       R#   + '       g   i     R# ; i)zDEnsures that TeX documentation is written out

CLI :: --no-rest-doc
r   rF   r   rd   z --no-rest-docr   Nrn   r   s   &&&    r   test_norestexdocr   '  s    
 !EEV"5'5'@FFHJ 
	%	%	!!#4C??? 
&	%	%	%r   c           	        \        V4      pRpVP                  \        RRV RV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        \        RV R24      P                  4       ;_uu_ 4       pRVP                  4       9   g   Q h R	R	R	4       R	R	R	4       R	#   + '       g   i     L; i  + '       g   i     R	# ; i)
zAEnsures that debugging wrappers are written

CLI :: --debug-capi
r   rF   r   rd   z --debug-capir   r   z#define DEBUGCFUNCSN
r   rI   rJ   rK   r   rL   rM   r   r   r   )rQ   r4   rR   rS   r   ocmods   &&&   r   test_debugcapir   7  s    
 !EEV"5'5'?EEGI 
	%	%	BugX&',,..%)UZZ\999 / 
&	%.. 
&	%	%s$   "0CB=	+C=CCC!	z2Consistently fails on CI; noisy so skip not xfail.c           	        \        V 4      pRpVP                  \        RRV RV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        \        P                  ! \        P                   R24      p\        P                  ! VRRR	7      pR
p\        P                  ! R4      pVP                  V8X  g   Q hVP                  V8X  g   Q h RRR4       R#   + '       g   i     R# ; i)z=Ensures that debugging wrappers work

CLI :: --debug-capi -c
r   rF   r   rd   z -c --debug-capi -c "import blah; blah.hi()"TUTF-8capture_outputr*    Hello World
a   debug-capi:Python C/API function blah.hi()
debug-capi:float hi=:output,hidden,scalar
debug-capi:hi=0
debug-capi:Fortran subroutine `f2pywraphi(&hi)'
debug-capi:hi=0
debug-capi:Building return value.
debug-capi:Python C/API function blah.hi: successful.
debug-capi:Freeing memory.
        N)r   rI   rJ   rK   r   rL   rM   r   shlex
executable
subprocessruntextwrapdedentstdoutstderr)r4   rR   rS   r   cmd_runrouteouteerrs   &&      r   test_debugcapi_bldr   G  s     !EEV"5'5'1ABHHJL 
	%	%	++ 00NOP~~gdWM 	  	 {{d"""{{d"""! 
&	%	%	%s   "B	C66D	c           	     v   \        V4      pRpVP                  \        RRV RV 2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        RRR4       V P                  4       w  rVRV9   g   Q hVP                  \        RRV RV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rVRV9   g   Q h RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)zgEnsures that fortran subroutine wrappers for F77 are included by default

CLI :: --[no]-wrap-functions
r   rF   r   rd   N Fortran 77 wrappers are saved toz --wrap-functionsrn   r   s   &&&    r   test_wrapfunc_defr   e  s     !EEVxwaw%?%E%E%GH		%	%	 
&FC.#555 V"5'5'1BCIIKM 
	%	%	!!#2c999 
&	% 
&	% 
&	%	%s   !D#&D'D$	'D8	c           	     N   \        V4      pRpVP                  \        RRV RV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rVRV9  g   Q h RRR4       R#   + '       g   i     R# ; i)z]Ensures that fortran subroutine wrappers for F77 can be disabled

CLI :: --no-wrap-functions
r   rF   r   rd   z --no-wrap-functionsr   Nrn   r   s   &&&    r   test_nowrapfuncr   ~  s    
 !EEV"5'5'1EFLLNP 
	%	%	!!#2#=== 
&	%	%	%r   c           	        \        V4      pRpVP                  \        RRV RV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        \        RV R24      P                  4       ;_uu_ 4       pVP                  4       pRV9   g   Q hR	V9   g   Q h R
R
R
4       R
R
R
4       R
#   + '       g   i     L; i  + '       g   i     R
# ; i)zWAdd to the include directories

CLI :: -include
TODO: Document this in the help string
r   rF   r   rd   z' -include<stdbool.h> -include<stdio.h> r   r   z#include <stdbool.h>z#include <stdio.h>Nr   )rQ   r4   rR   rS   r   r   ocmrs   &&&    r   test_inclheaderr     s     !EE
5'5'!HI	 
	%	%	BugX&',,..%::<D)T111'4/// / 
&	%.. 
&	%	%s$   "0C#C	6CCCC,	zCompiler requiredc                (   \        V4      pRpRpRpVP                  \        RRV RV RV RV 2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        V4      P                  4        \        4        \        V R	24      P                  4       ;_uu_ 4       pVP                  4       pR
V9   g   Q hRV R2V9   g   Q h RRR4       RRR4       R#   + '       g   i     L; i  + '       g   i     R# ; i)zLEnsures that the extra object can be specified when using meson backend
    r   r   zextra.orF   z!f2py --backend meson --build-dir r   z -c rd   z/meson.buildzobjects:z'''N)r   rI   rJ   rK   r   rL   rM   touchr   r   r   )	rQ   r4   rR   rS   r   r   obj
mesonbuildmblds	   &&&      r   test_cli_objr     s     !EED
CV;D6eWDQTPUUVW\V]^ddfh 
	%	%S	 TF,'(--//:??$D%%%S>T))) 0 
&	% 0/ 
&	%	%s%   +AD 3'C-	D -C=8D  D	c                     R# )z7Add to the include directories

CLI :: --include-paths
Nr   r   r   r   test_inclpathr          	r   c                     R# )z3Add to the include directories

CLI :: --help-link
Nr   r   r   r   
test_hlinkr     r   r   c                   \        V4      pVP                  \        RRV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rERV9   g   Q hRV9   g   Q hRV9   g   Q hRV9   g   Q hRV9   g   Q h R	R	R	4       R	#   + '       g   i     R	# ; i)
zGCheck that Fortran-to-Python KIND specs can be passed

CLI :: --f2cmap
rF   rG   z --f2cmap mapfilez!Reading f2cmap from 'mapfile' ...z&Mapping "real(kind=real32)" to "float"z'Mapping "real(kind=real64)" to "double"z,Mapping "integer(kind=int64)" to "long_long"z0Successfully applied user defined f2cmap changesNrn   )rQ   rD   rR   rS   rj   rk   s   &&&   r   test_f2cmapr     s    
 EV}UG;L%M%S%S%UV		%	%	!!#2c999;sBBB<CCCASHHHASHHH 
&	%	%	%s   A
B22C	c                V   \        V4      pVP                  \        RRV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rE\        V4      ^ 8X  g   Q h RRR4       R#   + '       g   i     R# ; i)z!Reduce verbosity

CLI :: --quiet
rF   rG   z --quietN)
r   rI   rJ   rK   r   rL   rM   r   rg   lenro   s   &&&   r   
test_quietr     sy    
 !EV}UG8%D%J%J%LM		%	%	!!#3x1}} 
&	%	%	%s   /BB(	c                D   \        V4      pVP                  \        RRV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        V P                  4       w  rERV9   g   Q h RRR4       R#   + '       g   i     R# ; i)z%Increase verbosity

CLI :: --verbose
rF   rG   z
 --verboseanalyzelineNrn   ro   s   &&&   r   test_verboser     sw    
 !EV}UG:%F%L%L%NO		%	%	!!#### 
&	%	%	%s   &BB	c                :   VP                  \        RRR.4       \        P                  ! \        4      ;_uu_ 4        \        4        V P                  4       w  r#^ RIpVP                  VP                  4       8X  g   Q h RRR4       R#   + '       g   i     R# ; i)zEnsure version

CLI :: -v
rF   r~   z-vN)
rI   rJ   r
   rY   ru   r   rg   numpy__version__strip)rQ   rR   rj   rk   nps   &&   r   test_versionr     sh    
 Vfd^4	z	"	"	!!#~~,,,	 
#	"	"	"s   AB		B	c                   \        V 4      pVP                  \        RRV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        \        P                  ! \        P                   R24      p\        P                  ! VRRR7      pRpVP                  V8X  g   Q h R	R	R	4       R	#   + '       g   i     R	# ; i)
z
CLI :: -c
rF   rG   z -cr   Tr   r   r   N)r   rI   rJ   rK   r   rL   rM   r   r   r   r   r   r   )r4   rR   rS   r   r   r   s   &&    r   test_npdistopr     s    
 !EV}UG3%?%E%E%GH		%	%	++ 00NOP~~gdWM{{d""" 
&	%	%	%s   A CC	z*Compiler and Python 3.12 or newer requiredc                ^   \        V 4      pVP                  \        RRV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        \        P                   R2p\        '       d   VR,          pM	VR,          p\        P                  ! V4      p\        P                  ! VRRR	7      pR
pVP                  V8X  g   Q h\        '       d   RVP                  9   g   Q hVP                  ^ 8X  g   Q h RRR4       R#   + '       g   i     R# ; i)z&
CLI :: --no-freethreading-compatible
rF   rG   z! -c --no-freethreading-compatible -c "import blah; blah.hi();z1import sys; assert sys._is_gil_enabled() is True"r   Tr   r   r   zHThe global interpreter lock (GIL) has been enabled to load module 'blah'Nr   rI   rJ   rK   r   rL   rM   r   r   r   r   r   r   r   r   
returncoder4   rR   rS   cmdr   r   r   s   &&     r    test_no_freethreading_compatibler    s     !EV}UG;\%]%c%c%ef		%	%   =>;GGC4KC++c"~~gdWM{{d""";]aealallll!### 
&	%	%	%s   BD*&DD,	c                F   \        V 4      pVP                  \        RRV R2P                  4       4       \        P
                  ! VP                  4      ;_uu_ 4        \        4        \        P                   R2p\        '       d   VR,          pM	VR,          p\        P                  ! V4      p\        P                  ! VRRR	7      pR
pVP                  V8X  g   Q hVP                  R8X  g   Q hVP                  ^ 8X  g   Q h RRR4       R#   + '       g   i     R# ; i)z#
CLI :: --freethreading_compatible
rF   rG   z -c --freethreading-compatibler  z2import sys; assert sys._is_gil_enabled() is False"r   Tr   r   r    Nr  r  s   &&     r   test_freethreading_compatibler
  /  s     !EV}UG;Y%Z%`%`%bc		%	%   =>;HHC4KC++c"~~gdWM{{d"""{{b   !### 
&	%	%	%s   B'DD 	c                     R# )z
CLI :: -c --fcompiler
Nr   r   r   r   test_npd_fcompilerr  J      
 	r   c                     R# )z
CLI :: -c --compiler
Nr   r   r   r   test_npd_compilerr  R  r  r   c                     R# )z
CLI :: -c --help-fcompiler
Nr   r   r   r   test_npd_help_fcompilerr  Z  r  r   c                     R# )z
CLI :: -c --f77exec
Nr   r   r   r   test_npd_f77execr  b  r  r   c                     R# )z
CLI :: -c --f90exec
Nr   r   r   r   test_npd_f90execr  j  r  r   c                     R# )z
CLI :: -c --f77flags
Nr   r   r   r   test_npd_f77flagsr  r  r  r   c                     R# )z
CLI :: -c --f90flags
Nr   r   r   r   test_npd_f90flagsr  z  r  r   c                     R# )z
CLI :: -c --opt
Nr   r   r   r   test_npd_optr    r  r   c                     R# )z
CLI :: -c --arch
Nr   r   r   r   test_npd_archr    r  r   c                     R# )z
CLI :: -c --noopt
Nr   r   r   r   test_npd_nooptr    r  r   c                     R# )z
CLI :: -c --noarch
Nr   r   r   r   test_npd_noarchr!    r  r   c                     R# )z
CLI :: -c --debug
Nr   r   r   r   test_npd_debugr#    r  r   c                     R# )z
CLI :: -c --link-<resource>
Nr   r   r   r   test_npd_link_autor%    r  r   c                     R# )z'
CLI :: -c -L/path/to/lib/ -l<libname>
Nr   r   r   r   test_npd_libr'    r  r   c                     R# )z
CLI :: -D<define>
Nr   r   r   r   test_npd_definer)    r  r   c                     R# )z
CLI :: -U<name>
Nr   r   r   r   test_npd_undefiner+    r  r   c                     R# )z
CLI :: -I/path/to/include/
Nr   r   r   r   test_npd_inclr-    r  r   c                     R# )z0
CLI :: <filename>.o <filename>.so <filename>.a
Nr   r   r   r   test_npd_linkerr/    r  r   )untitled)      )Yplatformr   r   r   rJ   r   collectionsr   pathlibr   r
   numpy.f2py.f2py2er   r   numpy.testing._private.utilsr   r	  r   r   r   r    fixturer4   r7   r9   r<   r?   rD   rV   r[   rb   rl   rp   rw   markskipifversion_inforz   systemr   xfailr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r
  r  r  r  r  r  r  r  r  r  r  r!  r#  r%  r'  r)  r+  r-  r/  r   r   r   <module>r>     s    	   
  "   - 4  
HH	IN i  ! i  ! i  ! i  ! i  ! i  !1&	
:)
,C C$$/8NO
) P
) X__&'1SSs7G7G77R\xyG zG> D D.D.D<%"0 .4$.N8"2"4$; 8,5$@ :  MN# O#::2> 0, X__&'1;NO* P*&		I$$- MN# O# X__&'1QQc6F6F'6QG  I$I$. X__&'1QQc6F6F'6QG  I$I$2																		r   