
    -Ph?              	          d dl Z d dlZ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m	Z	 d dl
mZ d dlZddlmZ ddlmZmZmZ ddlmZmZ ddlmZ dd	lmZ d
dlmZmZm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 Z( G d dee          Z)ed'd            Z*d'dZ+d'dZ,d Z-ed             Z.i Z/ e.d          Z0d(dZ1d Z2e+ej3        4                     e            d          dddddddf	dZ5dZ6dddej7        dfdZ8de5_9         ej:        d           j;        Z<d! Z= ej:        d"          Z>d# Z?d$ Z@ G d% d&          ZAdS ))    N)Distribution	Extension)	build_ext   )Context)default_optionsCompilationOptionsget_directive_defaults)CythonTransformEnvTransform)SkipDeclarations)parse_from_strings   )strip_string_literals	cythonizecached_function)get_cython_cache_dir)Pipeline)ExtensionFileLoaderc                     t           j                            | t          | |                    }t           j                            |          }|j                            |           |S )N)loader)	importlibutilspec_from_file_locationr   module_from_specr   exec_module)namepathspecmodules       S/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/Cython/Build/Inline.pyload_dynamicr"      sY    >11$?RSWY]?^?^1__D^,,T22FKF###M    c                   .     e Zd Z fdZd Z fdZ xZS )UnboundSymbolsc                     t          t          |                               d            t                      | _        d S )N)context)superr   __init__setunbound)self	__class__s    r!   r)   zUnboundSymbols.__init__$   s3    lD!!**4*888uur#   c                     |                                                      |j                  s| j                            |j                   |S N)current_envlookupr   r+   add)r,   nodes     r!   visit_NameNodezUnboundSymbols.visit_NameNode'   sC    !!((33 	(LTY'''r#   c                 T    t                                          |           | j        S r/   )r(   __call__r+   )r,   r3   r-   s     r!   r6   zUnboundSymbols.__call__+   s#    |r#   )__name__
__module____qualname__r)   r4   r6   __classcell__)r-   s   @r!   r%   r%   #   s`                      r#   r%   c                    |0t          g t                      t          t                              }ddlm} t          d|           }t          j        |d          D ]"}| ||          }t          ||          r n#dd l
}t           t                      |          t          t          |                    z
            S )Noptionsr   )AnalyseDeclarationsTransformz(tree fragment)pyxr   )r   r
   r	   r   Compiler.ParseTreeTransformsr>   r   r   create_pipeline
isinstancebuiltinstupler%   r*   dir)coder'   r>   treephaserC   s         r!   unbound_symbolsrI   0   s    "466"4_"E"EG G GKKKKKK/66D)'599  =uT{{e9:: 	E	OOO!!!$''#c(mm*<*<<===r#   c                 V    t          |           }|t          u rdS t          | |          S )Nlong)typeint	safe_type)argr'   py_types      r!   unsafe_typerQ   A   s+    3iiG#~~vg&&&r#   c                    t          |           }|t          t          t          t          fv r|j        S |t          u rdS |t          u rdS |t          u rdS dt          j
        v r=t          | t          j
        d         j                  rd| j        j        d| j        dS |j        D ]`}|j        dv r d	S |                    |j        d
          }|r4|                    |j                  }|j        r|j        d|j        c S ad	S )Nzdouble complexdoublebintnumpyznumpy.ndarray[numpy.z	_t, ndim=])__builtin__rC   objectF)need_pxd.)rL   listrD   dictstrr7   complexfloatboolsysmodulesrB   ndarraydtyper   ndim__mro__r8   find_moduler1   is_type)rO   r'   rP   	base_typer    entrys         r!   rN   rN   I   s-   3iiG4c***	G			E		x	Dv	CK		JsCK4H4P$Q$Q		7:y~~~sxxxPP  	P 	PI#'BBBxx(()=(NNF Pi&899= P&/&:&:&:I<N<NOOOOxr#   c                      t                      } |                                 }|                     |           t          |           }|                                 |S r/   )r   find_config_filesparse_config_filesr   finalize_options)distconfig_filesbuild_extensions      r!   _get_build_extensionrr   a   sU    >>D ))++LL)))ooO$$&&&r#   c                 |    t          t          |           t                      t          t                              S )Nr<   )r   r[   r
   r	   r   )cython_include_dirss    r!   _create_contextru   l   s9     !!  "?33   r#   )rZ   c                 4   |D ]}|| vr||4t          j                    j        j        j        }||j        }||j        }t          |t                    st          |          }||v r||         | |<   r||v r||         | |<   t          d|z             d S )NzCouldn't find %r)inspectcurrentframef_backf_locals	f_globalsrB   r\   print)kwdsrI   localsglobalssymbolcalling_frames         r!   _populate_unboundr   y   s    ! 3 3~ ' 4 6 6 = D K>*3F?+5Gfd++ & f%f~V7""&vV(61222%3 3r#   c                     | |t           j        t           j        |t          j        f}t          j        t          |                              d                    	                                S )Nzutf-8)
ra   version_info
executableCython__version__hashlibsha256r]   encode	hexdigest)	orig_codearg_sigslanguage_levelkeys       r!   _inline_keyr      sK    
Xs/QWQc
cC>#c((//'2233==???r#   inlineFc
                 x  
, d |rt          t          |                    nt          ,|rt          |          ni }|	d|vrd}	|	|	|d<   d }t                              |           }|t          
|||           t          
                                          }t          ,fd|D                       }t          | ||	          }t                              | ||f          }|d |D             } || S | }t          |           \  } }t          |           } |"t          j                    j        j        j        }|"t          j                    j        j        j        }	 t#          |           xt          |<   }t          
|||           n!# t$          $ r |st'          d           Y nw xY wg }t)          
                                          D ])\  }}|t*          u r|                    d|z             
|= *t          
          }t          ,
fd|D                       }|t          |||	          }d	|z   }|t.          j        v rt.          j        |         }nd }t2          j        -t7                      }|                    d
          t2          _        t:          j                            |          }t:          j                             ||t2          j        z             }t:          j        !                    |          st;          j"        |           |s t:          j        #                    |          sBg }g }g }tI          j%        d          }|D ]\  }} |&                    |          }!|!r|                    d|!'                                d         z             |!'                                d         dk    r@dd l(}"|                    |")                                           |                    d           tU          |           \  }#}$d                     d |D                       }%dd                     |          |#|%|$dz  }&|                                D ]\  }'}(|&+                    |'|(          }&t:          j                             ||dz             })tY          |)d          }*	 |*-                    |&           |*.                                 n# |*.                                 w xY wt_          ||)g|pd |pd |pd           }+|t7                      }ta          |+g|pdg||          |_1        t:          j        2                    |)          |_3        ||_4        |5                                 t.          j6        dk    rjt.          j7        dk    rZt;          j8        t:          j                            |                    5  ts          ||          }d d d            n# 1 swxY w Y   nts          ||          }|j:        t          |||f<   
fd|D             } |j:        | S )Nc                     dS )NrX    )xs    r!   <lambda>zcython_inline.<locals>.<lambda>   s    X r#   r   3c                 2    g | ]\  }} |          |fS r   r   ).0rO   valuectxget_types      r!   
<listcomp>z!cython_inline.<locals>.<listcomp>   s.    MMM*#u88E3//5MMMr#   c                     g | ]
}|d          S )r   r   )r   rO   s     r!   r   z!cython_inline.<locals>.<listcomp>   s    ///3A///r#   z>Could not parse code as a string (to extract unbound symbols).z
cimport cython as %sc                 8    g | ]} |                   |fS r   r   )r   rO   r   r   r}   s     r!   r   z!cython_inline.<locals>.<listcomp>   s.    KKK#xxS	3//5KKKr#   _cython_inline_ z([.\w]+)[.]z
cimport %sr   rU   )NPY_NO_DEPRECATED_APINPY_1_7_API_VERSIONz, c                     g | ]}d |z  S )z%s %sr   )r   as     r!   r   z!cython_inline.<locals>.<listcomp>   s    >>>!>>>r#   zf
%(module_body)s
%(cimports)s
def __invoke(%(params)s):
%(func_body)s
    return locals()
            
)cimportsmodule_bodyparams	func_bodyz.pyxw)r   sourcesinclude_dirsextra_compile_argsdefine_macrosrZ   )include_pathcompiler_directivesquietwin32)      c                      g | ]
}|         S r   r   )r   rO   r}   s     r!   r   z!cython_inline.<locals>.<listcomp>  s    ///cS	///r#   );ru   rD   _cython_inline_default_contextr\   _cython_inline_cachegetr   sorteditemsr   r   strip_common_indentrw   rx   ry   rz   r{   rI   AssertionErrorr|   r[   cython_moduleappendra   rb   cython_inlineso_extrr   get_ext_filenameosr   abspathjoinexistsmakedirsisfilerecompilematchgroupsrU   get_includeextract_func_codereplaceopenwritecloser   r   
extensionsdirname
build_temp	build_librunplatformr   add_dll_directoryr"   __invoke)-rF   r   lib_dirrt   cython_compiler_directivesforcer   r~   r   r   r}   key_hash_unbound_symbolsargsr   invokearg_listr   literalsr   r   rO   	arg_namesmodule_namer    rq   module_pathcflagsr   c_include_dirs	qualifiedrL   _mrU   r   r   r   module_coder   r   pyx_filefh	extensionr   s-    `        `                                 @r!   r   r      s   
 %%9L
p/% 344
5
5
5RpCE_!g&@!A!A!Aeg"2:T"T"T!7E"#34H ,//55#$ 0&'BBBdjjll##MMMMMMMMNNtX~>>%))48*DEE//$///H68$$I*400ND(t$$D~%''.5>&((/6@T=LT=R=RRY'*:$ 0&'BBBB T T T 	TRSSST
 H$**,,''  	c-OO4t;<<<T
tIKKKKKKKKKLLHy(NCC#h.Kck!![) '244O#2#C#CB#G#GM '//'**gll7K-:N,NOOw~~g&& 	!K    3	"{33 3	"FMN
>22I# _ _aOOD)) _OONQXXZZ]$BCCCxxzz!}//$&--e.?.?.A.ABBB%,,-]^^^%6t%<%<"KYY>>X>>>??F  $yy22"-# ), ,	,K 'nn.. > >
U)11#u==w||G[6-ABBHh$$B%%%







! !
+3t#)>T+3t  I &"6"8"8)209SE$>	* * *O&
 *,)B)BO&)0O%!!!<7""s'76'A'A%bgoog&>&>?? @ @%k;??@ @ @ @ @ @ @ @ @ @ @ @ @ @ @ "+{;;F:@/Hh67////Y///H6?H%%s0   *+F F43F4?S) )S?W66W:=W:a=  
def __PYX_repeat_benchmark(benchmark, timer, size_t number):
    cdef size_t i

    t0 = timer()
    for i in range(number):
        benchmark()
    t1 = timer()
    return t1 - t0

def __PYX_make_benchmark():
    {setup_code}

    def __PYX_run_benchmark():
        {benchmark_code}

    return __PYX_run_benchmark
	   c                    ddl }|rt          |          nd}|                                 rt          |           nd} |rt          |          j        nd}t
                              |                    |d                                          |                    | d                                                    }t          |||          }	|	d	         |	d
         fdt                       t                    rdnd}
r|
dz  n|
dz  fd} |              |            fdt          |          D             }dz  fd|D             }|fS )a  Benchmark a Cython code string similar to 'timeit'.

    'setup_code': string of setup code that will be run before taking the timings.

    'import_module': a module namespace to run the benchmark in
                     (usually a compiled Cython module).

    'directives': Cython directives to use when compiling the benchmark code.

    'timer': The timer function. Defaults to 'time.perf_counter', returning float seconds.
             Nanosecond timers are detected (and can only be used) if they return integers.

    'repeat': The number of timings to take and return.

    Returns a tuple: (list of single-loop timings, number of loops run for each)
    r   Nr   pass    z        )
setup_codebenchmark_code)r   r~   __PYX_make_benchmark__PYX_repeat_benchmarkc                                  }t          j                    }t          j                     	  ||           }|rt          j                     n# |rt          j                     w w xY w|S r/   )gc	isenableddisableenable)number	benchmarkgcoldtimingmake_benchmarkrepeat_benchmarktimers       r!   timeitzcymeit.<locals>.timeit\  sx    "N$$	

	%%i??F 	  	s   A A.i ʚ;g      ?   c                      d} 	 dD ]\}| |z  } |          }t          |rt          nt                    sJ |k    r|c S r|dk     r|dk    rt          d           ]| dz  } e)Nr   T)r   r   r  
   z&Timer seems to return non-ns timings: )rB   rM   r_   RuntimeError)ijr   
time_takenmin_runtimer  r  timer_returns_nanosecondss       r!   	autorangezcymeit.<locals>.autorangep  s    
	 Y YQ#VF^^
!*5N.YccTYZZZZZ,,!MMM. YJOORT&'WPU'W'WXXXGA
	r#   c                 &    g | ]}           S r   r   )r   r   r   r  s     r!   r   zcymeit.<locals>.<listcomp>  s1        	v  r#   r   c                 .    g | ]}r|z   z  n|z  S r   r   )r   r   halfr   r  s     r!   r   zcymeit.<locals>.<listcomp>  s@        &?S$6!!FVO  r#   )textwrapr   strip
__import____dict___CYMEIT_TEMPLATEformatindentr   rB   rM   range)rF   r   import_module
directivesr  repeatr  module_namespacecymeit_code	namespace
one_secondr  timingsr  r  r  r   r  r  r  s       `        @@@@@@@r!   cymeitr"  1  s   " OOO 5?F$Z000BJ(,

@t$$$&D=JTz-0099PT"))??:u55;;==tU3399;; *  K #-  I 56N !9:
 
 
 
 
 
 
 !+5577C 8 8";DJ &?R*//JQRNK        IKKKY[[F    v  G
 Q;D       G
 Vr#   z\Sc                 j   d }|                                  }|D ]?}t          |          }|s|                                }||         dk    r5|||k    r|}@t          |          D ]7\  }}t          |          }|r|r|||dz            dk    r*||d          ||<   8d                    |          S )N#r   r   )
splitlines_find_non_spacestart	enumerater   )rF   
min_indentlinesliner   r  ixs          r!   r   r     s    JOOE    %% 	<3f!4!4Je$$ & &D%% 	D 	Dq$9S$@$@%b		99Ur#   zI^((cdef +(extern|class))|cimport|(from .+ cimport)|(from .+ import +[*]))c                 Z   g }g }|}|                      dd          } |                     d          }|D ]K}|                    d          st                              |          r|}n|}|                    |           Ld                    |          dd                    |          z   fS )N	 r   r   z
    )r   split
startswithmodule_statementr   r   r   )rF   r    functioncurrentr*  r+  s         r!   r   r     s    FHG<<c""DJJtE  s## 	#%%d++ # "t99Vfx}}X'>'>>>>r#   c                     |                      d          }| d d         dk    rd| |dz   d          z  S | |dz   d          S )N:r  lambdaz	return %sr   )index)sourcer,  s     r!   get_bodyr:    sO    	c		BbqbzXVBqDEE]**bdee}r#   c                       e Zd Zd Zd ZdS )RuntimeCompiledFunctionc                 `    || _         t          t          j        |                    | _        d S r/   )_fr:  rw   	getsource_body)r,   fs     r!   r)   z RuntimeCompiledFunction.__init__  s'    g/2233


r#   c                     t          j        | j        g|R i |}t          | j        f| j        j        | j        j        d|S )N)r~   r   )rw   getcallargsr>  r   r@  __globals__)r,   r   r}   alls       r!   r6   z RuntimeCompiledFunction.__call__  sN    !$'9D999D99TZh0CTWM`hhdghhhr#   N)r7   r8   r9   r)   r6   r   r#   r!   r<  r<    s7        4 4 4i i i i ir#   r<  r/   )NN)Br   r   rw   r   r   ra   timedistutils.corer   r   distutils.command.build_extr   r   Compiler.Mainr   Compiler.Optionsr   r	   r
   Compiler.Visitorr   r   r@   r   Compiler.TreeFragmentr   Dependenciesr   r   r   Cacher   Compilerr   cythonr   importlib.utilr   importlib.machineryr   r"   r%   rI   rQ   rN   rr   ru   r   r   r   r   r   r   r   r  perf_counterr"  r   r   searchr&  r   r2  r   r:  r<  r   r#   r!   <module>rU     sk   				   				 				 



  2 2 2 2 2 2 2 2 1 1 1 1 1 1  # # # # # #          = < < < < < < < ; ; ; ; ; ; 6 6 6 6 6 6 K K K K K K K K K K ' ' ' ' ' '               3 3 3 3 3 3  
 
 
 
 
\#3 
 
 
 > > > > ' ' ' '   0       !0!8!8 3 3 3 3,@ @ @
 "-',,';';'='=xHH&*tU4VZC& C& C& C&R ( !TM^gh ] ] ] ]D  "*U##*  ( 2:jkk ? ? ?   i i i i i i i i i ir#   