o
    U=ºiòb  ã                   @   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rŒd}q1|dkr“d}q1|dkršd}q1|dkr¡d}q1|dkr¨d}q1|dkr¯d}q1|dkr¸d|d< q1|dkr¿d}q1|dkrÆd}q1|dkrÍd}q1|dkrÖd|d < q1|d!krÝd}q1|d"kräd}q1|d d#… d$krõttƒ t ¡  q1|d%krüd}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|
�r€d}
| | tj¡¡ q1|�rŠd}||d2< q1|�r”d}||d3< q1|�ržd}||d4< q1|dk�rÞzt|ƒ� W d   ƒ n	1 �s´w   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   Téÿÿÿÿ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-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   Zoutneedsr   ÚoutmessÚerrmessÚreprÚextendÚsplitÚosÚpathsepÚopenÚOSErrorÚ	__usage__ÚpathÚisdirÚmkdirÚjoinÚisfileÚ
setdefault)Z	inputlineÚfilesr)   r(   r#   ÚfÚf2Zf3Zf5Zf6Zf7Zf8Zf9Zf10r$   r"   Zdolcr*   r+   r,   r   r-   r'   Ú
modulenameÚoptionsÚlZdetail© rI   úWC:\Users\psant\Downloads\PAF backend\school\venv\Lib\site-packages\numpy/f2py/f2py2e.pyÚscaninputline³   s2  þ




 ÿ






ÿ"€ÿ


€
ÿ
rK   c                 C   sr  |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< q�|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   rG   r   r#   r$   Zf77modulenamer)   r(   r-   Zdolowercaser3   Zcrack2fortranr1   rL   Úwriter:   )rC   rG   ÚpostlistZpyfrD   ÚmodrI   rI   rJ   ÚcallcrackfortranJ  s@   







ÿþrR   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__rN   Úusez+	Skipping module "%s" which is used by %s.
ú,c                 s   s   � | ]}d | V  qdS )z"%s"NrI   ©Ú.0ÚsrI   rI   rJ   Ú	<genexpr>�  s   € zbuildmodules.<locals>.<genexpr>z		Module "z" uses nonexisting "z" which will be ignored.
)r   Zbuildcfuncsr3   r   ZbuildcallbacksÚkeysr.   Úzipr@   ÚindexÚdict_appendr   Zbuildmodule)
ÚlstÚmodulesZmnamesÚisusedbyÚitemÚuÚretr&   rN   ZumrI   rI   rJ   Úbuildmodulesn  s<   

ÿÿrd   c                 C   sP   |  ¡ D ]!\}}|| vrg | |< t|tƒr| | | | |< q| |  |¡ qd S ©N)ÚitemsÚ
isinstanceÚlistr.   )Zd_outZd_inÚkÚvrI   rI   rJ   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 }|D ] }d|v rX|d  ¡ D ]}	|	|vrNg ||	< ||	  |d ¡ qDq8|D ]-}|d dkrˆd	|d v rˆ|d |v rˆtd
|d › d� d dd„ ||d  D ƒ¡¡ƒ q[d|v rª|d dkr¨tdƒ tdtj tjd ¡|d f ƒ dS |D ]}|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 )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!   rT   rN   Úblockzpython modulerS   z$Skipping Makefile build for module "z" which is used by {}
rU   c                 s   s   � | ]	}d |› d �V  qdS )ú"NrI   rV   rI   rI   rJ   rY   È  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,   )ZcsrcÚh)r   Zreset_global_f2py_varsr8   r=   ÚdirnameÚabspathr   Ú__file__r@   rK   r   rG   r   Zload_f2cmap_filerR   rZ   r.   r3   ÚformatÚbasenamer1   Úargvr4   Ú	TypeErrorr5   Zdebugoptionsr	   r,   rd   r]   )Zcomline_listZf2pydirZfobjhsrcZfobjcsrcrC   rG   rP   r`   Úplistrb   rc   ÚmnrI   rI   rJ   Úrun_main›  sh   
€ÿþ€ÿÿÿ
ÿü

rx   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 rI   )Ústrip)rW   ÚxrI   rI   rJ   Ú
<listcomp>ì  s    z filter_files.<locals>.<listcomp>N)ÚreÚcompileÚmatchÚlenr.   )	ÚprefixÚsuffixrC   Úremove_prefixÚfilteredÚrestr~   ÚindÚfilerI   rI   rJ   Úfilter_filesâ  s   

