
    qKgc                        d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZ d dl	Z	d dl
Z
ddlmZ d dlmZ  edd      ZdKd	Z e
j$                  d
      d        Z e
j$                  d
      d        Z e
j$                  d
      d        Z e
j$                  d
      d        Z e
j$                  d
      d        Z e
j$                  d
      d        Zd Zd Zd Zd Zd Zd Ze
j>                  jA                   e	jB                         dk7  xs ejD                  dk  d      d        Z#e
j>                  jA                   e	jB                         dk7  xs ejD                  dk  d      d        Z$e
j>                  jJ                  d        Z&d Z'd  Z(d! Z)d" Z*d# Z+d$ Z,d% Z-d& Z.d' Z/d( Z0d) Z1d* Z2d+ Z3d, Z4e
j>                  jk                  d-      d.        Z6d/ Z7d0 Z8d1 Z9d2 Z:d3 Z;d4 Z<d5 Z=d6 Z>d7 Z?e
j>                  jk                  d-      d8        Z@d9 ZAd: ZBd; ZCd< ZDd= ZEd> ZFd? ZGd@ ZHdA ZIdB ZJdC ZKdD ZLdE ZMdF ZNdG ZOdH ZPdI ZQdJ ZRy)L    N)Path)
namedtuple   )util)mainPPathsz(finp, f90inp, pyf, wrap77, wrap90, cmodfc                     t        |       }t        |j                  d      |j                  d      |j                  d      |j                  | d      |j                  | d      |j                  | d            S )ax  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      `/home/alanp/www/video.onchill/myenv/lib/python3.12/site-packages/numpy/f2py/tests/test_f2py2e.pyget_io_pathsr      s~    . OEt$  (f%%89%(:;<oox01     session)scopec                     t        j                  dddd      j                         }| j                         dz  }|j	                  |d       |S )'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_f90r-   9   sI     <<}=GGID		#	#	%	3BMM$M)Ir   c                     t        j                  dddd      j                         }| j                         dz  }|j	                  |d       |S )z(F90 file for testing warnings in gh23598r   r   crackfortranzgh23598Warn.f90r!   r"   r$   r)   s      r   gh23598_warnr0   B   sK     <<8IJTTVD		#	#	%(9	9BMM$M)Ir   c                     t        j                  dddd      j                         }| j                         dz  }|j	                  |d       |S )z8F90 file for testing disallowed CLI arguments in ghff819r   r   r    zgh_22819.pyfr!   r"   r$   r)   s      r   gh22819_clir2   K   sI     <<~>HHJD		#	#	%	6BMM$M)Ir   c                     t        j                  dddd      j                         }| j                         dz  }|j	                  |d       |S )'Generates a single f77 file for testingr   r   r    zhi77.fzhello.fr!   r"   r$   r)   s      r   hello_world_f77r5   T   sI     <<x8BBDD		#	#	%		1BMM$M)Ir   c                     t        j                  dddd      j                         }| j                         dz  }|j	                  |d       |S )r4   r   r   return_realzfoo77.fzfoo.fr!   r"   r$   r)   s      r   retreal_f77r8   ]   sI     <<yAKKMD		#	#	%	/BMM$M)Ir   c                 6   t        j                  dddd      j                         }t        j                  dddd      j                         }| j                         dz  }| j                         dz  }|j	                  |d	       |j	                  |d	       |S )
r   r   r   f2cmapzisoFortranEnvMap.f90z.f2py_f2cmapz
f2cmap.f90mapfiler!   r"   r$   )r*   r+   r:   r,   fmaps        r   
f2cmap_f90r=   e   s     <<2HISSUD\\'5(NCMMOF		#	#	%	4B%%')3DMM$M)OOFWO-Ir   c                    t        |      }|j                  t        dd| j                                t	        j
                  |j                        5  t                |j                  j                  d      D cg c]  }|j                         s|j                  ! }}d|vsJ d|vsJ d|v sJ d|v sJ 	 ddd       yc c}w # 1 sw Y   yxY w)	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parentf2pyclirglobis_filename)capfdr2   monkeypatchipathitem	gen_pathss         r   test_gh22819_clirP   q   s     EV}UG%<%B%B%DE		%	+0<<+=+=c+BU+B4dllnTYY+B	UY...$I555*i777#y000 
&	%U 
&	%s$   (C;CCCCCc                 H   t        |      }|j                  t        dd| dj                                t	        j
                  |j                        5  t        j                  t        d      5  t                ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)zBOnly one .pyf file allowed
    gh-22819
    CLI :: .pyf files
    r?   r@   z
 hello.pyfzOnly one .pyf file per call)matchN)r   rB   rC   rD   r   rE   rF   pytestraises
ValueErrorrG   )rK   r2   rL   rM   s       r   test_gh22819_many_pyfrV      st    
 EV}UG:%F%L%L%NO		%]]:-JKI L 
&	%KK 
&	%s$   B0B;BB	BB!c                 F   t        |d      }|j                  }|j                  t        dd| dj	                                t        j                  |j                        5  t                |j                  j                         }d|vsJ 	 d d d        y # 1 sw Y   y xY w)Ntestr   r?   f2py z -m testzintproductf2pywrap, intpr)r   r   rB   rC   rD   r   rE   rF   rG   r   r&   )rK   r0   rL   foutlrM   wrappers         r   test_gh23598_warnr]      s    V4ELLEV
wh%%') 
	%	,,((**'999 
&	%	%s   "+BB c                    t        |      }t        |      j                  dz   }|j                  t        dd| d| j	                                t        j                  |j                        5  t                | j                         \  }}d|v sJ t        |       j                         sJ 	 ddd       y# 1 sw Y   yxY w)zIEnsures that a signature file is generated via the CLI
    CLI :: -h
    r
   r?   zf2py -h  Saving signatures to fileN)r   stemrB   rC   rD   r   rE   rF   rG   
readouterrexists)rK   r-   rL   rM   opathout_s          r   test_gen_pyfrg      s     !E!&&/EVxwaw%?%E%E%GH		%	!!#Q*c111ug&&(((	 
&	%	%s   .A B88Cc                 &   t        |      }|j                  t        dd| j                                t	        j
                  |j                        5  t                | j                         \  }}d|v sJ d|v sJ 	 ddd       y# 1 sw Y   yxY w)zHEnsures that a signature file can be dumped to stdout
    CLI :: -h
    r?   zf2py -h stdout r`   zfunction hi() ! in N	r   rB   rC   rD   r   rE   rF   rG   rb   rK   r-   rL   rM   re   rf   s         r   test_gen_pyf_stdoutrk      s     !EVug%>%D%D%FG		%	!!#Q*c111$+++	 
