AlkantarClanX12

Your IP : 3.144.42.233


Current Path : /lib/python3.8/site-packages/setuptools/__pycache__/
Upload File :
Current File : //lib/python3.8/site-packages/setuptools/__pycache__/sandbox.cpython-38.pyc

U

�Qab�7�@s
ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZddlZej�d�r�ddlmmmmZnejejZzeZWnek
r�dZYnXeZddlm Z ddlm!Z!ddd	d
gZ"d-dd�Z#ej$d.d
d��Z%ej$dd��Z&ej$dd��Z'ej$dd��Z(Gdd�de)�Z*Gdd�d�Z+ej$dd��Z,dd�Z-ej$dd��Z.ej$dd ��Z/d!d"�Z0d#d$�Z1d%d
�Z2Gd&d�d�Z3e4ed'��r�ej5gZ6ngZ6Gd(d�de3�Z7e�8ej9d)d*�d+�:�D��Z;Gd,d	�d	e �Z<dS)/�N)�six)�builtins�map�java)�DistutilsError)�working_set�AbstractSandbox�DirectorySandbox�SandboxViolation�	run_setupc	CsJd}t||��}|��}W5QRX|dkr.|}t||d�}t|||�dS)z.
    Python 3 implementation of execfile.
    �rbN�exec)�open�read�compiler
)�filename�globals�locals�mode�streamZscript�code�r�6/usr/lib/python3.8/site-packages/setuptools/sandbox.py�	_execfile#src
csDtjdd�}|dk	r$|tjdd�<z
|VW5|tjdd�<XdS�N)�sys�argv)�repl�savedrrr�	save_argv0s
rc
cs.tjdd�}z
|VW5|tjdd�<XdSr)r�path�rrrr�	save_path;s
r"ccs4tjj|dd�tj}|t_z
dVW5|t_XdS)zL
    Monkey-patch tempfile.tempdir with replacement, ensuring it exists
    T)�exist_okN)�
pkg_resourcesZ
py31compat�makedirs�tempfileZtempdir)Zreplacementrrrr�
override_tempDs
r'c	cs.t��}t�|�z
|VW5t�|�XdSr)�os�getcwd�chdir)�targetrrrr�pushdUs


r,c@seZdZdZedd��ZdS)�UnpickleableExceptionzP
    An exception representing another Exception that could not be pickled.
    c	CsPzt�|�t�|�fWStk
rJddlm}|�||t|���YSXdS)z�
        Always return a dumped (pickled) type and exc. If exc can't be pickled,
        wrap it in UnpickleableException first.
        r)r-N)�pickle�dumps�	Exception�setuptools.sandboxr-�dump�repr)�type�exc�clsrrrr2ds
zUnpickleableException.dumpN)�__name__�
__module__�__qualname__�__doc__�staticmethodr2rrrrr-_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__xszExceptionSaver.__enter__cCs |sdSt�||�|_||_dS�NT)r-r2�_saved�_tb)r>r4r5�tbrrr�__exit__{s
zExceptionSaver.__exit__cCs6dt|�krdSttj|j�\}}t�|||j�dS)z"restore and re-raise any exceptionrAN)�varsrr.�loadsrArZreraiserB)r>r4r5rrr�resume�szExceptionSaver.resumeN)r7r8r9r:r?rDrGrrrrr<rsr<c	#sVtj���t��}�VW5QRXtj����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.
    c3s$|]}|�kr|�d�s|VqdS)z
encodings.N��
startswith)�.0�mod_namer!rr�	<genexpr>�s
�zsave_modules.<locals>.<genexpr>N)r�modules�copyr<�update�_clear_modulesrG)�	saved_excZdel_modulesrr!r�save_modules�s

�rRcCst|�D]}tj|=qdSr)�listrrM)Zmodule_namesrKrrrrP�srPc	cs$t��}z
|VW5t�|�XdSr)r$�__getstate__�__setstate__r!rrr�save_pkg_resources_state�s
rVccs�tj�|d�}t��xt��ft�t��Nt��<t|��(t	|��t
d�dVW5QRXW5QRXW5QRXW5QRXW5QRXW5QRXdS)NZtempZ
setuptools)r(r �joinrVrR�hide_setuptoolsr"rr'r,�
__import__)�	setup_dirZtemp_dirrrr�
setup_context�s