r‡   c                 C   s   t j t j | j¡¡}|S re   )r8   r=   ro   rq   )r&   ÚprI   rI   rJ   Ú
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 r™d}n|dkrŸd}|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�s‹J 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 �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… }n"dd#lm} td$d%|ƒ\}}|| }|D ]}||ƒ}|�r0 �q2�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�r—t|ƒ||< �qrtd.|ƒ �qrdd/lm} i }|�r²| 	| d0g ¡¡ dd1lm }m!} ||||||||ˆd2œ	}ˆ
�rìdd3l"m#}  ˆ
D ]}!||!ƒ}|�sât$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=� |�rCt%j& '|¡�rEd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 rI   ©r~   ©rW   Ú_m)Ú_reg1rI   rJ   r{     ó    zrun_compile.<locals>.<listcomp>c                    ó   g | ]}|ˆ vr|‘qS rI   rI   r�   )Úsysinfo_flagsrI   rJ   r{     ó    c                 S   s   g | ]}|d d… ‘qS )é   NrI   )rW   rD   rI   rI   rJ   r{     r“   zN--((no-|)(wrap-functions|lower)|debug-capi|quiet|skip-empty-wrappers)|-includec                    r‹   rI   rŒ   r�   )Ú_reg2rI   rJ   r{     r�   c                    r‘   rI   rI   r�   )Ú
f2py_flagsrI   rJ   r{     r“   )r   r   r   r   c                    r‘   rI   rI   r�   )Úf2py_flags2rI   rJ   r{   &  r“   z4--((f(90)?compiler(-exec|)|compiler)=|help-compiler)c                    r‹   rI   rŒ   r�   )Ú_reg3rI   rJ   r{   )  r�   c                    r‘   rI   rI   r�   )Ú
flib_flagsrI   rJ   r{   *  r“   zH--((f(77|90)(flags|exec)|opt|arch)=|(debug|noopt|noarch|help-fcompiler))c                    r‹   rI   rŒ   r�   )Ú_reg4rI   rJ   r{   -  r�   c                    r‘   rI   rI   r�   )Úfc_flagsrI   rJ   r{   .  r“   z--fcompiler=)Ú	fcompilerzUnknown vendor: "%s"r   z--(verbose)c                    r‹   rI   rŒ   r�   )Ú_reg5rI   rJ   r{   I  r�   c                    r‘   rI   rI   r�   )Úsetup_flagsrI   rJ   r{   J  r“   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)	rN   Ú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
rI   )*Útempfiler1   rt   r\   Ú
ValueErrorÚmkdtempr|   r}   r.   r6   r   Znumpy.distutilsrœ   Zload_all_fcompiler_classesrh   Zfcompiler_classrZ   ÚlowerÚKeyErrorÚvaluesr/   r5   Z!numpy.distutils.command.build_srcrŸ   r‡   Úranger7   ÚtupleÚnumpy.distutils.system_infor¡   ÚgetZnumpy.distutils.corer£   r¤   Znumpy.distutils.misc_utilr]   r3   r8   r=   ÚexistsÚshutilÚrmtree)$r®   ÚiZremove_build_dirÚ	build_dirÚflÚaZdel_listrX   rj   rœ   Zallowed_keysÚnvÚovZvmaprF   r¥   ÚoptnamerŸ   Z	pyf_filesrD   rª   r¢   r¦   r§   r©   r¨   Ú
name_valuer¡   Znum_infor£   r¤   Zext_argsr]   ÚnÚextr¹   rI   )r�   r•   r˜   rš   r�   r–   r—   r›   r™   rž   r’   rJ   Ú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Š   )r1   rt   Úremover¶   rÇ   ÚstderrrO   r2   r.   rÅ   rx   rÆ   rI   rI   rJ   Úmain¥  s&   
rÊ   re   )"Ú__doc__r1   r8   Úpprintr|   Úpathlibr   r   r   r   r   r   r   r	   r
   r   Úversionr0   Znumpy_versionrÉ   rO   r4   Úshowr3   r<   rK   rR   rd   r]   rx   r‡   r‰   rÅ   rÊ   rI   rI   rI   rJ   Ú<module>   sR     �ü  �ûÿ  $#

G -