&	%	%s   *BBc                    t        |      }|j                  t        dd| j                                t	        j
                  |j                        5  t        d      j                  dd       t        j                  t              5  t                | j                         \  }}d|v sJ 	 ddd       ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)	zjEnsures that the CLI refuses to overwrite signature files
    CLI :: -h without --overwrite-signature
    r?   f2py -h faker.pyf 	faker.pyf	Fake newsr!   r"   z&Use --overwrite-signature to overwriteN)r   rB   rC   rD   r   rE   rF   r(   rS   rT   
SystemExitrG   rb   )rK   r-   rL   rM   rf   errs         r   test_gen_pyf_no_overwriterr      s     !EV'9%%A%G%G%IJ		%[$$[7$C]]:&I%%'FAs;sBBB ' 
&	%&& 
&	%s$   6C	$B?.C?C	CCLinux)      zCompiler and 3.12 required)reasonc                    t        |      }|j                  t        dd| j                                t	        j
                  |j                        5  t                | j                         \  }}d|v sJ 	 ddd       y# 1 sw Y   yxY w)z@Check that modules are named correctly

    CLI :: defaults
    r?   zf2py --backend meson -c zuntitledmodule.cNri   rj   s         r   test_untitled_clirx      sr     !EV'?w%G%M%M%OP		%	!!#Q!S((( 
&	%	%s   $BB
c           	      F   d}t        ||      }|j                  }|j                  t        dd| d| j	                                t        j                  |j                        5  t                | j                         \  }}d|v sJ 	 ddd       |j                  t        ddj	                                t        j                  |j                        5  t                | j                         \  }}d	|v sJ 	 ddd       d
}|j                  t        dd| d| dj	                                t        j                  |j                        5  t                | j                         \  }}d|v sJ 	 ddd       y# 1 sw Y   xY w# 1 sw Y   xY w# 1 sw Y   yxY w)zqCheck that no distutils imports are performed on 3.12
    CLI :: --fcompiler --help-link --backend distutils
    hirY   r?   rZ   z -c --fcompiler=gfortran -m z%--fcompiler cannot be used with mesonNzf2py --help-linkzUse --dep for meson buildshi2z -c -m z --backend distutilsz.Cannot use distutils backend with Python>=3.12)
