
    /h8                     H   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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 ej                            d          rd dlmc mc mc mZ nej        e j                 Z	 eZn# e$ r dZY nw xY weZg dZd dZej        d d            Z ej        d             Z!ej        d	             Z"ej        d
             Z# G d de$          Z% G d d          Z&ej        d             Z'd Z(ej        d             Z)ej        d             Z*h dZ+d Z,d Z-d Z. G d d          Z/ e0e d          r	e j1        gZ2ng Z2 G d de/          Z3 ej4        ej5        d d6                                D                       Z7 G d de          Z8dS )!    N)DistutilsError)working_setjava)AbstractSandboxDirectorySandboxSandboxViolation	run_setupc                     d}t          | |          5 }|                                }ddd           n# 1 swxY w Y   ||}t          || d          }t          |||           dS )z.
    Python 3 implementation of execfile.
    rbNexec)openreadcompiler   )filenameglobalslocalsmodestreamscriptcodes          E/var/www/html/venv/lib/python3.11/site-packages/setuptools/sandbox.py	_execfiler   $   s     D	h		               ~68V,,Dws   488c              #      K   t           j        d d          }| | t           j        d d <   	 |V  |t           j        d d <   d S # |t           j        d d <   w xY wN)sysargv)replsaveds     r   	save_argvr   1   sf      HQQQKEes   A Ac               #      K   t           j        d d          } 	 | V  | t           j        d d <   d S # | t           j        d d <   w xY wr   )r   pathr   s    r   	save_pathr#   <   sQ      HQQQKEes	   / Ac              #      K   t          j        | d           t          j        }| t          _        	 dV  |t          _        dS # |t          _        w xY w)zL
    Monkey-patch tempfile.tempdir with replacement, ensuring it exists
    T)exist_okN)osmakedirstempfiletempdir)replacementr   s     r   override_tempr+   E   s]      
 Kd++++E"H! 5    s   A Ac              #      K   t          j                    }t          j        |            	 |V  t          j        |           d S # t          j        |           w xY wr   )r&   getcwdchdir)targetr   s     r   pushdr0   V   sR      IKKEHV