r[cCst�d�}t|�|��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
    z1(setuptools|pkg_resources|distutils|Cython)(\.|$))�rer�bool�match)rK�patternrrr�
_needs_hiding�s
r`cCstttj�}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.
    N)�filterr`rrMrP)rMrrrrX�srXcCs�tj�tj�|��}t|���z�|gt|�tjdd�<tj�d|�t	�
�t	j�dd��t
|t�rl|n|�t���}t|��t|dd�}t||�W5QRXWn4tk
r�}z|jr�|jdrʂW5d}~XYnXW5QRXdS)z8Run a distutils setup script, sandboxed in its directoryNrcSs|��Sr)Zactivate)Zdistrrr�<lambda>��zrun_setup.<locals>.<lambda>�__main__)�__file__r7)r(r �abspath�dirnamer[rSrr�insertr�__init__Z	callbacks�append�
isinstance�str�encode�getfilesystemencodingr	�dictr�
SystemExit�args)Zsetup_scriptrqrZZdunder_file�ns�vrrrr�s"
��
c@seZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
dD]Zee
e�rDe
e�e�e<qDd$dd�Zerzede�Zede�ZdD]Zee
e�r�ee�e�e<q�dd�ZdD]Zee
e�r�ee�e�e<q�dd�ZdD]Zee
e�r�ee�e�e<q�dd�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)�_)rI�hasattr)rJ�namer=rr�
<listcomp>s

�z,AbstractSandbox.__init__.<locals>.<listcomp>)�dir�_os�_attrsr=rr=rris
�zAbstractSandbox.__init__cCs"|jD]}tt|t||��qdSr)rz�setattrr(�getattr)r>�sourcervrrr�_copys
zAbstractSandbox._copycCs(|�|�tr|jt_|jt_d|_dSr@)r~�_filer�file�_openr�_activer=rrrr?s

zAbstractSandbox.__enter__cCs$d|_trtt_tt_|�t�dS�NF)r�rrr�r�rr~ry)r>�exc_type�	exc_value�	tracebackrrrrDs
zAbstractSandbox.__exit__c
Cs"|�|�W5QR�SQRXdS)zRun 'func' under os sandboxingNr)r>�funcrrr�runszAbstractSandbox.runcstt�����fdd�}|S)Ncs2|jr |j�||f|�|�\}}�||f|�|�Sr)r��_remap_pair)r>�src�dstrq�kw�rv�originalrr�wrap&sz3AbstractSandbox._mk_dual_path_wrapper.<locals>.wrap�r|ry�rvr�rr�r�_mk_dual_path_wrapper#s
z%AbstractSandbox._mk_dual_path_wrapper)�rename�link�symlinkNcs �ptt�����fdd�}|S)Ncs*|jr|j�|f|�|�}�|f|�|�Sr)r��_remap_input�r>r rqr�r�rrr�4sz5AbstractSandbox._mk_single_path_wrapper.<locals>.wrapr�)rvr�r�rr�r�_mk_single_path_wrapper1sz'AbstractSandbox._mk_single_path_wrapperr�r)�stat�listdirr*r�chmod�chown�mkdir�remove�unlink�rmdir�utime�lchown�chroot�lstatZ	startfile�mkfifo�mknod�pathconf�accesscstt�����fdd�}|S)NcsB|jr2|j�|f|�|�}|���|f|�|��S�|f|�|�Sr)r�r��
_remap_outputr�r�rrr�Isz4AbstractSandbox._mk_single_with_return.<locals>.wrapr�r�rr�r�_mk_single_with_returnFs
z&AbstractSandbox._mk_single_with_return)�readlink�tempnamcstt�����fdd�}|S)Ncs �||�}|jr|��|�S|Sr)r�r�)r>rqr�Zretvalr�rrr�Xs
z'AbstractSandbox._mk_query.<locals>.wrapr�r�rr�r�	_mk_queryUs
zAbstractSandbox._mk_query)r)�tmpnamcCs|S)z=Called to remap or validate any path, whether input or outputr)r>r rrr�_validate_pathdszAbstractSandbox._validate_pathcOs
|�|�S�zCalled for path inputs�r��r>�	operationr rqr�rrrr�hszAbstractSandbox._remap_inputcCs
|�|�S)zCalled for path outputsr�)r>r�r rrrr�lszAbstractSandbox._remap_outputcOs0|j|d|f|�|�|j|d|f|�|�fS)�?Called for path pairs like rename, link, and symlink operationsz-fromz-to)r��r>r�r�r�rqr�rrrr�ps�zAbstractSandbox._remap_pair)N)r7r8r9r:r�rir~r?rDr�r�rvruryrr�rr�r�r�r�r�r�r�rrrrrs<