r   r   rB   rC   rD   r   rE   rF   rG   rb   )rK   r-   rL   MNAMEr[   rM   re   rf   s           r   !test_no_py312_distutils_fcompilerr}      sr   
 E6ELLEVuUG#?wGMMO 
	%	!!#Q6#=== 
& V'..0 
	%	!!#Q+s222 
& EVuUG75'1EFLLN 
	%	!!#Q?3FFF 
&	% 
&	% 
&	% 
&	%s$   &$E?$F$F?FFF c                    t        |d      }|j                  }d}d}|j                  t        dd| d| j	                                t        j                  |j                        5  t                | j                         \  }}|j	                         D ]  }	d|	 d	|v rJ  |j	                         D ]  }
d
|
 d|v rJ  	 ddd       y# 1 sw Y   yxY w)z9Tests that functions can be skipped
    CLI :: skip:
    rX   rY   t0 t4 t8 sd s8 s4td s0r?   rZ   z -m test skip: z=buildmodule: Could not found the body of interfaced routine "". Skipping.Constructing wrapper function ""N
r   r   rB   rC   rD   r   rE   rF   rG   rb   )rK   r8   rL   r[   rM   toskip	remainingre   rq   skeyrkeys              r   test_f2py_skipr      s    
 F3EJJE FIV
wofX.4468 
	%	##%SLLNDOPTvUab # OO%D4TF!<CCC & 
&	%	%   (9C"CCCc                    t        |d      }|j                  }d}d}|j                  t        dd| d| j	                                t        j                  |j                        5  t                | j                         \  }}|j	                         D ]  }	d|	 d	|v rJ  |j	                         D ]  }
d
|
 d|v rJ  	 ddd       y# 1 sw Y   yxY w)z>Test that functions can be kept by only:
    CLI :: only:
    rX   rY   r   r   r?   rZ   z -m test only: <buildmodule: Could not find the body of interfaced routine "r   r   r   Nr   )rK   r8   rL   r[   rM   r   tokeepre   rq   r   r   s              r   test_f2py_onlyr     s     F3EJJE FFV
wofX.4468 
	%	##%SLLNDNtfT`a # LLND4TF!<CCC # 
&	%	%r   c                    t        |d      }|j                  }d}t        |      }d}d}	|j                  t        dd| d|	 d	| d
| j                                t        j                  |j                        5  t                | j                         \  }
}|j                         D ]  }d| d|v rJ  |j                         D ]  }d| d|
v rJ  	 ddd       y# 1 sw Y   yxY w)zfTests that it is possible to return to file processing mode
    CLI :: :
    BUG: numpy-gh #20520
    rX   rY   r   ztd s0 hiblahr?   rZ    -m z only: z : r   r   r   r   N)r   r   r   rB   rC   rD   r   rE   rF   rG   rb   )rK   r-   r8   rL   r[   rM   r   ipath2r   r   re   rq   r   r   s                 r   test_file_processing_switchr   '  s     F3EJJE F/"FFE
wd5'F8<BB 	
 
	%	##%SLLNDNtfT`a # LLND4TF!<CCC # 
&	%	%s   ;9C!5C!C!!C*c                    d}t        ||      }|j                  }|j                  t        dd| d| j	                                t        j                  |j                        5  t                ddd       t        j                  |j                        sJ t        j                  |j                        sJ y# 1 sw Y   LxY w)zHChecks the generation of files based on a module name
    CLI :: -m
    rz   rY   r?   rZ   r   N)r   r   rB   rC   rD   r   rE   rF   rG   r   rc   r   r   )rK   r-   rL   r|   r[   rM   s         r   test_mod_gen_f77r   E  s     E6ELLEVuUG4w%?%E%E%GH		%	 
& ;;u{{###;;u||$$$ 
&	%s   &B<<Cc           	         d}t        ||      }|j                  }|j                  t        dd| d| dj	                                t        j                  |j                        5  t                t        d      j                         5 }|j                         }d|v sJ 	 d	d	d	       d	d	d	       y	# 1 sw Y   xY w# 1 sw Y   y	xY w)
zCheck that pyf files are correctly generated with module structure
    CLI :: -m <name> -h pyf_file
    BUG: numpy-gh #20520
    rz   rY   r?   rZ   r   z
 -h hi.pyfzhi.pyfzpython module hiN)r   r   rB   rC   rD   r   rE   rF   rG   r   openread)rK   r5   rL   r|   r[   rM   hipyfpyfdats           r   test_mod_gen_gh25263r   V  s    
 E6EJJEVuUG4wj%I%O%O%QR		%	(^  "eZZ\F%/// # 
&	%"" 
&	%s$   '$C B4#C 4B=	9C  C	c                    t        |d      }|j                  }t        j                  d      }t        j                  d      }|j	                  t
        dd| dj                                t        j                  |j                        5  t                | j                         \  }}|j                  |      J |j                  |      J 	 ddd       |j	                  t
        dd| d	j                                t        j                  |j                        5  t                | j                         \  }}|j                  |      J |j                  |      J 	 ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)
