a
    �¥»a_  ã                   @   s  d 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mZ ddlm	Z	 ddlm
Z
 dd	lmZ dd
lmZ ddlmZ ejZejZejjZejZe	jZde› de› d�Zdd„ Zdd„ Zdd„ Zdd„ Zdd„ Zd!dd„Zdd„ Zdd„ Zdd „ ZdS )"a‡  

f2py2e - Fortran to Python C/API generator. 2nd Edition.
         See __usage__ below.

Copyright 1999--2011 Pearu Peterson all rights reserved,
Pearu Peterson <pearu@cens.ioc.ee>
Permission to use, modify, and distribute this software is given under the
terms of the NumPy License.

NO WARRANTY IS EXPRESSED OR IMPLIED.  USE AT YOUR OWN RISK.
$Date: 2005/05/06 08:31:19 $
Pearu Peterson

é    Né   )Úcrackfortran)Úrules)Úcb_rules)Úauxfuncs)Úcfuncs)Úf90mod_rules)Ú__version__)Ú	capi_mapsa¡  Usage:

1) To construct extension module sources:

      f2py [<options>] <fortran files> [[[only:]||[skip:]] \
                                        <fortran functions> ] \
                                       [: <fortran files> ...]

2) To compile fortran files and build extension modules:

      f2py -c [<options>, <build_flib options>, <extra options>] <fortran files>

3) To generate signature files:

      f2py -h <filename.pyf> ...< same options as in (1) >

Description: This program generates a Python C/API file (<modulename>module.c)
             that contains wrappers for given fortran functions so that they
             can be called from Python. With the -c option the corresponding
             extension modules are built.

Options:

  --2d-numpy       Use numpy.f2py tool with NumPy support. [DEFAULT]
  --2d-numeric     Use f2py2e tool with Numeric support.
  --2d-numarray    Use f2py2e tool with Numarray support.
  --g3-numpy       Use 3rd generation f2py from the separate f2py package.
                   [NOT AVAILABLE YET]

  -h <filename>    Write signatures of the fortran routines to file <filename>
                   and exit. You can then edit <filename> and use it instead
                   of <fortran files>. If <filename>==stdout then the
                   signatures are printed to stdout.
  <fortran functions>  Names of fortran routines for which Python C/API
                   functions will be generated. Default is all that are found
                   in <fortran files>.
  <fortran files>  Paths to fortran/signature files that will be scanned for
                   <fortran functions> in order to determine their signatures.
  skip:            Ignore fortran functions that follow until `:'.
  only:            Use only fortran functions that follow until `:'.
  :                Get back to <fortran files> mode.

  -m <modulename>  Name of the module; f2py generates a Python/C API
                   file <modulename>module.c or extension module <modulename>.
                   Default is 'untitled'.

  --[no-]lower     Do [not] lower the cases in <fortran files>. By default,
                   --lower is assumed with -h key, and --no-lower without -h key.

  --build-dir <dirname>  All f2py generated files are created in <dirname>.
                   Default is tempfile.mkdtemp().

  --overwrite-signature  Overwrite existing signature file.

  --[no-]latex-doc Create (or not) <modulename>module.tex.
                   Default is --no-latex-doc.
  --short-latex    Create 'incomplete' LaTeX document (without commands
                   \documentclass, \tableofcontents, and \begin{document},
                   \end{document}).

  --[no-]rest-doc Create (or not) <modulename>module.rst.
                   Default is --no-rest-doc.

  --debug-capi     Create C/API code that reports the state of the wrappers
                   during runtime. Useful for debugging.

  --[no-]wrap-functions    Create Fortran subroutine wrappers to Fortran 77
                   functions. --wrap-functions is default because it ensures
                   maximum portability/compiler independence.

  --include-paths <path1>:<path2>:...   Search include files from the given
                   directories.

  --help-link [..] List system resources found by system_info.py. See also
                   --link-<resource> switch below. [..] is optional list
                   of resources names. E.g. try 'f2py --help-link lapack_opt'.

  --f2cmap <filename>  Load Fortran-to-Python KIND specification from the given
                   file. Default: .f2py_f2cmap in current directory.

  --quiet          Run quietly.
  --verbose        Run with extra verbosity.
  -v               Print f2py version ID and exit.