s   A Ac                   (    e Zd ZdZed             ZdS )UnpickleableExceptionzP
    An exception representing another Exception that could not be pickled.
    c           	          	 t          j        |           t          j        |          fS # t          $ r5 ddlm} |                    | |t          |                              cY S w xY w)z
        Always return a dumped (pickled) type and exc. If exc can't be pickled,
        wrap it in UnpickleableException first.
        r   )r2   )pickledumps	Exceptionsetuptools.sandboxr2   dumprepr)typeexcclss      r   r8   zUnpickleableException.dumpe   s{    	1<%%v|C'8'888 	1 	1 	1GGGGGG88CT#YY00000		1s   '* <A)(A)N)__name__
__module____qualname____doc__staticmethodr8        r   r2   r2   `   s9          1 1 \1 1 1rC   r2   c                   $    e Zd ZdZd Zd Zd ZdS )ExceptionSaverz^
    A Context Manager that will save an exception, serialized, and restore it
    later.
    c                     | S r   rB   selfs    r   	__enter__zExceptionSaver.__enter__z   s    rC   c                 \    |sd S t                               ||          | _        || _        dS NT)r2   r8   _saved_tb)rH   r:   r;   tbs       r   __exit__zExceptionSaver.__exit__}   s6     	F ,00s;; trC   c                     dt          |           vrdS t          t          j        | j                  \  }}|                    | j                  )z"restore and re-raise any exceptionrL   N)varsmapr4   loadsrL   with_tracebackrM   )rH   r:   r;   s      r   resumezExceptionSaver.resume   sG     4::%%Fdk22	c  ***rC   N)r=   r>   r?   r@   rI   rO   rU   rB   rC   r   rE   rE   t   sK         
  	 	 	+ + + + +rC   rE   c               #   P  K   t           j                                        t                      5 } V  ddd           n# 1 swxY w Y   t           j                                       fdt           j        D             }t          |           |                                  dS )z
    Context in which imported modules are saved.

    Translates exceptions internal to the context into the equivalent exception
    outside the context.
    Nc              3   N   K   | ]}|v|                     d           |V   dS )z
encodings.N
startswith).0mod_namer   s     r   	<genexpr>zsave_modules.<locals>.<genexpr>   sP        5  ##L11 ! 	     rC   )r   modulescopyrE   update_clear_modulesrU   )	saved_excdel_modulesr   s     @r   save_modulesrc      s       KE			 Y               Ku     K ;s   AAAc                 D    t          |           D ]}t          j        |= d S r   )listr   r]   )module_namesr[   s     r   r`   r`      s0    && " "K!!" "rC   c               #      K   t          j                    } 	 | V  t          j        |            d S # t          j        |            w xY wr   )pkg_resources__getstate____setstate__r"   s    r   save_pkg_resources_staterk      sP      &((E*"5)))))"5))))s	   1 Ac              #   Z  K   t           j                            | d          }t                      5  t	                      5  t                      5  t                       t                      5  t          |          5  t          |           5  t          d           d V  d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            n# 1 swxY w Y   d d d            d S # 1 swxY w Y   d S )Ntemp
setuptools)r&   r!   joinrk   rc   r#   hide_setuptoolsr   r+   r0   
__import__)	setup_dirtemp_dirs     r   setup_contextrt      s     w||Iv..H	!	#	# 	" 	"^^ 	" 	" " "!!![[ " "&x00 " ""9-- " "&|444!EEE" " " " " " " " " " " " " " "" " " " " " " " " " " " " " "" " " " " " " " " " " " " " "" " " " " " " " " " " " " " "	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	" 	"s   D  DC1,C	<CB, C,B00C3B04C7C	CC	
CC	C1CC1!C"C1%D1C55D8C59D<D D	D D	D  D$'D$>   Cython	distutilsrn   rh   _distutils_hackc                 L    |                      dd          d         }|t          v S )aH  
    >>> _needs_hiding('setuptools')
    True
    >>> _needs_hiding('pkg_resources')
    True
    >>> _needs_hiding('setuptools_plugin')
    False
    >>> _needs_hiding('setuptools.__init__')
    True
    >>> _needs_hiding('distutils')
    True
    >>> _needs_hiding('os')
    False
    >>> _needs_hiding('Cython')
    True
    .   r   )split_MODULES_TO_HIDE)r[   base_modules     r   _needs_hidingr~      s(    " ..a((+K***rC   c                      t           j                            dd          } | |                                  t	          t
          t           j                  }t          |           dS )a%  
    Remove references to setuptools' modules from sys.modules to allow the
    invocation to import the most appropriate setuptools. This technique is
    necessary to avoid issues such as #315 where setuptools upgrading itself
    would fail to find a function declared in the metadata.
    rw   N)r   r]   getremove_shimfilterr~   r`   )rw   r]   s     r   rp   rp      sW     koo&7>>O"##%%%]CK00G7rC   c                    t           j                            t           j                            |                     }t	          |          5  	 | gt          |          z   t          j        dd<   t          j                            d|           t          j
                     t          j                            d            t          |          5  t          | d          }t          | |           ddd           n# 1 swxY w Y   n,# t           $ r}|j        r|j        d         r Y d}~nd}~ww xY wddd           dS # 1 swxY w Y   dS )z8Run a distutils setup script, sandboxed in its directoryNr   c                 *    |                                  S r   )activate)dists    r   <lambda>zrun_setup.<locals>.<lambda>   s    dmmoo rC   __main__)__file__r=   )r&   r!   abspathdirnamert   re   r   r   insertr   __init__	callbacksappendr   dictr   
