o
    d2`                     @   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 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)Path   )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'.

  '-include<header>'  Writes additional headers in the C wrapper, can be passed
                      multiple times, generates #include <header> each time.

  --[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.
  --skip-empty-wrappers   Only generate wrapper files when needed.
  -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.
https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2ec                 C   s(  g g g g f\}}}}d\	}}}}}	}
}}}d}d}d}d}d}d}d}g }d\}}|d d d}| D ]}|d	kr9q1|d
kr@d}q1|dkrGd}q1|dkrNd}q1|d d dkr`| |dd   q1|dkrgd}q1|dkrnd}	q1|dkrud}q1|dkr|d}q1|dkr|d7 }q1|dkrd}q1|dkrd}q1|dkrd}q1|dkrd}q1|dkrd}q1|dkrd}q1|dkrd|d< q1|dkrd}q1|dkrd}q1|dkrd}q1|dkrd|d < q1|d!krd}q1|d"krd}q1|d d# d$krtt t  q1|d%krd}q1|d d d&kr!tjd'  |d(d  d)|dd   tj|d(d < q1|d d* d+v r1td, d}
q1|d d* d-v r=d}
q1|d.krEd/}q1|d d0krYt	d1t
|  t  q1|rad}|}q1|rid}|}q1|	rqd}	|}q1|
rd}
||tj q1|rd}||d2< q1|rd}||d3< q1|rd}||d4< q1|dkrzt| W d    n	1 sw   Y  | | W q1 ty } zt	d5|d6|d7 W Y d }~q1d }~ww |dkr| | q1|dkr| | q1|s|s|stt t  tj|s|std8|  t| |r$tj||}|r=tj|r=d |vr=t	d9|  t  ||d:< ||d;< ||d<< |dkrV|sVd|d=< n||d=< |ra||d>< |rh||d?< |ro||d@< |rv||dA< ||dB< ||dC< ||dD< ||dE< ||dF< |d4d  ||fS )GN)	r   r   r   r   r   r   r   r   r   r   Tr   .)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-latex
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-pathsz--skip-empty-wrappersF-zUnknown option %s
r   r   f2cmap_filez	OSError: z. Skipping file "z".
zCreating build directory %s
zFSignature file "%s" exists!!! Use --overwrite-signature to overwrite.
emptygendebugverbosedo-lowermodule	signsfile	onlyfuncs	skipfuncs
dolatexdoc	dorestdoc	wrapfuncsr   include_paths)appendprintf2py_versionsysexitr   outneedsr   outmesserrmessreprextendsplitospathsepopenOSError	__usage__pathisdirmkdirjoinisfile
setdefault)	inputlinefilesr*   r)   r$   ff2f3f5f6f7f8f9f10r%   r#   dolcr+   r,   r-   r   r.   r(   
modulenameoptionsldetail rU   V/var/www/html/visualizacion-main/env/lib/python3.10/site-packages/numpy/f2py/f2py2e.pyscaninputline   s2  




 






"




rW   c                 C   st  |t _|d t_|d t_d|v r|d t_d|v r|d t_d|v r(|d t_|d tjd d < |d t_	t| }d|v ryt
d	|d   t|}|d d
d  dkr]tj| nt|d d}|| W d    n1 stw   Y  |d d u r|D ]
}d|d  |d< qn|D ]}|d |d< q|d d u r|D ]
}d|d  |d< q|S |D ]}|d |d< q|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   rR   r   r$   r%   f77modulenamer*   r)   r.   dolowercaser5   crack2fortranr2   rX   writer<   )rF   rR   postlistpyfrG   modrU   rU   rV   callcrackfortranJ  sB   







rb   c           
   	   C   sX  t   td g g i }}}| D ]8}d|d v r t| qd|v r>|d  D ]}||vr4g ||< || |d  q*|| ||d  qi }t||D ]W\}}||v rmtd|ddd || D f  qRg }	d|v r|d  D ] }||v r||v r|	||	|  qytd	| d
| d qyi ||< t
|| t||	 qR|S )NzBuilding modules...
__user__rZ   usez+	Skipping module "%s" which is used by %s.
,c                 s   s    | ]}d | V  qdS )z"%s"NrU   .0srU   rU   rV   	<genexpr>  s    zbuildmodules.<locals>.<genexpr>z		Module "z" uses nonexisting "z" which will be ignored.
)r   buildcfuncsr5   r   buildcallbackskeysr/   ziprB   indexdict_appendr   buildmodule)
lstmodulesmnamesisusedbyitemuretr'   rZ   umrU   rU   rV   buildmodulesn  s<   

ry   c                 C   sP   |  D ]!\}}|| vrg | |< t|tr| | | | |< q| | | qd S N)items
isinstancelistr/   )d_outd_inkvrU   rU   rV   ro     s   
ro   c              
   C   s  t   tjtjtj}tj|dd}tj|dd}t	| \}}|t
_t|d  t||}i }|D ] }d|v rX|d  D ]}	|	|vrNg ||	< ||	 |d  qDq8|D ]-}|d dkrd	|d v r|d |v rtd
|d  dddd ||d  D  q[d|v r|d dkrtd tdtjtjd |d f  dS |D ]}|d dkrd|vrtd tdt|d  q|d t
_|t_|d t
_t|}
|
 D ]}t|
| ||d q|
S )au  
    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.

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

    Examples
    --------
    The command ``f2py -m scalar scalar.f`` can be executed from Python as
    follows.

    .. literalinclude:: ../../source/f2py/code/results/run_main_session.dat
        :language: python

    srczfortranobject.hzfortranobject.cr"   rd   rZ   blockzpython modulerc   z$Skipping Makefile build for module "z" which is used by {}
