Your IP : 3.138.174.45


Current Path : /opt/alt/python310/lib/python3.10/site-packages/setuptools/__pycache__/
Upload File :
Current File : //opt/alt/python310/lib/python3.10/site-packages/setuptools/__pycache__/sandbox.cpython-310.pyc

o

~�Re8�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZej�d�rRddlmmmmZnejejZzeZWneygdZYnweZgd�Zd-dd�Zejd-dd	��Z ejd
d��Z!ejdd
��Z"ejdd��Z#Gdd�de$�Z%Gdd�d�Z&ejdd��Z'dd�Z(ejdd��Z)ejdd��Z*hd�Z+dd�Z,dd �Z-d!d"�Z.Gd#d$�d$�Z/e0ed%�r�ej1gZ2ngZ2Gd&d'�d'e/�Z3e�4ej5d(d)�d*�6�D��Z7Gd+d,�d,e
�Z8dS).�N)�DistutilsError)�working_set�java)�AbstractSandbox�DirectorySandbox�SandboxViolation�	run_setupcCs^d}t||��}|��}Wd�n1swY|dur!|}t||d�}t|||�dS)z.
    Python 3 implementation of execfile.
    �rbN�exec)�open�read�compiler
)�filename�globals�locals�mode�stream�script�code�r��/builddir/build/BUILDROOT/alt-python310-setuptools-58.3.0-2.el8.x86_64/opt/alt/python310/lib/python3.10/site-packages/setuptools/sandbox.py�	_execfile$s
�rc
csR�tjdd�}|dur|tjdd�<z
|VW|tjdd�<dS|tjdd�<w�N)�sys�argv)�repl�savedrrr�	save_argv1s�"rc
cs<�tjdd�}z
|VW|tjdd�<dS|tjdd�<wr)r�path�rrrr�	save_path<s
�"r ccs8�tj|dd�tj}|t_z	dVW|t_dS|t_w)zL
    Monkey-patch tempfile.tempdir with replacement, ensuring it exists
    T)�exist_okN)�os�makedirs�tempfile�tempdir)�replacementrrrr�
override_tempEs�r'c	cs8�t��}t�|�z|VWt�|�dSt�|�wr)r"�getcwd�chdir)�targetrrrr�pushdVs�
r+c@seZdZdZedd��ZdS)�UnpickleableExceptionzP
    An exception representing another Exception that could not be pickled.
    c	CsJzt�|�t�|�fWSty$ddlm}|�||t|���YSw)z�
        Always return a dumped (pickled) type and exc. If exc can't be pickled,
        wrap it in UnpickleableException first.
        r)r,)�pickle�dumps�	Exception�setuptools.sandboxr,�dump�repr)�type�exc�clsrrrr1es�zUnpickleableException.dumpN)�__name__�
__module__�__qualname__�__doc__�staticmethodr1rrrrr,`sr,c@s(eZdZdZdd�Zdd�Zdd�ZdS)	�ExceptionSaverz^
    A Context Manager that will save an exception, serialized, and restore it
    later.
    cCs|Srr��selfrrr�	__enter__zszExceptionSaver.__enter__cCs |sdSt�||�|_||_dS�NT)r,r1�_saved�_tb)r=r3r4�tbrrr�__exit__}s
zExceptionSaver.__exit__cCs.dt|�vrdSttj|j�\}}|�|j��)z"restore and re-raise any exceptionr@N)�vars�mapr-�loadsr@�with_tracebackrA)r=r3r4rrr�resume�szExceptionSaver.resumeN)r6r7r8r9r>rCrHrrrrr;ts
r;c#sl�tj���t��}�VWd�n1swYtj����fdd�tjD�}t|�|��dS)z�
    Context in which imported modules are saved.

    Translates exceptions internal to the context into the equivalent exception
    outside the context.
    Nc3s&�|]}|�vr|�d�s|VqdS)z
encodings.N��
startswith)�.0�mod_namerrr�	<genexpr>�s����zsave_modules.<locals>.<genexpr>)r�modules�copyr;�update�_clear_modulesrH)�	saved_excZdel_modulesrrr�save_modules�s�
�
�rScCst|�D]}tj|=qdSr)�listrrN)Zmodule_namesrLrrrrQ�s
�rQc	cs.�t��}z|VWt�|�dSt�|�wr)�
pkg_resources�__getstate__�__setstate__rrrr�save_pkg_resources_state�s
�rXc
cs"�tj�|d�}t��|t��`t��Mt�t��7t|��#t	|��t
d�dVWd�n1s6wYWd�n1sEwYWd�n1sTwYWd�n1scwYWd�n1srwYWd�dSWd�dS1s�wYdS)N�temp�
setuptools)r"r�joinrXrSr �hide_setuptoolsrr'r+�
__import__)�	setup_dir�temp_dirrrr�
setup_context�s.�

����������"�r`>rUZCython�	distutils�_distutils_hackrZcCs|�dd�d}|tvS)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)rL�base_modulerrr�
_needs_hiding�srhcCs6tj�dd�}|dur|��tttj�}t|�dS)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.
    rbN)rrN�getZremove_shim�filterrhrQ)rbrNrrrr\�s
r\cCs
tj�tj�|��}t|��mz@|gt|�tjdd�<tj�d|�t	�
�t	j�dd��t
|��t|dd�}t||�Wd�n1sIwYWntyj}z|jr`|jdr`�WYd}~n
d}~wwWd�dSWd�dS1s~wYdS)z8Run a distutils setup script, sandboxed in its directoryNrcSs|��Sr)�activate)�distrrr�<lambda>�szrun_setup.<locals>.<lambda>�__main__)�__file__r6)r"r�abspath�dirnamer`rTrr�insertr�__init__�	callbacks�appendr�dictr�
SystemExit�args)Zsetup_scriptrxr^�ns�vrrrr�s*

�������"rc@seZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dD]Zee
e�r0e
e�e�e<q"d$dd�Zer=ede�Zede�ZdD]Zee
e�rRee�e�e<qDdd�ZdD]Zee
e�rgee�e�e<qYdd�ZdD]Zee
e�r|ee�e�e<qndd�Zdd�Zd d!�Zd"d#�ZdS)%rzDWrap 'os' module and 'open()' builtin for virtualizing setup scriptsFcs�fdd�tt�D��_dS)Ncs$g|]}|�d�st�|�r|�qS)�_)rJ�hasattr)rK�namer<rr�
<listcomp>s���z,AbstractSandbox.__init__.<locals>.<listcomp>)�dir�_os�_attrsr<rr<rrss
�zAbstractSandbox.__init__cCs"|jD]}tt|t||��qdSr)r��setattrr"�getattr)r=�sourcer}rrr�_copys
�zAbstractSandbox._copycCs(|�|�tr|jt_|jt_d|_dSr?)r��_file�builtins�file�_openr�_activer<rrrr>s