SystemExitargs)setup_scriptr   rr   nsvs        r   r	   r	      s    = =>>I	y	!	!  	'.4::5CHQQQKHOOAy))) """!(()E)EFFF!),, , ,<*EEE,+++, , , , , , , , , , , , , , ,  	 	 	v !&) 	                 sa   EBD"D 4D D	DD	DE
D5D0+E0D55EE	E	c                      e Zd ZdZdZd Zd Zd Zd Zd Z	d Z
d	D ]$Z eee          r e
e           e            e<   %ddZer ede          Z ede          ZdD ]$Z eee          r ee           e            e<   %d ZdD ]$Z eee          r ee           e            e<   %d ZdD ]$Z eee          r ee           e            e<   %d Zd Zd Zd Zd
S )r   zDWrap 'os' module and 'open()' builtin for virtualizing setup scriptsFc                 R      fdt          t                    D              _        d S )Nc                 ^    g | ])}|                     d           t          |          '|*S )_)rY   hasattr)rZ   namerH   s     r   
<listcomp>z,AbstractSandbox.__init__.<locals>.<listcomp>  sO     
 
 
??3''
 -4D$,?,?

 
 
rC   )dir_os_attrsrG   s   `r   r   zAbstractSandbox.__init__  s7    
 
 
 
C
 
 
rC   c           	      b    | j         D ]&}t          t          |t          ||                     'd S r   )r   setattrr&   getattr)rH   sourcer   s      r   _copyzAbstractSandbox._copy  s<    K 	5 	5DBgfd334444	5 	5rC   c                     |                      |            t          r| j        t          _        | j        t          _        d| _        d S rK   )r   _filebuiltinsfile_openr   _activerG   s    r   rI   zAbstractSandbox.__enter__  s9    

4 	' JHM
rC   c                     d| _         t          rt          t          _        t          t          _        |                     t                     d S NF)r   r   r   r   r   r   r   r   )rH   exc_type	exc_value	tracebacks       r   rO   zAbstractSandbox.__exit__!  s2     	"!HM

3rC   c                 N    | 5   |            cddd           S # 1 swxY w Y   dS )zRun 'func' under os sandboxingNrB   )rH   funcs     r   runzAbstractSandbox.run(  su     	 	466	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	 	s   
c                 @     t          t                      fd}|S )Nc                 X    | j         r | j        ||g|R i |\  }} ||g|R i |S r   )r   _remap_pair)rH   srcdstr   kwr   originals        r   wrapz3AbstractSandbox._mk_dual_path_wrapper.<locals>.wrap0  sZ    | I+4+D#sHTHHHRHHS8C2t222r222rC   r   r   r   r   r   s   ` @r   _mk_dual_path_wrapperz%AbstractSandbox._mk_dual_path_wrapper-  s8    3%%	3 	3 	3 	3 	3 	3
 rC   )renamelinksymlinkNc                 D     pt          t                      fd}|S )Nc                 N    | j         r | j        |g|R i |} |g|R i |S r   )r   _remap_inputrH   r!   r   r   r   r   s       r   r   z5AbstractSandbox._mk_single_path_wrapper.<locals>.wrap>  sR    | B(t(tAdAAAbAA8D.4...2...rC   r   )r   r   r   s   `` r   _mk_single_path_wrapperz'AbstractSandbox._mk_single_path_wrapper;  s=    1wsD11	/ 	/ 	/ 	/ 	/ 	/
 rC   r   r   )statlistdirr.   r   chmodchownmkdirremoveunlinkrmdirutimelchownchrootlstat	startfilemkfifomknodpathconfaccessc                 @     t          t                      fd}|S )Nc                     | j         r2 | j        |g|R i |}|                      |g|R i |          S  |g|R i |S r   )r   r   _remap_outputr   s       r   r   z4AbstractSandbox._mk_single_with_return.<locals>.wrapc  s    | M(t(tAdAAAbAA))$0K0K0K0K0K0KLLL8D.4...2...rC   r   r   s   ` @r   _mk_single_with_returnz&AbstractSandbox._mk_single_with_return`  s8    3%%	/ 	/ 	/ 	/ 	/ 	/ rC   )readlinktempnamc                 @     t          t                      fd}|S )Nc                 R     |i |}| j         r|                     |          S |S r   )r   r   )rH   r   r   retvalr   r   s       r   r   z'AbstractSandbox._mk_query.<locals>.wrapr  s<    Xt*r**F| 8))$777MrC   r   r   s   ` @r   	_mk_queryzAbstractSandbox._mk_queryo  s8    3%%	 	 	 	 	 	 rC   )r-   tmpnamc                     |S )z=Called to remap or validate any path, whether input or outputrB   )rH   r!   s     r   _validate_pathzAbstractSandbox._validate_path~  s    rC   c                 ,    |                      |          S zCalled for path inputsr   rH   	operationr!   r   r   s        r   r   zAbstractSandbox._remap_input      ""4(((rC   c                 ,    |                      |          S )zCalled for path outputsr   )rH   r   r!   s      r   r   zAbstractSandbox._remap_output  r   rC   c                 V     | j         |dz   |g|R i | | j         |dz   |g|R i |fS )?Called for path pairs like rename, link, and symlink operationsz-fromz-to)r   rH   r   r   r   r   r   s         r   r   zAbstractSandbox._remap_pair  s\     Di'13DDDDDDDi%/BtBBBrBB
 	
