
     YHh?              	       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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jf                  ji                   e       d      dddddddf	dZ5dZ6dddejn                  dfdZ8de5_9         ejt                  d       jv                  Z<d! Z= ejt                  d"      Z>d# Z?d$ Z@ G d% d&      ZAy))    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                  j                  | t        | |            }t         j                  j	                  |      }|j
                  j                  |       |S )N)loader)	importlibutilspec_from_file_locationr   module_from_specr   exec_module)namepathspecmodules       L/var/www/html/planif/env/lib/python3.12/site-packages/Cython/Build/Inline.pyload_dynamicr"      sP    >>11$?RSWY]?^1_D^^,,T2FKKF#M    c                   .     e Zd Z fdZd Z fdZ xZS )UnboundSymbolsc                 L    t         t        |   d        t               | _        y )N)context)superr   __init__setunbound)self	__class__s    r!   r)   zUnboundSymbols.__init__$   s    lD*4*8ur#   c                     | j                         j                  |j                        s%| j                  j	                  |j                         |S N)current_envlookupr   r+   add)r,   nodes     r!   visit_NameNodezUnboundSymbols.visit_NameNode'   s8    !((3LLTYY'r#   c                 :    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                 <   |#t        g t               t        t                    }ddlm} t        d|       }t        j                  |d      D ]  }| ||      }t        ||      s 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"4_"EGK/6D))'59 =T{e9: !!$'#c(m*<<==r#   c                 B    t        |       }|t        u ryt        | |      S )Nlong)typeint	safe_type)argr'   py_types      r!   unsafe_typerQ   A   s"    3iG#~g&&r#   c                 b   t        |       }|t        t        t        t        fv r|j
                  S |t        u ry|t        u ry|t        u rydt        j                  v rNt        | t        j                  d   j                        r'd| j                  j                  d| j                  dS |j                   D ]v  }|j"                  dv r y	|j%                  |j"                  d
      }|s3|j'                  |j
                        }|j(                  s[|j"                  d|j
                  c S  y	)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    3iG4c**	G		E		D	CKK	JsCKK4H4P4P$Q7:yy~~sxxPP  	PI##'BB(()=)=(NFi&8&89==&/&:&:I<N<NOO	P r#   c                      t               } | j                         }| j                  |       t        |       }|j	                          |S r/   )r   find_config_filesparse_config_filesr   finalize_options)distconfig_filesbuild_extensions      r!   _get_build_extensionrr   a   sB    >D ))+LL)oO$$&r#   c                 Z    t        t        |       t               t        t                    S )Nr<   )r   r[   r
   r	   r   )cython_include_dirss    r!   _create_contextru   l   s&     ! "?3 r#   )rZ   c                 F   |D ]  }|| vs||Nt        j                         j                  j                  j                  }||j                  }||j                  }t        |t              st        |      }||v r	||   | |<   ||v r	||   | |<   t        d|z          y )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~ ' 4 4 6 = = D D K K>*33F?+55Gfd+ f%f~V7"&vV(612%3r#   c                     | |t         j                  t         j                  |t        j                  f}t        j                  t        |      j                  d            j                         S )Nzutf-8)
ra   version_info
executableCython__version__hashlibsha256r]   encode	hexdigest)	orig_codearg_sigslanguage_levelkeys       r!   _inline_keyr      sJ    
Xs//QWQcQc
cC>>#c(//'23==??r#   inlineFc
           
         |d }|rt        t        |            nt        }|rt        |      ni }|	d|vrd}	|	|	|d<   d }t        j                  |       }|t        |
|||       t        |
j                               }t        |D cg c]  \  }} |||      |f c}}      }t        | ||	      }t        j                  | ||f      }||D cg c]  }|d   	 }} || S | }t        |       \  } }t        |       } |2t        j                         j                  j                  j                  }|2t        j                         j                  j                  j                   }	 t#        |       xt        |<   }t        |
|||       g }t)        |
j                               D ]%  \  }}|t*        u s|j-                  d|z         |
|= ' t        |
      }t        |D cg c]  } ||
|   |      |f c}      }|t        |||	      }d|z   }|t.        j0                  v rt.        j0                  |   }nAd }t2        j4                  $t7               }|j9                  d      t2        _        t:        j<                  j?                  |      }t:        j<                  jA                  ||t2        j4                  z         }t:        j<                  jC                  |      st;        jD                  |       |s t:        j<                  jG                  |      sg }g }g }tI        jJ                  d	      } |D ]  \  }!}"| jM                  |!      }#|#s|j-                  d
|#jO                         d   z         |#jO                         d   dk(  sVdd l(}$|j-                  |$jS                                |j-                  d        tU        |       \  }%}&djA                  |D 'cg c]  }'d|'z  	 c}'      }(ddjA                  |      |%|(|&dz  })|j                         D ]  \  }*}|)jW                  |*|      }) t:        j<                  jA                  ||dz         }+tY        |+d      },	 |,j[                  |)       |,j]                          t_        ||+g|xs d |xs d |xs d       }-|
t7               }ta        |-g|xs dg||      |_1        t:        j<                  je                  |+      |_3        ||_4        |jk                          t.        jl                  dk(  r[t.        jn                  dk\  rHt;        jp                  t:        j<                  j?                  |            5  ts        ||      }d d d        nts        ||      }jt                  t        |||f<   |D cg c]  }|
|   	 }} |jt                  | S c c}}w c c}w # t$        $ r |st'        d       Y Jw xY wc c}w c c}'w # |,j]                          w xY w# 1 sw Y   xY wc c}w )Nc                      y)NrX    )xs    r!   <lambda>zcython_inline.<locals>.<lambda>   s    r#   r   3r   z>Could not parse code as a string (to extract unbound symbols).z
cimport cython as %s_cython_inline_ z([.\w]+)[.]z
cimport %sr   rU   )NPY_NO_DEPRECATED_APINPY_1_7_API_VERSIONz, z%s %szf
%(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)      );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   get_typelib_dirrt   cython_compiler_directivesforcer   r~   r   r   r}   ctxkey_hash_unbound_symbolsargsrO   valuer   invokearg_listr   literalsr   r   	arg_namesmodule_namer    rq   module_pathcflagsr   c_include_dirs	qualifiedrL   _mrU   r   r   ar   module_coder   pyx_filefh	extensions.                                                 r!   r   r      s   
 %9L/% 34