zHLowers cases by flag or when -h is present

    CLI :: --[no-]lower
    rX   rY   zHI\(\)zhi\(\)r?   rZ   z -m test --lowerNz -m test --no-lower)r   r   recompilerB   rC   rD   r   rE   rF   rG   rb   search	rK   r5   rL   r[   rM   capshicapslore   rf   s	            r   test_lower_cmodr   f  sF   
 7EJJEZZ	"FZZ	"FVuUG3C%D%J%J%LM		%	!!#Q}}S!---}}S!)))	 
& Vw&9:@@BD		%	!!#Q}}S!)))}}S!---	 
&	% 
&	% 
&	%s   AE/!AE;/E8;Fc           	      B   t        |d      }|j                  }t        j                  d      }t        j                  d      }|j	                  t
        dd| d|j                   dj                                t        j                  |j                        5  t                | j                         \  }}|j                  |      J |j                  |      J 	 d	d	d	       |j	                  t
        dd| d|j                   d
j                                t        j                  |j                        5  t                | j                         \  }}|j                  |      J |j                  |      J 	 d	d	d	       y	# 1 sw Y   xY w# 1 sw Y   y	xY w)z^Lowers cases in signature files by flag or when -h is present

    CLI :: --[no-]lower -h
    rX   rY   z	Block: HIz	Block: hir?   rZ   z -h z -m test --overwrite-signatureNz) -m test --overwrite-signature --no-lower)r   r   r   r   rB   rC   r   rD   r   rE   rF   rG   rb   r   r   s	            r   test_lower_sigr     sd   
 7EJJEZZ%FZZ%F 
wd599+%CDJJL 
	%	!!#Q}}S!---}}S!)))	 
& 
wd599+%NO		 
	%	!!#Q}}S!)))}}S!---	 
&	% 
&	% 
&	%s   AF	;AF	FFc           
      6   t        |      }d}d}|j                  t        dd| d| d| j                                t	        j
                  |j                        5  t                | j                         \  }}d| d|v sJ 	 d	d	d	       y	# 1 sw Y   y	xY w)
zNEnsures that the build directory can be specified

    CLI :: --build-dir
    r   tttmpr?   f2py -m r_   z --build-dir zWrote C/API module "r   Nri   )rK   r-   rL   rM   r   odirre   rf   s           r   test_build_dirr     s    
 !EEDV"5'5'tfEKKMO 
	%	!!#Q&ugR0C777 
&	%	%s   (BBc                 T   t        |      }|j                  t        dd| dj                                t	        j
                  |j                        5  t        d      j                  dd       t                | j                         \  }}d|v sJ 	 d	d	d	       y	# 1 sw Y   y	xY w)
zXEnsures that the build directory can be specified

    CLI :: --overwrite-signature
    r?   rm   z --overwrite-signaturern   ro   r!   r"   r`   N)
r   rB   rC   rD   r   rE   rF   r(   rG   rb   rj   s         r   test_overwriter     s    
 !EV
UG#9:@@BD 
	%[$$[7$C	!!#Q*c111	 
&	%	%s   A BB'c           	         t        |      }d}|j                  t        dd| d| dj                                t	        j
                  |j                        5  t                | j                         \  }}d|v sJ t        | d      j                         5 }d|j                         v sJ 	 d	d	d	       d	d	d	       y	# 1 sw Y   xY w# 1 sw Y   y	xY w)