zAbstractSandbox.__enter__cCs$d|_trtt_tt_|�t�dS�NF)r�r�r�r�r�rr�r�)r=�exc_type�	exc_value�	tracebackrrrrC!s
zAbstractSandbox.__exit__cCs.|�|�Wd�S1swYdS)zRun 'func' under os sandboxingNr)r=�funcrrr�run(s$�zAbstractSandbox.runc�tt�����fdd�}|S)Ncs>|jr|j�||g|�Ri|��\}}�||g|�Ri|��Sr)r��_remap_pair)r=�src�dstrx�kw�r}�originalrr�wrap0s z3AbstractSandbox._mk_dual_path_wrapper.<locals>.wrap�r�r��r}r�rr�r�_mk_dual_path_wrapper-s
z%AbstractSandbox._mk_dual_path_wrapper)�rename�link�symlinkNcs �ptt�����fdd�}|S)Ncs6|jr|j�|g|�Ri|��}�|g|�Ri|��Sr)r��_remap_input�r=rrxr�r�rrr�>sz5AbstractSandbox._mk_single_path_wrapper.<locals>.wrapr�)r}r�r�rr�r�_mk_single_path_wrapper;sz'AbstractSandbox._mk_single_path_wrapperr�r)�stat�listdirr)r�chmod�chown�mkdir�remove�unlink�rmdir�utime�lchown�chroot�lstatZ	startfile�mkfifo�mknod�pathconf�accesscr�)NcsT|jr|j�|g|�Ri|��}|���|g|�Ri|���S�|g|�Ri|��Sr)r�r��
_remap_outputr�r�rrr�csz4AbstractSandbox._mk_single_with_return.<locals>.wrapr�r�rr�r�_mk_single_with_return`�
z&AbstractSandbox._mk_single_with_return)�readlink�tempnamcr�)Ncs$�|i|��}|jr|��|�S|Sr)r�r�)r=rxr��retvalr�rrr�rsz'AbstractSandbox._mk_query.<locals>.wrapr�r�rr�r�	_mk_queryor�zAbstractSandbox._mk_query)r(�tmpnamcCs|S)z=Called to remap or validate any path, whether input or outputr)r=rrrr�_validate_path~szAbstractSandbox._validate_pathcO�
|�|�S�zCalled for path inputs�r��r=�	operationrrxr�rrrr���
zAbstractSandbox._remap_inputcCr�)zCalled for path outputsr�)r=r�rrrrr��r�zAbstractSandbox._remap_outputcOs<|j|d|g|�Ri|��|j|d|g|�Ri|��fS)�?Called for path pairs like rename, link, and symlink operationsz-fromz-to)r��r=r�r�r�rxr�rrrr��s�zAbstractSandbox._remap_pairr)r6r7r8r9r�rsr�r>rCr�r�r}r|r�rr�r�r�r�r�r�r�r�r�rrrrr
sF

�




�
�
�r�devnullc@s�eZdZdZe�gd��ZgZ	efdd�Z	dd�Z
er!ddd	�Zdd
d�Zdd
�Z
dd�Zdd�Zdd�Zdd�Zddd�ZdS)rz<Restrict operations to a single subdirectory - pseudo-chroot)
rr�r�r�r�r�r�r�r�r�r�r�r�cCsFtj�tj�|��|_tj�|jd�|_dd�|D�|_t�	|�dS)N�cSs g|]}tj�tj�|���qSr)r"r�normcase�realpath)rKrrrrr~�s�z-DirectorySandbox.__init__.<locals>.<listcomp>)
r"rr�r��_sandboxr[�_prefix�_exceptionsrrs)r=Zsandbox�
exceptionsrrrrs�s�zDirectorySandbox.__init__cOsddlm}||||��)Nr)r)r0r)r=r�rxr�rrrr�
_violation�szDirectorySandbox._violation�rcO�F|dvr|�|�s|jd||g|�Ri|��t||g|�Ri|��S)N�r��rtr	ZrU�Ur�)�_okr�r��r=rrrxr�rrrr���zDirectorySandbox._filecOr�)Nr�r)r�r�r�r�rrrr��r�zDirectorySandbox._opencCs|�d�dS)Nr�)r�r<rrrr��szDirectorySandbox.tmpnamcCsR|j}z!d|_tj�tj�|��}|�|�p ||jkp |�|j�W||_S||_wr�)	r�r"rr�r��	_exemptedr�rJr�)r=r�activer�rrrr��s
�
�zDirectorySandbox._okcs<�fdd�|jD�}�fdd�|jD�}t�||�}t|�S)Nc3s�|]}��|�VqdSrrI)rK�	exception��filepathrrrM�s�

�z-DirectorySandbox._exempted.<locals>.<genexpr>c3s�|]	}t�|��VqdSr)�re�match)rK�patternr�rrrM�s�
�)r��_exception_patterns�	itertools�chain�any)r=r�Z
start_matchesZpattern_matches�
candidatesrr�rr��s
�
�zDirectorySandbox._exemptedcOs:||jvr|�|�s|j|tj�|�g|�Ri|��|Sr�)�	write_opsr�r�r"rr�r�rrrr��s"zDirectorySandbox._remap_inputcOs8|�|�r
|�|�s|j|||g|�Ri|��||fS)r�)r�r�r�rrrr��szDirectorySandbox._remap_pair�cOsL|t@r|�|�s|jd|||g|�Ri|��tj|||g|�Ri|��S)zCalled for low-level os.open()zos.open)�WRITE_FLAGSr�r�r�r)r=r��flagsrrxr�rrrr�szDirectorySandbox.openN)r�)r�)r6r7r8r9rv�fromkeysr�r��_EXCEPTIONSrsr�r�r�r�r�r�r�r�rrrrrr�s$�



rcCsg|]}tt|d��qS)rr�)rK�arrrr~�s
��r~z4O_WRONLY O_RDWR O_APPEND O_CREAT O_TRUNC O_TEMPORARYc@s&eZdZdZe�d���Zdd�ZdS)rzEA 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.
        cCs |j\}}}|jjdit���S)Nr)rx�tmpl�formatr)r=�cmdrx�kwargsrrr�__str__szSandboxViolation.__str__N)	r6r7r8r9�textwrap�dedent�lstripr�r�rrrrr�s��rr)9r"rr$�operator�	functoolsr�r��
contextlibr-r�r�rU�distutils.errorsrr�platformrJZ$org.python.modules.posix.PosixModule�pythonrN�posixZPosixModuler�r}r�r��	NameErrorrr��__all__r�contextmanagerrr r'r+r/r,r;rSrQrXr`rfrhr\rrr|r�r�r�reduce�or_rer�rrrrr�<module>sv �





	


	
	
^��	

?>