
    pg\j-q                     \   S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKJr  S SK	J
r
  S SKrS SKJr  S SKJr  SSKJr  S r\" S	S
5      rSSS jr\R,                  " SS9S 5       r\R,                  " SS9S 5       r\R,                  " SS9S 5       r\R,                  " SS9S 5       r\R,                  " SS9S 5       r\R,                  " SS9S 5       rS rS rS rS r S r!S r"\RF                  RI                  \RJ                  S:*  SS9\RF                  RL                  S 5       5       r'\RF                  RL                  S 5       r(\RF                  RR                  S 5       r*S  r+S! r,S" r-S# r.S$ r/S% r0S& r1S' r2S( r3S) r4\RF                  RL                  S* 5       r5S+ r6S, r7S- r8S. r9\RF                  Ru                  S/S9S0 5       r;S1 r<S2 r=S3 r>\RF                  RI                  \R~                  " 5       S4:g  S5S9\RF                  RL                  S6 5       5       r@S7 rAS8 rBS9 rCS: rDS; rES< rF\RF                  Ru                  S/S9S= 5       rG\RF                  RI                  \R~                  " 5       S4:g  =(       d    \RJ                  S:*  S>S9\RF                  RL                  S? 5       5       rH\RF                  RI                  \R~                  " 5       S4:g  =(       d    \RJ                  S:*  S>S9S@ 5       rISA rJSB rKSC rLSD rMSE rNSF rOSG rPSH rQSI rRSJ rSSK rTSL rUSM rVSN rWSO rXSP rYSQ rZSR r[g)T    N)
namedtuple)Path)main)NOGIL_BUILD   )utilc                  z    [         R                  " 5       (       d  [        R                  " S5        g [	        5         g )Nz$CLI command needs a Fortran compiler)r   has_fortran_compilerpytestskipf2pycli     W/home/edenadmin/noVNC/venv/lib/python3.13/site-packages/numpy/f2py/tests/test_f2py2e.pycompiler_check_f2pyclir      s#    $$&&:;	r   PPathsz(finp, f90inp, pyf, wrap77, wrap90, cmodfc                     [        U 5      n[        UR                  S5      UR                  S5      UR                  S5      UR                  U S35      UR                  U S35      UR                  U S35      S9$ )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                     [         R                  " SSSS5      R                  5       nU R                  5       S-  nUR	                  USS9  U$ )'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_f90r5   M   sI     <<}=GGID		#	#	%	3BMM$M)Ir   c                     [         R                  " SSSS5      R                  5       nU R                  5       S-  nUR	                  USS9  U$ )z(F90 file for testing warnings in gh23598r&   r'   crackfortranzgh23598Warn.f90r)   r*   r,   r1   s      r   gh23598_warnr8   V   sK     <<8IJTTVD		#	#	%(9	9BMM$M)Ir   c                     [         R                  " SSSS5      R                  5       nU R                  5       S-  nUR	                  USS9  U$ )z8F90 file for testing disallowed CLI arguments in ghff819r&   r'   r(   zgh_22819.pyfr)   r*   r,   r1   s      r   gh22819_clir:   _   sI     <<~>HHJD		#	#	%	6BMM$M)Ir   c                     [         R                  " SSSS5      R                  5       nU R                  5       S-  nUR	                  USS9  U$ )'Generates a single f77 file for testingr&   r'   r(   zhi77.fzhello.fr)   r*   r,   r1   s      r   hello_world_f77r=   h   sI     <<x8BBDD		#	#	%		1BMM$M)Ir   c                     [         R                  " SSSS5      R                  5       nU R                  5       S-  nUR	                  USS9  U$ )r<   r&   r'   return_realzfoo77.fzfoo.fr)   r*   r,   r1   s      r   retreal_f77r@   q   sI     <<yAKKMD		#	#	%	/BMM$M)Ir   c                 .   [         R                  " SSSS5      R                  5       n[         R                  " SSSS5      R                  5       nU R                  5       S-  nU R                  5       S-  nUR	                  USS	9  UR	                  USS	9  U$ )
r%   r&   r'   f2cmapzisoFortranEnvMap.f90z.f2py_f2cmapz
f2cmap.f90mapfiler)   r*   r,   )r2   r3   rB   r4   fmaps        r   
f2cmap_f90rE   y   s     <<2HISSUD\\'5(NCMMOF		#	#	%	4B%%')3DMM$M)OOFWO-Ir   c                    [        U5      nUR                  [        SSU 3R                  5       5        [        R
                  " UR                  5         [        5         UR                  R                  S5       Vs/ s H%  oDR                  5       (       d  M  UR                  PM'     nnSU;  d   eSU;  d   eSU;   d   eSU;   d   e SSS5        gs  snf ! , (       d  f       g= f)	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)capfdr:   monkeypatchipathitem	gen_pathss         r   test_gh22819_clirW      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("CC
C'c                 Z   [        U5      nUR                  [        SSU S3R                  5       5        [        R
                  " UR                  5         [        R                  " [        SS9   [        5         SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f)z6Only one .pyf file allowed
gh-22819
CLI :: .pyf files
rG   rH   z
 hello.pyfzOnly one .pyf file per call)matchN)r   rJ   rK   rL   r   rM   rN   r   raises
ValueErrorr   )rR   r:   rS   rT   s       r   test_gh22819_many_pyfr\      st    
 EV}UG:%F%L%L%NO		%]]:-JKI L 