numpy.distutils options (only effective with -c):

  --fcompiler=         Specify Fortran compiler type by vendor
  --compiler=          Specify C compiler type (as defined by distutils)

  --help-fcompiler     List available Fortran compilers and exit
  --f77exec=           Specify the path to F77 compiler
  --f90exec=           Specify the path to F90 compiler
  --f77flags=          Specify F77 compiler flags
  --f90flags=          Specify F90 compiler flags
  --opt=               Specify optimization flags
  --arch=              Specify architecture specific optimization flags
  --noopt              Compile without optimization
  --noarch             Compile without arch-dependent optimization
  --debug              Compile with debugging information

Extra options (only effective with -c):

  --link-<resource>    Link extension module with <resource> as defined
                       by numpy.distutils/system_info.py. E.g. to link
                       with optimized LAPACK libraries (vecLib on MacOSX,
                       ATLAS elsewhere), use --link-lapack_opt.
                       See also --help-link switch.

  -L/path/to/lib/ -l<libname>
  -D<define> -U<name>
  -I/path/to/include/
  <filename>.o <filename>.so <filename>.a

  Using the following macros may be required with non-gcc Fortran
  compilers:
    -DPREPEND_FORTRAN -DNO_APPEND_FORTRAN -DUPPERCASE_FORTRAN
    -DUNDERSCORE_G77

  When using -DF2PY_REPORT_ATEXIT, a performance report of F2PY
  interface is printed out at exit (platforms: Linux).

  When using -DF2PY_REPORT_ON_ARRAY_COPY=<int>, a message is
  sent to stderr whenever F2PY interface makes a copy of an
  array. Integer <int> sets the threshold for array sizes when
  a message should be shown.

Version:     z
numpy Version: zÇ
Requires:    Python 3.5 or higher.
License:     NumPy license (see LICENSE.txt in the NumPy source code)
Copyright 1999 - 2011 Pearu Peterson all rights reserved.
http://cens.ioc.ee/projects/f2py2e/c                 C   s,  g g g g f\}}}}d\	}}}}}	}
}}}d}d}d}d}d}d}g }d\}}|d d dœ}| D �]’}|dkrnq^|d	kr|d}q^|d
krŠd}q^|dkr˜d}q^|d d… dkr¼|  |dd … ¡ q^|dkrÊd}q^|dkrØd}	q^|dkræd}q^|dk� röd}q^|dk�r
|d7 }q^|dk�rd}q^|dk�r*d}q^|dk�r:d}q^|dk�rJd}q^|dk�rZd}q^|dk�rjd}q^|dk�r~d|d< q^|dk�rŽd}q^|dk�ržd}q^|dk�r®d}q^|dk�rÂd|d< q^|d k�rÒd}q^|d!k�râd}q^|d d"… d#k�rttƒ t ¡  q^|d$k�rd}q^|d d… d%k�r`tjd&   |d'd… ¡ d(|dd …  tj|d'd… < q^|d d)… d*v �r€td+ƒ d}
q^|d d)… d,v �r˜d}
q^|d d-k�rÀt	d.t
|ƒ ƒ t ¡  q^|�rÐd}|}q^|�ràd}|}q^|	�rðd}	|}q^|
�rd}
| | tj¡¡ q^|�r"d}||d/< q^|�r6d}||d0< q^|�rJd}||d1< q^|dk�rÊz8t|ƒ� W d   ƒ n1 �sv0    Y  |  |¡ W n: t�yÆ } z t	d2t|ƒ|f ƒ W Y d }~n
d }~0 0 q^|dk�rà|  |¡ q^|dkr^|  |¡ q^|�s|�s|�sttƒ t ¡  tj |¡�s@|�s6td3| ƒ t |¡ |�rTtj ||¡}|�r†tj |¡�r†d|v�r†t	d4| ƒ t ¡  ||d5< ||d6< |dk�r°|�s°d|d7< n||d7< |�rÆ||d8< |�rÔ||d9< |�râ||d:< |�rð||d;< ||d<< ||d=< ||d>< ||d?< ||d@< | d1d ¡ ||fS )AN)	r   r   r   r   r   r   r   r   r   r   éÿÿÿÿr   Ú.)NN)Ú	buildpathÚcoutputÚf2py_wrapper_outputÚ úonly:úskip:ú:é   z--debug-z--lowerú--build-dirz
--no-lowerú--quietz	--verbosez--latex-docz--no-latex-docz
--rest-docz--no-rest-docz--wrap-functionsz--no-wrap-functionsz--short-latexZ
shortlatexz	--coutputz--f2py-wrapper-outputú--f2cmapz--overwrite-signaturezh-overwritez-hú-mé   z-vz--show-compilersz-includeÚuserincludesé	   z	#include é   ú--include_pathszHf2py option --include_paths is deprecated, use --include-paths instead.
ú--include-pathsú-zUnknown option %s
r   r   Úf2cmap_filez!IOError: %s. Skipping file "%s".
zCreating build directory %szFSignature file "%s" exists!!! Use --overwrite-signature to overwrite.
ÚdebugÚverboseúdo-lowerÚmoduleÚ	signsfileÚ	onlyfuncsÚ	skipfuncsÚ
dolatexdocÚ	dorestdocÚ	wrapfuncsr   Úinclude_paths)ÚappendÚprintÚf2py_versionÚsysÚexitr   Zoutneedsr   ÚoutmessÚerrmessÚreprÚextendÚsplitÚosÚpathsepÚopenÚIOErrorÚstrÚ	__usage__ÚpathÚisdirÚmkdirÚjoinÚisfileÚ
setdefault)Z	inputlineÚfilesr'   r&   r!   ÚfÚf2Zf3Zf5Zf6Zf7Zf8Zf9Zf10r"   Zdolcr(   r)   r*   r   r+   r%   Ú
modulenameÚoptionsÚlZdetail© rH   úK/home/yuhw/wc/pochoir/venv/lib/python3.9/site-packages/numpy/f2py/f2py2e.pyÚscaninputline®   s&   þ




















 ÿ





 