zJEnsures that TeX documentation is written out

    CLI :: --latex-doc
    r   r?   r   r_   z --latex-docDocumentation is saved to file
module.tex\documentclassNr   rB   rC   rD   r   rE   rF   rG   rb   r   r   rK   r-   rL   rM   r   re   rf   otexs           r   test_latexdocr     s    
 !EEV"5'5'>DDFH 
	%	!!#Q/3666UG:&',,.$$		333 /	 
&	% /.	 
&	%s%   A CC /C C		CCc           	      &   t        |      }d}|j                  t        dd| d| dj                                t	        j
                  |j                        5  t                | j                         \  }}d|vsJ 	 ddd       y# 1 sw Y   yxY w)zMEnsures that TeX documentation is written out

    CLI :: --no-latex-doc
    r   r?   r   r_   z --no-latex-docr   Nri   rK   r-   rL   rM   r   re   rf   s          r   test_nolatexdocr     s    
 !EEV"5'5'AGGIK 
	%	!!#Q/s::: 
&	%	%   $BBc           	         t        |      }d}|j                  t        dd| d| dj                                t	        j
                  |j                        5  t                | j                         \  }}d|v sJ t        d| d      j                         5 }d	|j                         vsJ 	 d
d
d
       d
d
d
       y
# 1 sw Y   xY w# 1 sw Y   y
xY w)zEnsures that truncated documentation is written out

    TODO: Test to ensure this has no effect without --latex-doc
    CLI :: --latex-doc --short-latex
    r   r?   r   r_   z --latex-doc --short-latexr   ./r   r   Nr   r   s           r   test_shortlatexr     s     !EE
5'5'!;<BBD 
	%	!!#Q/3666BugZ()..0D$DIIK777 1	 
&	% 10	 
&	%%   ACC0CC
	CCc           	         t        |      }d}|j                  t        dd| d| dj                                t	        j
                  |j                        5  t                | j                         \  }}d|v sJ t        d| d      j                         5 }d	|j                         v sJ 	 d
d
d
       d
d
d
       y
# 1 sw Y   xY w# 1 sw Y   y
xY w)zIEnsures that RsT documentation is written out

    CLI :: --rest-doc
    r   r?   r   r_   z --rest-doc#ReST Documentation is saved to filer   zmodule.restz.. -*- rest -*-Nr   )rK   r-   rL   rM   r   re   rf   orsts           r   test_restdocr     s    
 !EEV"5'5'=CCEG 
	%	!!#Q4;;;Bug[)*//1T%444 2	 
&	% 21	 
&	%r   c           	      &   t        |      }d}|j                  t        dd| d| dj                                t	        j
                  |j                        5  t                | j                         \  }}d|vsJ 	 ddd       y# 1 sw Y   yxY w)zLEnsures that TeX documentation is written out

    CLI :: --no-rest-doc
    r   r?   r   r_   z --no-rest-docr   Nri   r   s          r   test_norestexdocr     s    
 !EEV"5'5'@FFHJ 
	%	!!#Q4C??? 
&	%	%r   c           	         t        |      }d}|j                  t        dd| d| dj                                t	        j
                  |j                        5  t                t        d| d      j                         5 }d|j                         v sJ 	 d	d	d	       d	d	d	       y	# 1 sw Y   xY w# 1 sw Y   y	xY w)
zIEnsures that debugging wrappers are written

    CLI :: --debug-capi
    r   r?   r   r_   z --debug-capir   r   z#define DEBUGCFUNCSN
r   rB   rC   rD   r   rE   rF   rG   r   r   )rK   r-   rL   rM   r   ocmods         r   test_debugcapir   #  s    
 !EEV"5'5'?EEGI 
	%	BugX&',,.%)UZZ\999 / 