5RpCE_&@!Aeg"2:T"T!7E"#34H ,//5#$ 0&'Bdjjl#M*#u8E3/5MNtX~>%))48*DE*./3A/H/8$$I*40ND(t$D~%%'..55>>&&(//66@@T=LT=RRY'*:$ 0&'B H$**,' 	c-OO4t;<T
 tIK#xS	3/5KLHy(NC#h.Kckk![) '24O#2#C#CB#GM ''//'*ggll7K-:N:N,NOww~~g&KK {3FMN

>2I# _aOOD)OONQXXZ]$BCxxz!}/$&--e.?.?.AB%,,-]^_ &7t%<"KYYX>!>?F  $yy2"-# ),	,K 'nn. >
U)11#u=>ww||G[6-ABHh$B%
! !
+3t#)>T+3tI &"6"8)209SE$>	*O&
 *,)BO&)0O%!<<7"s'7'76'A%%bggoog&>? @%k;?@ @ "+{;F:@//Hh67%./cS	/H/6??H%%[ N 0  TRST LH  ?$ 
(@ @ 0sH   
V1
V7)"V< "WW!W# W8X<WW#W58X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}| j                         rt        |       nd} |rt        |      j                  nd}t
        j                  |j                  |d      j                         |j                  | d      j                               }t        |||      }	|	d	   |	d
   fdt                t              rdnd}
r|
dz  n|
dz  fd} |         |       }t        |      D cg c]
  } |       }}|dz  }|D cg c]  }r||z   |z  n||z   }}||fS c c}w c c}w )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                          |S # |rt        j                          w w xY wr/   )gc	isenableddisableenable)number	benchmarkgcoldtimingmake_benchmarkrepeat_benchmarktimers       r!   timeitzcymeit.<locals>.timeit\  sX    "$	


	%i?F		 		 s   
A A-i ʚ;g      ?   c                      d} 	 dD ]N  }| |z  } |      }t        |rt        nt              sJ |k\  r|c S s6|dk  s<|dk\  sBt        d        | dz  } Y)Nr   )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Q#F^
!*5NcTYZZZ,!M.JORT&)OPUw'WXXY GA r#   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  r   r   timingshalfr   r   r  r   r   r  s       `            @@@@@r!   cymeitr  1  sw   "  5?$Z0BJ(,

t$&D=Jz-099PT"))??:u5;;=tU399; * K #-I 56N !9:
 !+57C 8";J &?*/JQRNK K[F
 v 	vG 
 Q;D  &?$6!FVOSG 
 Vs   E&Ez\Sc                 $   d }| j                         }|D ]3  }t        |      }|s|j                         }||   dk(  r*|||kD  s2|}5 t        |      D ](  \  }}t        |      }|r|r||dz    dk(  r!||d  ||<   * dj	                  |      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J  e$ &D%DDq$9S$@%b		&
 99Ur#   zI^((cdef +(extern|class))|cimport|(from .+ cimport)|(from .+ import +[*]))c                 $   g }g }|}| j                  dd      } | j                  d      }|D ]>  }|j                  d      st        j	                  |      r|}n|}|j                  |       @ dj                  |      ddj                  |      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                 Z    | j                  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_bodyr1    sC    	c	BbqzXVBqDE]**bde}r#   c                       e Zd Zd Zd Zy)RuntimeCompiledFunctionc                 X    || _         t        t        j                  |            | _        y r/   )_fr1  rw   	getsource_body)r,   fs     r!   r)   z RuntimeCompiledFunction.__init__  s     g//23
r#   c                     t        j                  | j                  g|i |}t        | j                  f| j                  j
                  | j                  j
                  d|S )N)r~   r   )rw   getcallargsr5  r   r7  __globals__)r,   r   r}   alls       r!   r6   z RuntimeCompiledFunction.__call__  sP    !!$''9D9D9TZZh0C0CTWWM`M`hdghhr#   N)r7   r8   r9   r)   r6   r   r#   r!   r3  r3    s    4ir#   r3  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   r)  r   r1  r3  r   r#   r!   <module>rL     s^   	   	 	 
  2 1  #  = ; 6 K K '    3
\#3 
 > > '0    !0!8 3,@
 "-'',,';'=xH&*tU4VZC&R ( !TM^M^gh ]D  "**U#**( 2::jk ? i ir#   