ÿ

ÿ
rJ   c                 C   s~  |t _|d t_|d t_d|v r,|d t_d|v r>|d t_d|v rP|d t_|d tjd d …< |d t_	t | ¡}d|v ròt
d	|d  ƒ t |¡}|d d
d … dkrºtj |¡ n8t|d dƒ�}| |¡ W d   ƒ n1 sè0    Y  |d d u �r|D ]}d|d  |d< �qn|D ]}|d |d< �q"|d d u �rb|D ]}d|d  |d< �qHn|D ]}|d |d< �qf|S )Nr!   r"   r$   r'   r&   r+   r#   r%   zSaving signatures to file "%s"
iúÿÿÿÚstdoutÚwr   z
%smodule.cÚnamer   z%s-f2pywrappers.f)r   rF   r   r!   r"   Zf77modulenamer'   r&   r+   Zdolowercaser1   Zcrack2fortranr/   rK   Úwriter8   )rB   rF   ÚpostlistZpyfrC   ÚmodrH   rH   rI   ÚcallcrackfortranB  s<    







(rQ   c              
   C   s¢  t  ¡  tdƒ g g i   }}}tt| ƒƒD ]Œ}d| | d v rPt | | ¡ q,d| | v r˜| | d  ¡ D ]*}||vr€g ||< ||  | | d ¡ ql| | | ¡ | | | d ¡ q,i }tt|ƒƒD ]Ò}|| |v �r