re   c                 s   s    | ]	}d | d V  qdS )"NrU   rf   rU   rU   rV   ri     s    zrun_main.<locals>.<genexpr>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-   )csrch)r   reset_global_f2py_varsr:   r?   dirnameabspathr   __file__rB   rW   r   rR   r   load_f2cmap_filerb   rl   r/   r5   formatbasenamer2   argvr6   	TypeErrorr7   debugoptionsr	   r-   ry   ro   )comline_listf2pydirfobjhsrcfobjcsrcrF   rR   r_   rt   plistrv   rw   mnrU   rU   rV   run_main  sh   



r   c           	      C   sv   g g }}t | d | d j}|rt| }nd}dd |D D ]}||r1|||d  q!|| q!||fS )z,
    Filter files by prefix and suffix.
    z.*z\Zr   c                 S   s   g | ]}|  qS rU   )strip)rg   xrU   rU   rV   
<listcomp>  s    z filter_files.<locals>.<listcomp>N)recompilematchlenr/   )	prefixsuffixrF   remove_prefixfilteredrestr   indfilerU   rU   rV   filter_files  s   

r   c                 C   s   t jt j| j}|S rz   )r:   r?   r   r   )r'   prU   rU   rV   
get_prefix  s   r   c            $   
      s  ddl } tjd}tj|= d}ztjd}W n ty#   d}Y nw |dur:t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_
rgd
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 rd}n|dkrd}|s|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 ]g}d}|dt
| |krnddlm}	 |	  t|	j }
|t
|d   }}||
vrai }z|| }W n ty^   || vr\td|t
|d   Y nw |}|}d| |< qq|D ]}|}|= qrt
dksJ ttdfddtjdd D 		fddtjD t_dv r	d d }tjdd }d!D ],}|tjv rtj|}	tj||d   tj|d = tj|= tjdd }qd"tjv rtjd"}tj|d  }tj|d = tj|= tjdd }n!dd#lm} td$d%|\}}|| }|D ]}||}|r/ nq$t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 ]+}|| d-d}t
|dkr|d t
|dkrt|||< qqtd.| qqdd/lm} i }|r|	|d0g  dd1lm }m!} ||||||||d2	}
rdd3l"m#}  
D ]}!||!}|st$d4t|!  | |fi | q|d?i |}"tjd g	 t_tj	d5d6|d7|d8d9d:g rtj	d;g  r!tj	d<g  ||"gd= |rBt%j&'|rDddl(}#t$d>|  |#)| dS dS dS )@z 
    Do it all in one call!
    r   N-cr   r   z--link-c                       g | ]	}  |r|qS rU   r   rg   _m)_reg1rU   rV   r         zrun_compile.<locals>.<listcomp>c                       g | ]}| vr|qS rU   rU   r   )sysinfo_flagsrU   rV   r         c                 S   s   g | ]}|d d qS )   NrU   )rg   rG   rU   rU   rV   r     r   zN--((no-|)(wrap-functions|lower)|debug-capi|quiet|skip-empty-wrappers)|-includec                    r   rU   r   r   )_reg2rU   rV   r     r   c                    r   rU   rU   r   )
f2py_flagsrU   rV   r     r   )r   r   r   r   c                    r   rU   rU   r   )f2py_flags2rU   rV   r   &  r   z4--((f(90)?compiler(-exec|)|compiler)=|help-compiler)c                    r   rU   r   r   )_reg3rU   rV   r   )  r   c                    r   rU   rU   r   )
flib_flagsrU   rV   r   *  r   zH--((f(77|90)(flags|exec)|opt|arch)=|(debug|noopt|noarch|help-fcompiler))c                    r   rU   r   r   )_reg4rU   rV   r   -  r   c                    r   rU   rU   r   )fc_flagsrU   rV   r   .  r   z--fcompiler=)	fcompilerzUnknown vendor: "%s"r   z--(verbose)c                    r   rU   r   r   )_reg5rU   rV   r   I  r   c                    r   rU   rU   r   )setup_flagsrU   rV   r   J  r   r   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)	rZ   sourcesr   library_dirs	librariesdefine_macrosundef_macrosextra_objectsf2py_options)ro   z9No %s resources found in system (try `f2py --help-link`)
buildz--build-tempz--build-basez--build-platlibr   z--disable-optimization	config_fc	build_ext)ext_moduleszRemoving build directory %s
rU   )*tempfiler2   r   rn   
ValueErrormkdtempr   r   r/   r8   r   numpy.distutilsr   load_all_fcompiler_classesr}   fcompiler_classrl   lowerKeyErrorvaluesr0   r7   !numpy.distutils.command.build_srcr   r   ranger9   tuplenumpy.distutils.system_infor   getnumpy.distutils.corer   r   numpy.distutils.misc_utilro   r5   r:   r?   existsshutilrmtree)$r   iremove_build_dir	build_dirfladel_listrh   r   r   allowed_keysnvovvmaprQ   r   optnamer   	pyf_filesrG   r   r   r   r   r   r   
name_valuer   num_infor   r   ext_argsro   nextr   rU   )r   r   r   r   r   r   r   r   r   r   r   rV   run_compile  s8  













r   c                  C   s   dt jdd  v rt jd ddlm}  |   d S dt jdd  v r/t jd t d n7dt jdd  v r?t jd n'dt jdd  v rUt jd	 t jd nd
t jdd  v ret jd
 n	 dt jdd  v rtt	  d S 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   )r2   r   remover   r   stderrr^   r3   r/   r   r   r   rU   rU   rV   main  s&   
r   rz   )"__doc__r2   r:   pprintr   pathlibr   r   r   r   r   r   r   r	   r
   r   versionr1   numpy_versionr   r^   r6   showr5   r>   rW   rb   ry   ro   r   r   r   r   r   rU   rU   rU   rV   <module>   sR         $#

G -