rC   r   )r=   r>   r?   r@   r   r   r   rI   rO   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   rB   rC   r   r   r   
  s       NNG
 
 
5 5 5      
   . 9 973 	922488FFHHTN     7''66##FE22E ; ;* 73 	;44T::FFHHTN	 	 	 ( : :73 	:33D99FFHHTN	 	 	 % - -73 	-&Yt__FFHHTN  ) ) )) ) )
 
 
 
 
rC   r   devnullc                       e Zd ZdZe                    g d          Zg Z	 efdZ	d Z
erddZddZd Zd	 Zd
 Zd Zd ZddZdS )r   z<Restrict operations to a single subdirectory - pseudo-chroot)r   r   r   r   r   r   r   r   r   r   r   r   r   c                 2   t           j                            t           j                            |                    | _        t           j                            | j        d          | _        d |D             | _        t          	                    |            d S )N c                     g | ]>}t           j                            t           j                            |                    ?S rB   )r&   r!   normcaserealpath)rZ   r!   s     r   r   z-DirectorySandbox.__init__.<locals>.<listcomp>  sE     
 
 
9=BGRW--d3344
 
 
rC   )
r&   r!   r   r   _sandboxro   _prefix_exceptionsr   r   )rH   sandbox
exceptionss      r   r   zDirectorySandbox.__init__  s    (()9)9')B)BCCw||DM266
 
AK
 
 
 	  &&&&&rC   c                 (    ddl m}  ||||          )Nr   )r   )r7   r   )rH   r   r   r   r   s        r   