&	%.. 
&	%s$   (B4B(B4(B1	-B44B=z2Consistently fails on CI; noisy so skip not xfail.c           	         t        |       }d}|j                  t        dd| d| dj                                t	        j
                  |j                        5  t                t        j                  d      }t        j                  |dd	      }d
}t        j                  d      }|j                  |k(  sJ |j                  |k(  sJ 	 ddd       y# 1 sw Y   yxY w)zEEnsures that debugging wrappers work

    CLI :: --debug-capi -c
    r   r?   r   r_   z -c --debug-capiz#python3 -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   rB   rC   rD   r   rE   rF   rG   shlex
subprocessruntextwrapdedentstdoutstderr)r-   rL   rM   r   cmd_runrouteouteerrs           r   test_debugcapi_bldr   3  s     !EEV"5'5'1ABHHJL 
	%	++EF~~gdWM 	  	 {{d"""{{d"""! 
&	%	%s   A1CCc           	      *   t        |      }d}|j                  t        dd| d| j                                t	        j
                  |j                        5  t                ddd       | j                         \  }}d|v sJ |j                  t        dd| d| dj                                t	        j
                  |j                        5  t                | j                         \  }}d|v sJ 	 ddd       y# 1 sw Y   xY w# 1 sw Y   yxY w)zoEnsures that fortran subroutine wrappers for F77 are included by default

    CLI :: --[no]-wrap-functions
    r   r?   r   r_   N Fortran 77 wrappers are saved toz --wrap-functionsri   r   s          r   test_wrapfunc_defr   Q  s     !EEVxwaw%?%E%E%GH		%	 
&FC.#555 V"5'5'1BCIIKM 
	%	!!#Q2c999 
&	% 
&	% 
&	%s   C=$D	=D	Dc           	      &   t        |      }d}|j                  t        dd| d| dj                                t	        j
                  |j                        5  t                | j                         \  }}d|vsJ 	 ddd       y# 1 sw Y   yxY w)zeEnsures that fortran subroutine wrappers for F77 can be disabled

    CLI :: --no-wrap-functions
    r   r?   r   r_   z --no-wrap-functionsr   Nri   r   s          r   test_nowrapfuncr   j  s    
 !EEV"5'5'1EFLLNP 
	%	!!#Q2#=== 
&	%	%r   c           	         t        |      }d}|j                  t        dd| d| dj                                t	        j
                  |j                        5  t                t        d| d      j                         5 }|j                         }d|v sJ d	|v sJ 	 d
d
d
       d
d
d
       y
# 1 sw Y   xY w# 1 sw Y   y
xY w)zcAdd to the include directories

    CLI :: -include
    TODO: Document this in the help string
    r   r?   r   r_   z' -include<stdbool.h> -include<stdio.h> r   r   z#include <stdbool.h>z#include <stdio.h>Nr   )rK   r-   rL   rM   r   r   ocmrs          r   test_inclheaderr   z  s     !EE
5'5'!HI	 
	%	BugX&',,.%::<D)T111'4/// / 
&	%.. 
&	%s$   (B<B0B<0B9	5B<<Cc                       y)z?Add to the include directories

    CLI :: --include-paths
    N r   r   r   test_inclpathr          	r   c                       y)z;Add to the include directories

    CLI :: --help-link
    Nr   r   r   r   
test_hlinkr     r   r   c                 L   t        |      }|j                  t        dd| dj                                t	        j
                  |j                        5  t                | j                         \  }}d|v sJ d|v sJ d|v sJ d|v sJ d|v sJ 	 d	d	d	       y	# 1 sw Y   y	xY w)
zOCheck that Fortran-to-Python KIND specs can be passed

    CLI :: --f2cmap
    r?   r@   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 changesNri   )rK   r=   rL   rM   re   rf   s         r   test_f2cmapr     s    
 EV}UG;L%M%S%S%UV		%	!!#Q2c999;sBBB<CCCASHHHASHHH 
&	%	%s   <BB#c                 0   t        |      }|j                  t        dd| dj                                t	        j
                  |j                        5  t                | j                         \  }}t        |      dk(  sJ 	 ddd       y# 1 sw Y   yxY w)z)Reduce verbosity

    CLI :: --quiet
    r?   r@   z --quietr   N)
r   rB   rC   rD   r   rE   rF   rG   rb   lenrj   s         r   
test_quietr     su    
 !EV}UG8%D%J%J%LM		%	!!#Q3x1}} 