&	%KK 
&	%s$   B/B:B
B	B
B*c                 P   [        USS9nUR                  nUR                  [        SSU S3R	                  5       5        [
        R                  " UR                  5         [        5         UR                  R                  5       nSU;  d   e S S S 5        g ! , (       d  f       g = f)Ntestr   rG   f2py z -m testzintproductf2pywrap, intpr)r!   r   rJ   rK   rL   r   rM   rN   r   r   r.   )rR   r8   rS   foutlrT   wrappers         r   test_gh23598_warnrc      s    V4ELLEV
wh%%') 
	%	,,((**'999 
&	%	%s    -B
B%c                    [        U5      n[        U5      R                  S-   nUR                  [        SSU SU 3R	                  5       5        [
        R                  " UR                  5         [        5         U R                  5       u  pVSU;   d   e[        U 5      R                  5       (       d   e SSS5        g! , (       d  f       g= f)zAEnsures that a signature file is generated via the CLI
CLI :: -h
r   rG   zf2py -h  Saving signatures to fileN)r   stemrJ   rK   rL   r   rM   rN   r   
readouterrexists)rR   r5   rS   rT   opathout_s          r   test_gen_pyfrm      s     !E!&&/EVxwaw%?%E%E%GH		%	!!#*c111ug&&((((	 
&	%	%s   /AB??
Cc                 8   [        U5      nUR                  [        SSU 3R                  5       5        [        R
                  " UR                  5         [        5         U R                  5       u  pESU;   d   eSU;   d   e SSS5        g! , (       d  f       g= f)z@Ensures that a signature file can be dumped to stdout
CLI :: -h
rG   zf2py -h stdout rf   zfunction hi() ! in N	r   rJ   rK   rL   r   rM   rN   r   rh   rR   r5   rS   rT   rk   rl   s         r   test_gen_pyf_stdoutrq      s}     !EVug%>%D%D%FG		%	!!#*c111$+++	 
&	%	%s   -B
Bc                    [        U5      nUR                  [        SSU 3R                  5       5        [        R
                  " UR                  5         [        S5      R                  SSS9  [        R                  " [        5         [        5         U R                  5       u  pESU;   d   e SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f)	zbEnsures that the CLI refuses to overwrite signature files
CLI :: -h without --overwrite-signature
rG   f2py -h faker.pyf 	faker.pyf	Fake newsr)   r*   z&Use --overwrite-signature to overwriteN)r   rJ   rK   rL   r   rM   rN   r0   r   rZ   
SystemExitr   rh   )rR   r5   rS   rT   rl   errs         r   test_gen_pyf_no_overwriterx      s     !EV'9%%A%G%G%IJ		%[$$[7$C]]:&I%%'FA;sBBB ' 
&	%&& 
&	%s$   4C%B?.C?
C		C
C)      zPython 3.12 required)reasonc                 (   [        U5      nUR                  [        SSU 3R                  5       5        [        R
                  " UR                  5         [        5         U R                  5       u  pESU;   d   e SSS5        g! , (       d  f       g= f)z8Check that modules are named correctly

CLI :: defaults
rG   zf2py --backend meson -c zuntitledmodule.cN)	r   rJ   rK   rL   r   rM   rN   r   rh   rp   s         r   test_untitled_clir}      sq     !EV'?w%G%M%M%OP		% !!#!S((( 
&	%	%s   %B
Bc                 "   Sn[        XS9nUR                  nUR                  [        SSU SU 3R	                  5       5        [
        R                  " UR                  5         [        5         U R                  5       u  pgSU;   d   e SSS5        UR                  [        SSS	/5        [        R                  " [        5         [        5         U R                  5       u  pgS
U;   d   e SSS5        UR                  [        S/ SQ5        [        R                  " [        5         [        5         [        5         U R                  5       u  pgSU;   d   e SSS5        g! , (       d  f       N= f! , (       d  f       N= f! , (       d  f       g= f)ziCheck that distutils backend and related options fail
CLI :: --fcompiler --help-link --backend distutils
hir_   rG   r`   z -c --fcompiler=gfortran -m z%--fcompiler cannot be used with mesonNf2pyz--help-linkzUnknown option --help-link)r   z	--backend	distutilsz'distutils' backend was removed)r!   r   rJ   rK   rL   r   rM   rN   r   rh   r   rZ   rv   r   )rR   r5   rS   MNAMEra   rT   rk   rl   s           r   test_no_distutils_backendr      sG   
 E6ELLEVuUG#?wGMMO 
	% !!#6#=== 
&
 Vfm, 
z	"	!!#+s222 
#
 V7 
z	" 	!!#0C777	 
#	"! 
&	% 
#	" 
#	"s$   #%E%E/%/F 
E,/
E= 
Fc                    [        USS9nUR                  nSnSnUR                  [        SSU SU 3R	                  5       5        [
        R                  " UR                  5         [        5         U R                  5       u  pxUR	                  5        H  n	SU	 S	3U;   a  M   e   UR	                  5        H  n
S
U
 S3U;   a  M   e   SSS5        g! , (       d  f       g= f)z1Tests that functions can be skipped
CLI :: skip:
r^   r_   t0 t4 t8 sd s8 s4td s0rG   r`   z -m test skip: z=buildmodule: Could not found the body of interfaced routine "". Skipping.Constructing wrapper function ""N
r!   r   rJ   rK   rL   r   rM   rN   r   rh   )rR   r@   rS   ra   rT   toskip	remainingrk   rw   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 & 
&	%	%   &8C"CC
C c                    [        USS9nUR                  nSnSnUR                  [        SSU SU 3R	                  5       5        [
        R                  " UR                  5         [        5         U R                  5       u  pxUR	                  5        H  n	SU	 S	3U;   a  M   e   UR	                  5        H  n
S
U
 S3U;   a  M   e   SSS5        g! , (       d  f       g= f)z6Test that functions can be kept by only:
CLI :: only:
r^   r_   r   r   rG   r`   z -m test only: <buildmodule: Could not find the body of interfaced routine "r   r   r   Nr   )rR   r@   rS   ra   rT   r   tokeeprk   rw   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                    [        USS9nUR                  nSn[        U5      nSnSn	UR                  [        SSU SU	 S	U S
U 3R                  5       5        [        R                  " UR                  5         [        5         U R                  5       u  pUR                  5        H  nSU S3U;   a  M   e   UR                  5        H  nSU S3U
;   a  M   e   SSS5        g! , (       d  f       g= f)zZTests that it is possible to return to file processing mode
CLI :: :
BUG: numpy-gh #20520
r^   r_   r   ztd s0 hiblahrG   r`    -m z only: z : r   r   r   r   N)r!   r   r   rJ   rK   rL   r   rM   rN   r   rh   )rR   r5   r@   rS   ra   rT   r   ipath2r   r   rk   rw   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   98C%5C%C%%
C3c                    Sn[        XS9nUR                  nUR                  [        SSU SU 3R	                  5       5        [
        R                  " UR                  5         [        5         SSS5        [        R                  " UR                  5      (       d   e[        R                  " UR                  5      (       d   eg! , (       d  f       N]= f)z@Checks the generation of files based on a module name
CLI :: -m
r   r_   rG   r`   r   N)r!   r   rJ   rK   rL   r   rM   rN   r   r   ri   r   r   )rR   r5   rS   r   ra   rT   s         r   test_mod_gen_f77r   [  s     E6ELLEVuUG4w%?%E%E%GH		%	 
& ;;u{{####;;u||$$$$ 
&	%s   #C
Cc           	         Sn[        XS9nUR                  nUR                  [        SSU SU S3R	                  5       5        [
        R                  " UR                  5         [        5         [        S5      R                  5        nUR                  5       nSU;   d   e S	S	S	5        S	S	S	5        g	! , (       d  f       N= f! , (       d  f       g	= f)
zuCheck that pyf files are correctly generated with module structure
CLI :: -m <name> -h pyf_file
BUG: numpy-gh #20520
r   r_   rG   r`   r   z
 -h hi.pyfzhi.pyfzpython module hiN)r!   r   rJ   rK   rL   r   rM   rN   r   r   openread)rR   r=   rS   r   ra   rT   hipyfpyfdats           r   test_mod_gen_gh25263r   l  s    
 E6EJJEVuUG4wj%I%O%O%QR		%	(^  "eZZ\F%/// # 
&	%"" 
&	%s$   $$CB3"C3
C	=C
Cc                 (   [        USS9nUR                  n[        R                  " S5      n[        R                  " S5      nUR	                  [
        SSU S3R                  5       5        [        R                  " UR                  5         [        5         U R                  5       u  pxUR                  U5      c   eUR                  U5      b   e SSS5        UR	                  [
        SSU S	3R                  5       5        [        R                  " UR                  5         [        5         U R                  5       u  pxUR                  U5      b   eUR                  U5      c   e SSS5        g! , (       d  f       N= f! , (       d  f       g= f)
z@Lowers cases by flag or when -h is present

CLI :: --[no-]lower
r^   r_   zHI\(\)zhi\(\)rG   r`   z -m test --lowerNz -m test --no-lower)r!   r   recompilerJ   rK   rL   r   rM   rN   r   rh   search	rR   r=   rS   ra   rT   capshicapslork   rl   s	            r   test_lower_cmodr   |  sB   
 7EJJEZZ	"FZZ	"FVuUG3C%D%J%J%LM		%	!!#}}S!---}}S!)))	 
& Vw&9:@@BD		%	!!#}}S!)))}}S!---	 
&	% 
&	% 
&	%s   AE2#AF2
F 
Fc           	      \   [        USS9nUR                  n[        R                  " S5      n[        R                  " S5      nUR	                  [
        SSU SUR                   S3R                  5       5        [        R                  " UR                  5         [        5         U R                  5       u  pxUR                  U5      c   eUR                  U5      b   e S	S	S	5        UR	                  [
        SSU SUR                   S
3R                  5       5        [        R                  " UR                  5         [        5         U R                  5       u  pxUR                  U5      b   eUR                  U5      c   e S	S	S	5        g	! , (       d  f       N= f! , (       d  f       g	= f)zVLowers cases in signature files by flag or when -h is present

CLI :: --[no-]lower -h
r^   r_   z	Block: HIz	Block: hirG   r`   z -h z -m test --overwrite-signatureNz) -m test --overwrite-signature --no-lower)r!   r   r   r   rJ   rK   r   rL   r   rM   rN   r   rh   r   r   s	            r   test_lower_sigr     s`   
 7EJJEZZ%FZZ%F 
wd599+%CDJJL 
	%	!!#}}S!---}}S!)))	 
& 
wd599+%NO		 
	%	!!#}}S!)))}}S!---	 
&	% 
&	% 
&	%s   AF=AF
F
F+c           
      D   [        U5      nSnSnUR                  [        SSU SU SU 3R                  5       5        [        R
                  " UR                  5         [        5         U R                  5       u  pgSU S3U;   d   e S	S	S	5        g	! , (       d  f       g	= f)
zFEnsures that the build directory can be specified

CLI :: --build-dir
r   tttmprG   f2py -m re   z --build-dir zWrote C/API module "r   Nro   )rR   r5   rS   rT   r   odirrk   rl   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                 \   [        U5      nUR                  [        SSU S3R                  5       5        [        R
                  " UR                  5         [        S5      R                  SSS9  [        5         U R                  5       u  pESU;   d   e S	S	S	5        g	! , (       d  f       g	= f)
zPEnsures that the build directory can be specified

CLI :: --overwrite-signature
rG   rs   z --overwrite-signaturert   ru   r)   r*   rf   N)
r   rJ   rK   rL   r   rM   rN   r0   r   rh   rp   s         r   test_overwriter     s    
 !EV
UG#9:@@BD 
	%[$$[7$C	!!#*c111	 
&	%	%s   >B
B+c           	         [        U5      nSnUR                  [        SSU SU S3R                  5       5        [        R
                  " UR                  5         [        5         U R                  5       u  pVSU;   d   e[        U S35      R                  5        nSUR                  5       ;   d   e S	S	S	5        S	S	S	5        g	! , (       d  f       N= f! , (       d  f       g	= f)
zBEnsures that TeX documentation is written out

CLI :: --latex-doc
r   rG   r   re   z --latex-docDocumentation is saved to file
module.tex\documentclassNr   rJ   rK   rL   r   rM   rN   r   rh   r   r   rR   r5   rS   rT   r   rk   rl   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3C
C	C
C#c           	      4   [        U5      nSnUR                  [        SSU SU S3R                  5       5        [        R
                  " UR                  5         [        5         U R                  5       u  pVSU;  d   e SSS5        g! , (       d  f       g= f)zEEnsures that TeX documentation is written out

CLI :: --no-latex-doc
r   rG   r   re   z --no-latex-docr   Nro   rR   r5   rS   rT   r   rk   rl   s          r   test_nolatexdocr     s    
 !EEV"5'5'AGGIK 
	%	!!#/s::: 
&	%	%   %B		
Bc                 r   [         R                  " 5       (       d  [        R                  " S5        [        R
                  " S5      nU S-  n[        US5       nUR                  U5        S S S 5        [        R                  SSS[        U5      SSS	/n[        R                  " X@S
9  g ! , (       d  f       ND= f)NzNo Fortran compiler foundz(
        subroutine foo
        end
    ztest_latex.f90wz-mz
numpy.f2pyz-c
test_latexz--latex-doc)cwd)r   r
   r   r   textwrapdedentr   writerK   
executablestr
subprocess
check_call)tmp_pathfsourcefpathfcmds        r   test_latex_doc_gh30268r      s     $$&&/0oo  	G
 ''E	eS	Q	 
 >>4tSZ|Ub
cC#,	 
	s   B((
B6c           	         [        U5      nSnUR                  [        SSU SU S3R                  5       5        [        R
                  " UR                  5         [        5         U R                  5       u  pVSU;   d   e[        SU S35      R                  5        nS	UR                  5       ;  d   e S
S
S
5        S
S
S
5        g
! , (       d  f       N= f! , (       d  f       g
= f)zEnsures that truncated documentation is written out

TODO: Test to ensure this has no effect without --latex-doc
CLI :: --latex-doc --short-latex
r   rG   r   re   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()..0D$DIIK777 1	 
&	% 10	 
&	%%   ACC4C
C	C
C$c           	         [        U5      nSnUR                  [        SSU SU S3R                  5       5        [        R
                  " UR                  5         [        5         U R                  5       u  pVSU;   d   e[        SU S35      R                  5        nS	UR                  5       ;   d   e S
S
S
5        S
S
S
5        g
! , (       d  f       N= f! , (       d  f       g
= f)zAEnsures that RsT documentation is written out

CLI :: --rest-doc
r   rG   r   re   z --rest-doc#ReST Documentation is saved to filer   zmodule.restz.. -*- rest -*-Nr   )rR   r5   rS   rT   r   rk   rl   orsts           r   test_restdocr   )  s    
 !EEV"5'5'=CCEG 
	%	!!#4;;;Bug[)*//1T%444 2	 
&	% 21	 
&	%r   c           	      4   [        U5      nSnUR                  [        SSU SU S3R                  5       5        [        R
                  " UR                  5         [        5         U R                  5       u  pVSU;  d   e SSS5        g! , (       d  f       g= f)zDEnsures that TeX documentation is written out

CLI :: --no-rest-doc
r   rG   r   re   z --no-rest-docr   Nro   r   s          r   test_norestexdocr   ;  s    
 !EEV"5'5'@FFHJ 
	%	!!#4C??? 
&	%	%r   c           	         [        U5      nSnUR                  [        SSU SU S3R                  5       5        [        R
                  " UR                  5         [        5         [        SU S35      R                  5        nSUR                  5       ;   d   e S	S	S	5        S	S	S	5        g	! , (       d  f       N= f! , (       d  f       g	= f)
zAEnsures that debugging wrappers are written

CLI :: --debug-capi
r   rG   r   re   z --debug-capir   r   z#define DEBUGCFUNCSN
r   rJ   rK   rL   r   rM   rN   r   r   r   )rR   r5   rS   rT   r   ocmods         r   test_debugcapir   K  s    
 !EEV"5'5'?EEGI 
	%	BugX&',,.%)UZZ\999 / 
&	%.. 
&	%s$   (B<B+B<+
B9	5B<<
C
z2Consistently fails on CI; noisy so skip not xfail.c           	         [        U 5      nSnUR                  [        SSU SU S3R                  5       5        [        R
                  " UR                  5         [        5         [        R                  " [        R                   S35      n[        R                  " USSS	9nS
n[        R                  " S5      nUR                  U:X  d   eUR                  U:X  d   e SSS5        g! , (       d  f       g= f)z=Ensures that debugging wrappers work

CLI :: --debug-capi -c
r   rG   r   re   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   rJ   rK   rL   r   rM   rN   r   shlexr   r   runr   r   stdoutstderr)r5   rS   rT   r   cmd_runrouteouteerrs           r   test_debugcapi_bldr   [  s     !EEV"5'5'1ABHHJL 
	%	++ 00NOP~~gdWM 	  	 {{d"""{{d"""! 
&	%	%s   BC((
C6c           	      F   [        U5      nSnUR                  [        SSU SU 3R                  5       5        [        R
                  " UR                  5         [        5         SSS5        U R                  5       u  pVSU;   d   eUR                  [        SSU SU S3R                  5       5        [        R
                  " UR                  5         [        5         U R                  5       u  pVSU;   d   e SSS5        g! , (       d  f       N= f! , (       d  f       g= f)zgEnsures that fortran subroutine wrappers for F77 are included by default

CLI :: --[no]-wrap-functions
r   rG   r   re   N Fortran 77 wrappers are saved toz --wrap-functionsro   r   s          r   test_wrapfunc_defr   y  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
D c           	      4   [        U5      nSnUR                  [        SSU SU S3R                  5       5        [        R
                  " UR                  5         [        5         U R                  5       u  pVSU;  d   e SSS5        g! , (       d  f       g= f)z]Ensures that fortran subroutine wrappers for F77 can be disabled

CLI :: --no-wrap-functions
r   rG   r   re   z --no-wrap-functionsr   Nro   r   s          r   test_nowrapfuncr     s    
 !EEV"5'5'1EFLLNP 
	%	!!#2#=== 
&	%	%r   c           	         [        U5      nSnUR                  [        SSU SU S3R                  5       5        [        R
                  " UR                  5         [        5         [        SU S35      R                  5        nUR                  5       nSU;   d   eS	U;   d   e S
S
S
5        S
S
S
5        g
! , (       d  f       N= f! , (       d  f       g
= f)zWAdd to the include directories

CLI :: -include
TODO: Document this in the help string
r   rG   r   re   z' -include<stdbool.h> -include<stdio.h> r   r   z#include <stdbool.h>z#include <stdio.h>Nr   )rR   r5   rS   rT   r   r   ocmrs          r   test_inclheaderr     s     !EE
5'5'!HI	 
	%	BugX&',,.%::<D)T111'4/// / 
&	%.. 
&	%s$   (C!B5$C5
C	?C
CLinuxzCompiler requiredc                    [        U5      nSnSnSnUR                  [        SSU SU SU SU 3R                  5       5        [        R
                  " UR                  5         [        U5      R                  5         [        5         [        U S	35      R                  5        nUR                  5       nS
U;   d   eSU S3U;   d   e SSS5        SSS5        g! , (       d  f       N= f! , (       d  f       g= f)zLEnsures that the extra object can be specified when using meson backend
    r   r   zextra.orG   z!f2py --backend meson --build-dir r   z -c re   z/meson.buildzobjects:z'''N)r   rJ   rK   rL   r   rM   rN   touchr   r   r   )	rR   r5   rS   rT   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 C+#%C	C+
C(	$C++
C9c                      g)z7Add to the include directories

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

CLI :: --help-link
Nr   r   r   r   
test_hlinkr     r   r   c                 j   [        U5      nUR                  [        SSU S3R                  5       5        [        R
                  " UR                  5         [        5         U R                  5       u  pESU;   d   eSU;   d   eSU;   d   eSU;   d   eSU;   d   e S	S	S	5        g	! , (       d  f       g	= f)
zGCheck that Fortran-to-Python KIND specs can be passed

CLI :: --f2cmap
rG   rH   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 changesNro   )rR   rE   rS   rT   rk   rl   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B$$
B2c                 <   [        U5      nUR                  [        SSU S3R                  5       5        [        R
                  " UR                  5         [        5         U R                  5       u  pE[        U5      S:X  d   e SSS5        g! , (       d  f       g= f)z!Reduce verbosity

CLI :: --quiet
rG   rH   z --quietr   N)
r   rJ   rK   rL   r   rM   rN   r   rh   lenrp   s         r   
test_quietr    ss    
 !EV}UG8%D%J%J%LM		%	!!#3x1}} 
&	%	%s   .B
Bc                 *   [        U5      nUR                  [        SSU S3R                  5       5        [        R
                  " UR                  5         [        5         U R                  5       u  pESU;   d   e SSS5        g! , (       d  f       g= f)z%Increase verbosity

CLI :: --verbose
rG   rH   z
 --verboseanalyzelineNro   rp   s         r   test_verboser    sq    
 !EV}UG:%F%L%L%NO		%	!!#### 
&	%	%s   %B
Bc                     UR                  [        SSS/5        [        R                  " [        5         [        5         U R                  5       u  p#SSKnUR                  UR                  5       :X  d   e SSS5        g! , (       d  f       g= f)zEnsure version

CLI :: -v
rG   r   z-vr   N)
rJ   rK   r   rZ   rv   r   rh   numpy__version__strip)rR   rS   rk   rl   nps        r   test_versionr    sb    
 Vfd^4	z	"	!!#~~,,,	 
#	"	"s   AA??
Bc                    [        U 5      nUR                  [        SSU S3R                  5       5        [        R
                  " UR                  5         [        5         [        R                  " [        R                   S35      n[        R                  " USSS9nSnUR                  U:X  d   e S	S	S	5        g	! , (       d  f       g	= f)
z
CLI :: -c
rG   rH   z -cr   Tr   r   r   N)r   rJ   rK   rL   r   rM   rN   r   r   r   r   r   r   )r5   rS   rT   r   r   r   s         r   test_npdistopr    s    
 !EV}UG3%?%E%E%GH		%	++ 00NOP~~gdWM{{d""" 
&	%	%s   AB;;
C	z*Compiler and Python 3.12 or newer requiredc                 &   [        U 5      nUR                  [        SSU S3R                  5       5        [        R
                  " UR                  5         [        5         [        R                   S3n[        (       a  US-  nOUS-  n[        R                  " U5      n[        R                  " USSS	9nS
nUR                  U:X  d   e[        (       a  SUR                  ;   d   eUR                  S:X  d   e SSS5        g! , (       d  f       g= f)z&
CLI :: --no-freethreading-compatible
rG   rH   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'r   N)r   rJ   rK   rL   r   rM   rN   r   r   r   r   r   r   r   r   
returncoder5   rS   rT   r   r   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c                 8   [        U 5      nUR                  [        SSU S3R                  5       5        [        R
                  " UR                  5         [        5         [        R                   S3n[        (       a  US-  nOUS-  n[        R                  " U5      n[        R                  " USSS	9nS
nUR                  U:X  d   eS[        R                  ;  a  UR                   S:X  d   eUR"                  S:X  d   e SSS5        g! , (       d  f       g= f)z#
CLI :: --freethreading_compatible
rG   rH   z -c --freethreading-compatibler  z2import sys; assert sys._is_gil_enabled() is False"r   Tr   r   r   LSAN_OPTIONS r   N)r   rJ   rK   rL   r   rM   rN   r   r   r   r   r   r   r   osenvironr   r  r  s          r   test_freethreading_compatibler  E  s     !EV}UG;Y%Z%`%`%bc		%   =>;HHC4KC++c"~~gdWM{{d"""+;;"$$$!### 
&	%	%s   B,D
Dc                      g)z
CLI :: -c --fcompiler
Nr   r   r   r   test_npd_fcompilerr  a      
 	r   c                      g)z
CLI :: -c --compiler
Nr   r   r   r   test_npd_compilerr   i  r  r   c                      g)z
CLI :: -c --help-fcompiler
Nr   r   r   r   test_npd_help_fcompilerr"  q  r  r   c                      g)z
CLI :: -c --f77exec
Nr   r   r   r   test_npd_f77execr$  y  r  r   c                      g)z
CLI :: -c --f90exec
Nr   r   r   r   test_npd_f90execr&    r  r   c                      g)z
CLI :: -c --f77flags
Nr   r   r   r   test_npd_f77flagsr(    r  r   c                      g)z
CLI :: -c --f90flags
Nr   r   r   r   test_npd_f90flagsr*    r  r   c                      g)z
CLI :: -c --opt
Nr   r   r   r   test_npd_optr,    r  r   c                      g)z
CLI :: -c --arch
Nr   r   r   r   test_npd_archr.    r  r   c                      g)z
CLI :: -c --noopt
Nr   r   r   r   test_npd_nooptr0    r  r   c                      g)z
CLI :: -c --noarch
Nr   r   r   r   test_npd_noarchr2    r  r   c                      g)z
CLI :: -c --debug
Nr   r   r   r   test_npd_debugr4    r  r   c                      g)z
CLI :: -c --link-<resource>
Nr   r   r   r   test_npd_link_autor6    r  r   c                      g)z'
CLI :: -c -L/path/to/lib/ -l<libname>
Nr   r   r   r   test_npd_libr8    r  r   c                      g)z
CLI :: -D<define>
Nr   r   r   r   test_npd_definer:    r  r   c                      g)z
CLI :: -U<name>
Nr   r   r   r   test_npd_undefiner<    r  r   c                      g)z
CLI :: -I/path/to/include/
Nr   r   r   r   test_npd_inclr>    r  r   c                      g)z0
CLI :: <filename>.o <filename>.so <filename>.a
Nr   r   r   r   test_npd_linkerr@    r  r   )untitled)\r  platformr   r   r   rK   r   collectionsr   pathlibr   r   numpy.f2py.f2py2er   r   numpy.testing._private.utilsr   r  r   r   r   r!   fixturer5   r8   r:   r=   r@   rE   rW   r\   rc   rm   rq   rx   markskipifversion_infoslowr}   r   xfailr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   systemr   r   r   r  r  r  r  r  r  r  r  r   r"  r$  r&  r(  r*  r,  r.  r0  r2  r4  r6  r8  r:  r<  r>  r@  r   r   r   <module>rN     s   	  	   
  "   - 4  
HH	IN i  ! i  ! i  ! i  ! i  ! i  !1&	
:)
,C C$$/8NO
)  P
) 8 8@ 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Qc6F6F'6QG  I$ I$. X__&'1Qc6F6F'6QG  I$I$4																		r   