_violationzDirectorySandbox._violation  s)    777777y$333rC   rc                 |    |dvr(|                      |          s | j        d||g|R i | t          ||g|R i |S )Nr   rtr   rUUr   )_okr   r   rH   r!   r   r   r   s        r   r   zDirectorySandbox._file  sc    7777d@T@@@R@@@t1d111b111rC   c                 |    |dvr(|                      |          s | j        d||g|R i | t          ||g|R i |S )Nr   r   )r  r   r   r  s        r   r   zDirectorySandbox._open  sc    333DHHTNN3DOFD$<<<<<<<T4-$---"---rC   c                 0    |                      d           d S )Nr   )r   rG   s    r   r   zDirectorySandbox.tmpnam  s    !!!!!rC   c                 4   | j         }	 d| _         t          j                            t          j                            |                    }|                     |          p$|| j        k    p|                    | j                  	 || _         S # || _         w xY wr   )	r   r&   r!   r   r   	_exemptedr   rY   r   )rH   r!   activer   s       r   r  zDirectorySandbox._ok  s    		" DLw''(8(8(>(>??Hx(( 5t},5&&t|44 "DLL6DL!!!!s   A<B 	Bc                     fd| j         D             }fd| j        D             }t          j        ||          }t	          |          S )Nc              3   B   K   | ]}                     |          V  d S r   rX   )rZ   	exceptionfilepaths     r   r\   z-DirectorySandbox._exempted.<locals>.<genexpr>  sB       
 
/8H	**
 
 
 
 
 
rC   c              3   B   K   | ]}t          j        |          V  d S r   )rematch)rZ   patternr  s     r   r\   z-DirectorySandbox._exempted.<locals>.<genexpr>  s@       
 
,3BHWh''
 
 
 
 
 
rC   )r   _exception_patterns	itertoolschainany)rH   r  start_matchespattern_matches
candidatess    `   r   r  zDirectorySandbox._exempted  sx    
 
 
 
<@<L
 
 

 
 
 
7;7O
 
 
 _]ODD
:rC   c                     || j         v rD|                     |          s/ | j        |t          j                            |          g|R i | |S r   )	write_opsr  r   r&   r!   r   r   s        r   r   zDirectorySandbox._remap_input  sW    &&txx~~&DOIrw'7'7'='=KKKKKKKrC   c                     |                      |          r|                      |          s | j        |||g|R i | ||fS )r   )r  r   r   s         r   r   zDirectorySandbox._remap_pair  sU    xx}} 	>DHHSMM 	>DOIsC=$==="===SzrC     c                     |t           z  r)|                     |          s | j        d|||g|R i | t          j        |||g|R i |S )zCalled for low-level os.open()zos.open)WRITE_FLAGSr  r   r   r   )rH   r   flagsr   r   r   s         r   r   zDirectorySandbox.open  sn    ; 	Gtxx~~ 	GDOItUDF4FFF2FFFxeT7D777B777rC   N)r   )r  )r=   r>   r?   r@   r   fromkeysr  r  _EXCEPTIONSr   r   r   r   r   r  r  r   r   r   rB   rC   r   r   r     s        FF	
 	
 	
 I$ 4+6 ' ' ' '4 4 4
  2	2 	2 	2 	2
. . . .
" " "" " "      8 8 8 8 8 8rC   r   c                 :    g | ]}t          t          |d           S )r   r   )rZ   as     r   r   r     s4        	Q  rC   z4O_WRONLY O_RDWR O_APPEND O_CREAT O_TRUNC O_TEMPORARYc                   \    e Zd ZdZ ej        d                                          Zd ZdS )r   zEA setup script attempted to modify the filesystem outside the sandboxa  
        SandboxViolation: {cmd}{args!r} {kwargs}

        The package setup script has attempted to modify files on your system
        that are not within the EasyInstall build area, and has been aborted.

        This package cannot be safely installed by EasyInstall, and may not
        support alternate installation locations even if you run its setup
        script by hand.  Please inform the package's author and the EasyInstall
        maintainers to find out if a fix or workaround is available.
        c                 T    | j         \  }}} | j        j        di t                      S )NrB   )r   tmplformatr   )rH   cmdr   kwargss       r   __str__zSandboxViolation.__str__  s/     IT6ty++&((+++rC   N)	r=   r>   r?   r@   textwrapdedentlstripr%  r)  rB   rC   r   r   r     sO        OO8?
	  fhh 	, , , , ,rC   r   r   )9r&   r   r(   operator	functoolsr  r  
contextlibr4   r*  r   rh   distutils.errorsr   r   platformrY   $org.python.modules.posix.PosixModulepythonr]   posixPosixModuler   r   r   r   	NameErrorr   r   __all__r   contextmanagerr   r#   r+   r0   r6   r2   rE   rc   r`   rk   rt   r|   r~   rp   r	   r   r   r   r   r   reduceor_r{   r  r   rB   rC   r   <module>r;     s   				 



           				            + + + + + + % % % % % %<6"" 6666666666666666
+bg
CEE   EEE  
  
  
  
         ! ! !    1 1 1 1 1I 1 1 1(+ + + + + + + +<   2" " "
 * * * " " "   + + +*    (E
 E
 E
 E
 E
 E
 E
 E
P 72y :,KKK[8 [8 [8 [8 [8 [8 [8 [8| iL GMMOO   , , , , ,~ , , , , ,s   :A= =BB