td|| d 	dd„ |||  D ƒ¡f ƒ qÊg }d|| v �rr|| d  ¡ D ]D}||v �rZ||v �rZ| || 
|¡ ¡ ntd	|| |f ƒ �q,i ||| < t|||  t || |¡ƒ qÊ|S )
NzBuilding modules...
Ú__user__rM   Úusez+	Skipping module "%s" which is used by %s.
ú,c                 S   s   g | ]}d | ‘qS ©z"%s"rH   ©Ú.0ÚsrH   rH   rI   Ú
<listcomp>y  ó    z buildmodules.<locals>.<listcomp>z:	Module "%s" uses nonexisting "%s" which will be ignored.
)r   Zbuildcfuncsr1   ÚrangeÚlenr   ZbuildcallbacksÚkeysr,   r?   ÚindexÚdict_appendr   Zbuildmodule)ÚlstÚmodulesZmnamesÚisusedbyÚiÚuÚretZumrH   rH   rI   Úbuildmodulesf  s<     ÿ
ÿ rf   c                 C   sP   |  ¡ D ]B\}}|| vr g | |< t|tƒr<| | | | |< q| |  |¡ qd S ©N)ÚitemsÚ
isinstanceÚlistr,   )Zd_outZd_inÚkÚvrH   rH   rI   r_   ˆ  s    
r_   c              
   C   s  t  ¡  tj tj tj¡¡}tj |dd¡}tj |dd¡}t	| ƒ\}}|t
_t |d ¡ t||ƒ}i }tt|ƒƒD ]L}d|| v rx|| d  ¡ D ]*}	|	|vr¬g ||	< ||	  || d ¡ q˜qxtt|ƒƒD ]h}|| d dkrÒd	|| d v rÒ|| d |v rÒtd
|| d d dd„ ||| d  D ƒ¡f ƒ qÒd|v �r‚|d dk�r~tdƒ tdtj tjd ¡|d f ƒ dS tt|ƒƒD ]B}|| d dk�rŽd|v�r¶tdƒ tdt|| d ƒ ƒ‚�qŽ|d t
_|t_|d t
_t|ƒ}
|
 ¡ D ]}t|
| ||dœƒ �qü|
S )aJ  
    Equivalent to running::

        f2py <args>

    where ``<args>=string.join(<list>,' ')``, but in Python.  Unless
    ``-h`` is used, this function returns a dictionary containing
    information on generated modules and their dependencies on source
    files.  For example, the command ``f2py -m scalar scalar.f`` can be
    executed from Python as follows

    You cannot build extension modules with this function, that is,
    using ``-c`` is not allowed. Use ``compile`` command instead

    Examples
    --------
    .. include:: run_main_session.dat
        :literal:

    Úsrczfortranobject.hzfortranobject.cr    rS   rM   Úblockzpython modulerR   z<Skipping Makefile build for module "%s" which is used by %s
rT   c                 S   s   g | ]}d | ‘qS rU   rH   rV   rH   rH   rI   rY   »  rZ   zrun_main.<locals>.<listcomp>r%   r"   r   zKStopping. Edit the signature file and then run f2py on the signature file: z%s %s
r   NzJTip: If your original code is Fortran source then you must use -m option.
z2All blocks must be python module blocks but got %sr!   r*   )ZcsrcÚh)r   Zreset_global_f2py_varsr6   r<   ÚdirnameÚabspathr   Ú__file__r?   rJ   r   rF   r
   Zload_f2cmap_filerQ   r[   r\   r]   r,   r1   Úbasenamer/   Úargvr2   Ú	TypeErrorr3   Zdebugoptionsr   r*   rf   r_   )Zcomline_listZf2pydirZfobjhsrcZfobjcsrcrB   rF   rO   rb   rc   rd   re   ÚmnrH   rH   rI   Úrun_main’  s\    
 (ÿ

ÿÿ
ÿÿ


rw   c           	      C   sv   g g  }}t  | d | d ¡j}|r0t| ƒ}nd}dd„ |D ƒD ]*}||ƒrb| ||d… ¡ qB| |¡ qB||fS )z,
    Filter files by prefix and suffix.
    z.*z\Zr   c                 S   s   g | ]}|  ¡ ‘qS rH   )Ústrip)rW   ÚxrH   rH   rI   rY   ß  rZ   z filter_files.<locals>.<listcomp>N)ÚreÚcompileÚmatchr\   r,   )	ÚprefixÚsuffixrB   Úremove_prefixÚfilteredÚrestr|   ÚindÚfilerH   rH   rI   Úfilter_filesÕ  s    