�devnullc@s�eZdZdZe�dddddddd	d
ddd
dg
�ZdgZefdd�Z	dd�Z
erXd'dd�Zd(dd�Zdd�Z
dd�Zdd�Zdd �Zd!d"�Zd)d$d%�Zd&S)*r	z<Restrict operations to a single subdirectory - pseudo-chrootrr�r�r�r�r�r�r�r�r�r�r�r�z.*lib2to3.*\.pickle$cCsFtj�tj�|��|_tj�|jd�|_dd�|D�|_t�	|�dS)N�cSs g|]}tj�tj�|���qSr)r(r �normcase�realpath)rJr rrrrw�s�z-DirectorySandbox.__init__.<locals>.<listcomp>)
r(r r�r��_sandboxrW�_prefix�_exceptionsrri)r>Zsandbox�
exceptionsrrrri�s�zDirectorySandbox.__init__cOsddlm}||||��dS)Nr)r
)r1r
)r>r�rqr�r
rrr�
_violation�szDirectorySandbox._violation�rcOs:|dkr(|�|�s(|jd||f|�|�t||f|�|�S)N�r�ZrtrZrU�Ur�)�_okr�r�r>r rrqr�rrrr�szDirectorySandbox._filecOs:|dkr(|�|�s(|jd||f|�|�t||f|�|�S)Nr�r)r�r�r�r�rrrr��szDirectorySandbox._opencCs|�d�dS)Nr�)r�r=rrrr��szDirectorySandbox.tmpnamcCsR|j}z>d|_tj�tj�|��}|�|�p@||jkp@|�|j�W�S||_XdSr�)	r�r(r r�r��	_exemptedr�rIr�)r>r Zactiver�rrrr��s
�
�zDirectorySandbox._okcs<�fdd�|jD�}�fdd�|jD�}t�||�}t|�S)Nc3s|]}��|�VqdSrrH)rJZ	exception��filepathrrrL�s�z-DirectorySandbox._exempted.<locals>.<genexpr>c3s|]}t�|��VqdSr)r\r^)rJr_r�rrrL�s�)r��_exception_patterns�	itertools�chain�any)r>r�Z
start_matchesZpattern_matchesZ
candidatesrr�rr��s
�
�zDirectorySandbox._exemptedcOs4||jkr0|�|�s0|j|tj�|�f|�|�|Sr�)�	write_opsr�r�r(r r�r�rrrr��szDirectorySandbox._remap_inputcOs2|�|�r|�|�s*|j|||f|�|�||fS)r�)r�r�r�rrrr��szDirectorySandbox._remap_pair�cOs@|t@r*|�|�s*|jd|||f|�|�tj|||f|�|�S)zCalled for low-level os.open()zos.open)�WRITE_FLAGSr�r�ryr)r>r��flagsrrqr�rrrr�szDirectorySandbox.openN)r�)r�)r�)r7r8r9r:ro�fromkeysr�r��_EXCEPTIONSrir�rr�r�r�r�r�r�rrrrrr	~s:��	


cCsg|]}tt|d��qS)rr�)rJ�arrrrw�srwz4O_WRONLY O_RDWR O_APPEND O_CREAT O_TRUNC O_TEMPORARYc@s&eZdZdZe�d���Zdd�ZdS)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.
        cCs|j\}}}|jjft��Sr)rq�tmpl�formatr)r>�cmdrq�kwargsrrr�__str__�szSandboxViolation.__str__N)	r7r8r9r:�textwrap�dedent�lstripr�r�rrrrr
�s)N)N)=r(rr&�operator�	functoolsr�r\�
contextlibr.r�Zsetuptools.externrZsetuptools.extern.six.movesrrZpkg_resources.py31compatr$�platformrIZ$org.python.modules.posix.PosixModule�pythonrM�posixZPosixModuleryrvr�r�	NameErrorrr�Zdistutils.errorsrr�__all__r�contextmanagerrr"r'r,r0r-r<rRrPrVr[r`rXrrrur�r�r	�reduce�or_�splitr�r
rrrr�<module>sx 
�





	


w
V��