&	%	%s   .BBc                    t        |      }|j                  t        dd| dj                                t	        j
                  |j                        5  t                | j                         \  }}d|v sJ 	 ddd       y# 1 sw Y   yxY w)z-Increase verbosity

    CLI :: --verbose
    r?   r@   z
 --verboseanalyzelineNri   rj   s         r   test_verboser     ss    
 !EV}UG:%F%L%L%NO		%	!!#Q### 
&	%	%s   $BBc                 ,   |j                  t        ddj                                t        j                  t
              5  t                | j                         \  }}ddl}|j                  |j                         k(  sJ 	 ddd       y# 1 sw Y   yxY w)z"Ensure version

    CLI :: -v
    r?   zf2py -vr   N)rB   rC   rD   rS   rT   rp   rG   rb   numpy__version__strip)rK   rL   re   rf   nps        r   test_versionr     sg    
 VY__%67	z	"	!!#Q~~,,,	 
#	"	"s   AB

Bc                 j   t        |       }|j                  t        dd| dj                                t	        j
                  |j                        5  t                t        j                  d      }t        j                  |dd      }d}|j                  |k(  sJ 	 d	d	d	       y	# 1 sw Y   y	xY w)
z
    CLI :: -c
    r?   r@   z -cz"python -c "import blah; blah.hi()"Tr   r   r   N)r   rB   rC   rD   r   rE   rF   rG   r   r   r   r   )r-   rL   rM   r   r   r   s         r   test_npdistopr     s    
 !EV}UG3%?%E%E%GH		%	++DE~~gdWM{{d""" 
&	%	%s   AB))B2c                       y)z
    CLI :: -c --fcompiler
    Nr   r   r   r   test_npd_fcompilerr         
 	r   c                       y)z
    CLI :: -c --compiler
    Nr   r   r   r   test_npd_compilerr     r   r   c                       y)z$
    CLI :: -c --help-fcompiler
    Nr   r   r   r   test_npd_help_fcompilerr     r   r   c                       y)z
    CLI :: -c --f77exec
    Nr   r   r   r   test_npd_f77execr     r   r   c                       y)z
    CLI :: -c --f90exec
    Nr   r   r   r   test_npd_f90execr     r   r   c                       y)z
    CLI :: -c --f77flags
    Nr   r   r   r   test_npd_f77flagsr    r   r   c                       y)z
    CLI :: -c --f90flags
    Nr   r   r   r   test_npd_f90flagsr  #  r   r   c                       y)z
    CLI :: -c --opt
    Nr   r   r   r   test_npd_optr  +  r   r   c                       y)z
    CLI :: -c --arch
    Nr   r   r   r   test_npd_archr  3  r   r   c                       y)z
    CLI :: -c --noopt
    Nr   r   r   r   test_npd_nooptr
  ;  r   r   c                       y)z
    CLI :: -c --noarch
    Nr   r   r   r   test_npd_noarchr  C  r   r   c                       y)z
    CLI :: -c --debug
    Nr   r   r   r   test_npd_debugr  K  r   r   c                       y)z%
    CLI :: -c --link-<resource>
    Nr   r   r   r   test_npd_link_autor  S  r   r   c                       y)z/
    CLI :: -c -L/path/to/lib/ -l<libname>
    Nr   r   r   r   test_npd_libr  [  r   r   c                       y)z
    CLI :: -D<define>
    Nr   r   r   r   test_npd_definer  c  r   r   c                       y)z
    CLI :: -U<name>
    Nr   r   r   r   test_npd_undefiner  k  r   r   c                       y)z$
    CLI :: -I/path/to/include/
    Nr   r   r   r   test_npd_inclr  s  r   r   c                       y)z8
    CLI :: <filename>.o <filename>.so <filename>.a
    Nr   r   r   r   test_npd_linkerr  {  r   r   )untitled)Sr   r   rC   r   r   pathlibr   collectionsr   platformrS    r   numpy.f2py.f2py2er   rG   r   r   fixturer-   r0   r2   r5   r8   r=   rP   rV   r]   rg   rk   rr   markskipifsystemversion_inforx   r}   xfailr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   skipr   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   + + +  "    - 
HH	IN i  ! i  ! i  ! i  ! i  ! i  !(	
:)
,C _X__&'1Ss7G7G77R7  9
)9
) _X__&'1Ss7G7G77R\xyG zG> D D.D.D<%"0 .4$.N8"2"4$; 8,5$@ :  MN# O#::2> 0.		I$$- MN# O#&																		r   