r„   c                 C   s   t j t j | j¡¡}|S rg   )r6   r<   rp   rr   )r$   ÚprH   rH   rI   Ú
get_prefixç  s    r†   c            $   
      s’  ddl } tj d¡}tj|= d}ztj d¡}W n tyF   d}Y n0 |durttj|d  }tj|d = tj|= nd}|  ¡ }t d¡‰ ‡ fdd„tjdd… D ƒ‰
‡
fd	d„tjD ƒt_ˆ
rÎd
d„ ˆ
D ƒ‰
t d¡‰‡fdd„tjdd… D ƒ‰‡fdd„tjD ƒt_g ‰d}tjdd… D ]>}|dv �r4d}n|dk�rBd}|�sR|dk�r ˆ |¡ �q ˆ�r~ˆd dk�r~ˆ d¡ ˆ 	ˆ¡ ‡fdd„tjD ƒt_t d¡‰‡fdd„tjdd… D ƒ‰‡fdd„tjD ƒt_t d¡‰‡fdd„tjdd… D ƒ‰‡fdd„tjD ƒt_g }ˆD ]Î}d}|dt
|ƒ… |k�rddlm}	 |	 ¡  t|	j ¡ ƒ}
|t
|ƒd…  ¡  }}||
v�rÐi }z|| }W n: t�yÊ   || ¡ v�rÆtd|t
|ƒd…  ƒ Y n0 |}ˆ |¡}d| ˆ|< �q�q|D ]}ˆ |¡}ˆ|= �qòt
ˆƒdk�s$J tˆƒƒ‚t d¡‰‡fdd„tjdd… D ƒ‰	‡	fdd„tjD ƒt_dˆv �rtˆ	 d¡ d }tjdd… }d!D ]X}|tjv �rŠtj |¡}ˆ 	tj||d … ¡ tj|d = tj|= tjdd… }�qŠd"tjv �r.tj d"¡}tj|d  }tj|d = tj|= tjdd… }nDdd#lm} td$d%|ƒ\}}|| }|D ]}||ƒ}|�rV �qr�qVtd$d&|ƒ\}}td'd$|dd(�\}}td)d$|dd(�\}}td*d$|dd(�\}}td+d$|dd(�\}}td,d$|dd(�\}}tt
|ƒƒD ]T}||  d-d¡}t
|ƒdk�r| d¡ t
|ƒdk�r:t|ƒ||< n
td.|ƒ �qòdd/lm} i }|�rp| 	| d0g ¡¡ dd1lm }m!} ||||||||ˆd2œ	}ˆ
�rädd3l"m#}  ˆ
D ]4}!||!ƒ}|�sÐt$d4t|!ƒ ƒ | |fi |¤Ž �q®|f i |¤Ž}"tjd gˆ	 t_tj 	d5d6|d7|d8d9d:g¡ ˆ�r8tj 	d;gˆ ¡ ˆ�rPtj 	d<gˆ ¡ ||"gd=� |�rŽt%j& '|¡�rŽddl(}#t$d>| ƒ |# )|¡ dS )?z 
    Do it all in one call!
    r   Nú-cr   r   z--link-c                    s   g | ]}ˆ   |¡r|‘qS rH   ©r|   ©rW   Ú_m)Ú_reg1rH   rI   rY     rZ   zrun_compile.<locals>.<listcomp>c                    s   g | ]}|ˆ vr|‘qS rH   rH   r‰   )Úsysinfo_flagsrH   rI   rY     rZ   c                 S   s   g | ]}|d d… ‘qS )é   NrH   )rW   rC   rH   rH   rI   rY     rZ   z:--((no-|)(wrap-functions|lower)|debug-capi|quiet)|-includec                    s   g | ]}ˆ   |¡r|‘qS rH   rˆ   r‰   )Ú_reg2rH   rI   rY   
  rZ   c                    s   g | ]}|ˆ vr|‘qS rH   rH   r‰   )Ú
