
    #	h+                     8   S SK r S SKrS SKrS SKrS SKrSSKJr  SSKJr  SSKJ	r	  \ R                  S:  a  S SKrS rOS SKrS r\ R                  S	:  a  \R                  rO " S
 S\R"                  5      r " S S\5      rSrS rSqS rS rSS jrS rS rg)    N   )__version_verifier_modules__)ffiplatform)VerificationError)   r   c                  <    [         R                  R                  S S  $ N)	importlib	machineryEXTENSION_SUFFIXES     ?/var/www/html/env/lib/python3.13/site-packages/cffi/verifier.py_extension_suffixesr      s    ""55a88r   c                      [         R                  " 5        V VVs/ s H  u  pnU[         R                  :X  d  M  U PM      snnn $ s  snnn f r	   )impget_suffixesC_EXTENSION)suffix_types      r   r   r      s@    .1.>.>.@ ,.@?6d3??* .@ , 	, ,s
   AAr   c                   (   ^  \ rS rSrU 4S jrSrU =r$ )NativeIO   c                 x   > [        U[        5      (       a  UR                  S5      n[        [        U ]  U5        g )Nascii)
isinstanceunicodeencodesuperr   write)selfs	__class__s     r   r"   NativeIO.write   s-    !W%%HHW%(D'*r   r   )__name__
__module____qualname____firstlineno__r"   __static_attributes____classcell__)r%   s   @r   r   r      s    	+ 	+r   r   c                   t    \ rS rSr   SS jrSS jrS rS rS rS r	S	 r
S
 rS rS rSS jrS rS rSrg)Verifier   Nc                    UR                   R                  (       a#  [        SUR                   R                  < 35      eXl        X l        U(       d  [
        R                  " U5      n[        X5      nU" U 5      U l        U R                  R                  U5        Xl
        U R                  X5      U l        U(       a  U(       a  [        S5      eGOSR                  S[        R                   S S -  ["        UW/UR$                  -   5      n[        R                   S:  a  UR'                  S5      n[)        [*        R,                  " USS S2   5      S	-  5      nUR/                  S
5      R1                  S5      n[)        [*        R,                  " USS S2   5      S	-  5      nUR/                  S5      R1                  S5      nSU< SU R                  R2                  < U< U< 3n[5        5       S   nU=(       d
    [7        5       U l        [:        R<                  R                  U R8                  XH-   5      U l        [:        R<                  R                  U R8                  UU-   5      U l         XPl!        SU l"        SU l#        g )NzIfeature not supported with ffi.verify(), but only with ffi.set_source(): z)can't specify both 'modulename' and 'tag' z%d.%d   r   zutf-8r   l    0xLr   0_cffi_r   F)$_parser_uses_new_featurer   ffipreambler   flatten_locate_engine_class_venginepatch_extension_kwdsflagsmake_relative_tokwds	TypeErrorjoinsysversion_infor   _cdefsourcesr    hexbinasciicrc32lstriprstrip
_class_key_get_so_suffixes_caller_dir_pycachetmpdirospathsourcefilenamemodulefilenameext_package_has_source_has_module)r#   r9   r:   rO   
modulenamerT   tagforce_generic_enginesource_extensionr?   relative_torA   flattened_kwdsvengine_classkeyk1k2r   s                     r   __init__Verifier.__init__    s    ;;((#/2{{/L/LOP P  (006N,SG%d+**40
))$<	 KLL  ++w)9)9"1)==;'9 "../ 0C 4'jj)X^^C1I.;<B4'',BX^^C1I.;<B3&&s+B.14==3K3K.0"6J!#A&5 3 5 ggll4;;
8UV ggll4;;
V8KL&  r   c                     U R                   R                     U R                  (       a  Uc  [        S5      eU R	                  U5        SSS5        g! , (       d  f       g= f)zcWrite the C source code.  It is produced in 'self.sourcefilename',
which can be tweaked beforehand.Nzsource code already written)r9   _lockrU   r   _write_sourcer#   files     r   write_sourceVerifier.write_sourceI   sD     XX^^DL'13 3t$	 ^^s   1A
Ac                     U R                   R                     U R                  (       a  [        S5      eU R                  (       d  U R                  5         U R                  5         SSS5        g! , (       d  f       g= f)z|Write the C source code (if not done already) and compile it.
This produces a dynamic link library in 'self.modulefilename'.zmodule already compiledN)r9   rd   rV   r   rU   re   _compile_moduler#   s    r   compile_moduleVerifier.compile_moduleR   sO     XX^^'(ABB##""$  " ^^s   AA..
A<c                 J   U R                   R                     U R                  (       dR  U R                  5         U R                  (       d1  U R                  (       d  U R                  5         U R                  5         U R                  5       sSSS5        $ ! , (       d  f       g= f)zGet a C module from this Verifier instance.
Returns an instance of a FFILibrary class that behaves like the
objects returned by ffi.dlopen(), but that delegates all
operations to the C module.  If necessary, the C code is written
and compiled first.
N)r9   rd   rV   _locate_modulerU   re   rk   _load_libraryrl   s    r   load_libraryVerifier.load_library\   sd     XX^^####%''++**,((*%%' ^^s   A3B
B"c                     [         R                  R                  U R                  5      nUR	                  SS5      S   nUR                  S5      (       a  [        [        S5      (       a  US S nU$ )N.r   r   _dgettotalrefcount)rP   rQ   basenamerS   splitendswithhasattrrD   )r#   ry   s     r   get_module_nameVerifier.get_module_namel   sc    77##D$7$78 >>#q)!, T""ws4F'G'G}Hr   c                 h   U R                   (       d@  U R                  R                     U R                   (       d  U R                  5         S S S 5        [        R
                  " U R                  5      nU R                  5       n[        R                  " X40 U R                  D6$ ! , (       d  f       N_= fr	   )
rU   r9   rd   re   r   maybe_relative_pathrR   r}   get_extensionrA   )r#   
sourcenamemodnames      r   r   Verifier.get_extensionw   sx    ''&&(   !44T5H5HI
&&(((J		JJ  s   "B##
B1c                 .    U R                   R                  $ r	   )r=   _gen_python_modulerl   s    r   generates_python_module Verifier.generates_python_module   s    }}///r   c                    U(       a  [         R                  R                  U5      (       a  [         R                  R                  U5      nUR                  5       n[        R
                   Hl  nXA;   d  M
  X   n[        U[        [        45      (       d  [        SU< S35      eU Vs/ s H"  n[         R                  R                  X65      PM$     nnXQU'   Mn     U$ s  snf )Nz	keyword 'z' should be a list or tuple)rP   rQ   dirnamecopyr   LIST_OF_FILE_NAMESr   listtuplerB   rC   )r#   rA   r[   r   r^   lstfns          r   r@   Verifier.make_relative_to   s    277??;77ggook2G99;D"55;)C%cD%=99'+.)1 2 2?BCs277<<4sCC #I 6  Ds   ()Cc                    [         R                  R                  U R                  5      (       dw  U R                  (       a'   [        U R                  S S S/5      nUR                  nOS nU R                  R                  U R                  5       U[        5       5      nUc  g X0l        U R                  R                  5         SU l        g ! [         a     g f = f)N__doc__T)rP   rQ   isfilerS   rT   
__import__ImportError__path__r=   find_moduler}   rM   collect_typesrV   )r#   pkgrQ   filenames       r   rp   Verifier._locate_module   s    ww~~d1122$T%5%5tTI;OC ||}}001E1E1G1A1CEH"*##% # s   C 
CCc                     XR                   l         U R                   R                  5         U R                   ?g ! U R                   ?f = fr	   )r=   _fwrite_source_to_frf   s     r   _write_source_toVerifier._write_source_to   s6    	!MM++-  s	   9 Ac                 6   Ub  U R                  U5        g [        5       nU R                  U5        UR                  5       n[        R                  R                  U R                  5      (       a4  [        U R                  S5       nUR                  5       U:X  + nS S S 5        OSnW(       aE  [        U R                  5        [        U R                  S5       nUR                  U5        S S S 5        SU l        g ! , (       d  f       Nb= f! , (       d  f       N'= f)NrTw)r   r   getvaluerP   rQ   existsrR   openread_ensure_dirr"   rU   )r#   rg   fsource_datafpneeds_writtens         r   re   Verifier._write_source   s    !!$' 
A!!!$**,K ww~~d1122$--s3r)+k$BM 43 !% D//0$--s3rHH[) 4  $D 43 43s   C9D
9
D

Dc                    [         R                  R                  U R                  5      n[        R
                  " XR                  5       5      n [        R                  " X R                  5      nU(       d5  [        U R                  5        [        R                  " X R                  5        SU l        g ! [         a    Sn NRf = f)NFT)rP   rQ   r   rR   r   compiler   samefilerS   OSErrorr   shutilmoverV   )r#   rO   outputfilenamesames       r   rk   Verifier._compile_module   s    !4!45$,,V5G5G5IJ	''8K8KLD ++,KK(;(;<  	D	s    B3 3CCc                     U R                   (       d   eU R                  b%  U R                  R                  U R                  5      $ U R                  R                  5       $ r	   )rV   r?   r=   rr   rl   s    r   rq   Verifier._load_library   sG    ::!==--djj99==--//r   )rV   rU   r=   rT   r9   r?   rA   rS   r:   rR   rO   )NNN F.cNNr	   )r'   r(   r)   r*   ra   rh   rm   rr   r}   r   r   r@   rp   r   re   rk   rq   r+   r   r   r   r.   r.      sN    >B@E@D'!R%#( 	K0  &!$2 0r   r.   Fc                     [         (       a  SnU(       d-  S[        R                  ;   a  SnO SS KnU R
                  ULa  SnU(       a  SSKJn  UR                  $ SSKJ	n  UR                  $ ! [         a    Sn NJf = f)NT__pypy__r   ?r   )vengine_gen)vengine_cpy)_FORCE_GENERIC_ENGINErD   builtin_module_names_cffi_backendr   _backendr   r   VGenericEnginer   VCPythonEngine)r9   rY   r   r   r   s        r   r<   r<      sx    #111#' $$ ||=0'+$!)))!)))  $ #$s   A- -A<;A<c                  |   [         (       a  [         $ [        R                  R                  S5      n U (       a  U $ [        R
                  " S5      R                  R                  n[        R                  R                  [        R                  R                  [        R                  R                  U5      S5      5      $ )NCFFI_TMPDIRr2   __pycache__)_TMPDIRrP   environgetrD   	_getframef_codeco_filenamerQ   abspathrC   r   )resultr   s     r   rN   rN      sv    wZZ^^M*F}}Q&&22H77??277<<(A(* + +r   c                     U q g)z:Set the temporary directory to use instead of __pycache__.N)r   )r   s    r   
set_tmpdirr      s	     Gr   c                    U =(       d
    [        5       n  [        R                  " U 5      nU(       a  SnO[	        5       S   R                  5       nU H  nUR                  5       R                  S5      (       d  M)  UR                  5       R                  U5      (       d&  UR                  5       R                  S5      (       d  Ms   [        R                  " [        R                  R                  X5      5        M     [        R                  R                  U S5      /nU H  n [        R                  " U5       Ho  n[        R                  R                  Xd5      n[        R                  R                  U5      (       a  UR                  U5        MY  [        R                  " U5        Mq     M     g! [         a     gf = f! [         a     GM~  f = f! [         a     M  f = f)zyClean up the temporary directory by removing all files in it
called `_cffi_*.{c,so}` as well as the `build` subdirectory.Nr   r   r6   build)rN   rP   listdirr   rM   lower
startswithr{   unlinkrQ   rC   isdirappend)rO   keep_sofilelistr   r   	clean_dirdirs          r   cleanup_tmpdirr     sc    ,*,F::f% !#A&,,.88:  **
##F++rxxz/B/B4/H/H		"'',,v23	  fg./I	jjoWW\\#*77==$$$$R(IIbM &       		s6   F2 3G$B	G2
F?>F?
GG
G"!G"c                  `    [        5       n U (       d  [        R                  S:X  a  S/n U $ S/n U $ )Nwin32z.pydz.so)r   rD   platform)suffixess    r   rM   rM   $  s5    "$H<<7"xH O wHOr   c                     [         R                  R                  U 5      nU(       a<  [         R                  R                  U5      (       d  [         R                  " U5        g g g r	   )rP   rQ   r   r   makedirs)r   r   s     r   r   r   /  s<    ggooh'Grww}}W--
G .wr   )NF)rD   rP   rH   r   ior   r   r   errorr   rE   importlib.machineryr
   r   r   StringIOr   BytesIOobjectr.   r   r<   r   rN   r   r   rM   r   r   r   r   <module>r      s    % $ $ *  $v9 ,
 t{{H+2:: +z0v z0|  *, +
>	r   