f2py_flagsrH   rI   rY     rZ   )r   r   r   r   c                    s   g | ]}|ˆ vr|‘qS rH   rH   r‰   )Úf2py_flags2rH   rI   rY     rZ   z4--((f(90)?compiler(-exec|)|compiler)=|help-compiler)c                    s   g | ]}ˆ   |¡r|‘qS rH   rˆ   r‰   )Ú_reg3rH   rI   rY     rZ   c                    s   g | ]}|ˆ vr|‘qS rH   rH   r‰   )Ú
flib_flagsrH   rI   rY     rZ   zH--((f(77|90)(flags|exec)|opt|arch)=|(debug|noopt|noarch|help-fcompiler))c                    s   g | ]}ˆ   |¡r|‘qS rH   rˆ   r‰   )Ú_reg4rH   rI   rY      rZ   c                    s   g | ]}|ˆ vr|‘qS rH   rH   r‰   )Úfc_flagsrH   rI   rY   !  rZ   z--fcompiler=)Ú	fcompilerzUnknown vendor: "%s"r   z--(verbose)c                    s   g | ]}ˆ   |¡r|‘qS rH   rˆ   r‰   )Ú_reg5rH   rI   rY   =  rZ   c                    s   g | ]}|ˆ vr|‘qS rH   rH   r‰   )Úsetup_flagsrH   rI   rY   >  rZ   r   Zuntitled)r   r   r   r   )Úget_f2py_modulenamer   z[.]pyf([.]src|)z[.](o|a|so|dylib)z-I)r   z-Lz-lz-Uz-Dú=zInvalid use of -D:)Úget_infoÚinclude_dirs)ÚsetupÚ	Extension)	rM   Úsourcesr›   Úlibrary_dirsÚ	librariesÚdefine_macrosÚundef_macrosÚextra_objectsZf2py_options)r_   z9No %s resources found in system (try `f2py --help-link`)
Úbuildz--build-tempz--build-basez--build-platlibr   z--disable-optimizationZ	config_fcÚ	build_ext)Úext_moduleszRemoving build directory %s
)*Útempfiler/   rt   r^   Ú
ValueErrorÚmkdtemprz   r{   r,   r4   r\   Znumpy.distutilsr•   Zload_all_fcompiler_classesrj   Zfcompiler_classr]   ÚlowerÚKeyErrorÚvaluesr-   r3   Z!numpy.distutils.command.build_srcr˜   r„   r[   r5   ÚtupleÚnumpy.distutils.system_inforš   ÚgetZnumpy.distutils.corerœ   r�   Znumpy.distutils.misc_utilr_   r1   r6   r<   ÚexistsÚshutilÚrmtree)$r§   rc   Zremove_build_dirÚ	build_dirÚflÚaZdel_listrX   rl   r•   Zallowed_keysÚnvÚovZvmaprE   rž   Úoptnamer˜   Z	pyf_filesrC   r£   r›   rŸ   r    r¢   r¡   Ú
name_valuerš   Znum_inforœ   r�   Zext_argsr_   ÚnÚextr±   rH   )r‹   rŽ   r‘   r“   r–   r�   r�   r”   r’   r—   rŒ   rI   Úrun_compileì  s(   


ÿ



ÿÿ








ù
ÿûr¼   c                  C   sú   dt jdd … v r4t j d¡ ddlm}  | ƒ  d S dt jdd … v r^t j d¡ t  d¡ nldt jdd … v r~t j d¡ nLdt jdd … v rªt j d	¡ t j d¡ n d
t jdd … v rÊt j d
¡ n dt jdd … v rät	ƒ  nt
t jdd … ƒ d S )Nz--help-linkr   r   ©Úshow_allz
--g3-numpyz*G3 f2py support is not implemented, yet.\nz--2e-numericz--2e-numarrayz
-DNUMARRAYz
--2e-numpyr‡   )r/   rt   Úremover®   r¾   ÚstderrrN   r0   r,   r¼   rw   r½   rH   rH   rI   Úmain™  s$    rÁ   )N) Ú__doc__r/   r6   Úpprintrz   r   r   r   r   r   r   r   r	   r
   Úversionr.   Znumpy_versionrÀ   rN   r2   Úshowr1   r;   rJ   rQ   rf   r_   rw   r„   r†   r¼   rÁ   rH   rH   rH   rI   Ú<module>   sH   � €ÿ 	 $"
C
 .