Your IP : 18.117.254.177


Current Path : /opt/alt/python35/lib/python3.5/site-packages/setuptools/__pycache__/
Upload File :
Current File : //opt/alt/python35/lib/python3.5/site-packages/setuptools/__pycache__/sandbox.cpython-35.pyc



�Re�8�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
mZddlZejjd�r�ddljjjjZnejejZy
eZWnek
rdZYnXeZddlm Z ddlm!Z!ddd	d
gZ"ddd�Z#ej$dd
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'�rsej5gZ6ngZ6Gd(d�de3�Z7ej8ej9d)d*�d+j:�D��Z;Gd,d	�d	e �Z<dS)-�N)�six)�builtins�map�java)�DistutilsError)�working_set�AbstractSandbox�DirectorySandbox�SandboxViolation�	run_setupcCs�d}t||��}|j�}WdQRXtjdd�dksvtjdd�dkr�tjdd�d
kr�|jdd�}|jd	d�}|dkr�|}t||d
�}t|||�dS)z.
    Python 3 implementation of execfile.
    �rbN���rs
s
s
�exec)r
r)rr)rr
)�open�read�sys�version_info�replace�compiler)�filename�globals�locals�mode�stream�script�code�r��/builddir/build/BUILDROOT/alt-python35-setuptools-36.3.0-4.el8.x86_64/opt/alt/python35/lib/python3.5/site-packages/setuptools/sandbox.py�	_execfile#sKr c
csVtjdd�}|dk	r2|tjdd�<z	|VWd|tjdd�<XdS)N)r�argv)�repl�savedrrr�	save_argv4s	r$c
cs7tjdd�}z	|VWd|tjdd�<XdS)N)r�path)r#rrr�	save_path?s	r&ccsBtjj|dd�tj}|t_z	dVWd|t_XdS)zL
    Monkey-patch tempfile.tempdir with replacement, ensuring it exists
    �exist_okTN)�
pkg_resources�
py31compat�makedirs�tempfile�tempdir)�replacementr#rrr�
override_tempHs			r.ccs7tj�}tj|�z	|VWdtj|�XdS)N)�os�getcwd�chdir)�targetr#rrr�pushdYs

	r3c@s(eZdZdZedd��ZdS)�UnpickleableExceptionzP
    An exception representing another Exception that could not be pickled.
    cCsey tj|�tj|�fSWn>tk
r`ddlm}|j||t|���SYnXdS)z�
        Always return a dumped (pickled) type and exc. If exc can't be pickled,
        wrap it in UnpickleableException first.
        r)r4N)�pickle�dumps�	Exception�setuptools.sandboxr4�dump�repr)�type�exc�clsrrrr9hs
 
zUnpickleableException.dumpN)�__name__�
__module__�__qualname__�__doc__�staticmethodr9rrrrr4csr4c@s:eZdZdZdd�Zdd�Zdd�ZdS)	�ExceptionSaverz^
    A Context Manager that will save an exception, serialized, and restore it
    later.
    cCs|S)Nr)�selfrrr�	__enter__|szExceptionSaver.__enter__cCs,|s
dStj||�|_||_dS)NT)r4r9�_saved�_tb)rDr;r<�tbrrr�__exit__s
	zExceptionSaver.__exit__cCsKdt|�krdSttj|j�\}}tj|||j�dS)z"restore and re-raise any exceptionrFN)�varsrr5�loadsrFr�reraiserG)rDr;r<rrr�resume�szExceptionSaver.resumeN)r>r?r@rArErIrMrrrrrCvsrCc
#sktjj��t��}�VWdQRXtjj���fdd�tjD�}t|�|j�dS)z�
    Context in which imported modules are saved.

    Translates exceptions internal to the context into the equivalent exception
    outside the context.
    Nc3s1|]'}|�kr|jd�r|VqdS)z
encodings.N)�
startswith)�.0�mod_name)r#rr�	<genexpr>�szsave_modules.<locals>.<genexpr>)r�modules�copyrC�update�_clear_modulesrM)�	saved_excZdel_modulesr)r#r�save_modules�s
rWcCs%xt|�D]}tj|=q
WdS)N)�listrrR)�module_namesrPrrrrU�srUccs*tj�}z	|VWdtj|�XdS)N)r(�__getstate__�__setstate__)r#rrr�save_pkg_resources_state�s	r\c,cs�tjj|d�}t��vt��et�t��Mt��<t|��(t	|��t
d�dVWdQRXWdQRXWdQRXWdQRXWdQRXWdQRXdS)N�temp�
setuptools)r/r%�joinr\rW�hide_setuptoolsr&r$r.r3�
__import__)�	setup_dir�temp_dirrrr�
setup_context�s






rdcCs"tjd�}t|j|��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)rP�patternrrr�
_needs_hiding�sricCs 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.
    N)�filterrirrRrU)rRrrrr`�sr`cCs.tjjtjj|��}t|���y�|gt|�tjdd�<tjjd|�t	j
�t	jjdd��t
|t�r�|n|jtj��}t|��'td|dd�}t||�WdQRXWn>tk
r"}z|jr|jdr�WYdd}~XnXWdQRXdS)z8Run a distutils setup script, sandboxed in its directoryNrcSs
|j�S)N)�activate)�distrrr�<lambda>�szrun_setup.<locals>.<lambda>�__file__r>�__main__)r/r%�abspath�dirnamerdrXrr!�insertr�__init__�	callbacks�append�
isinstance�str�encode�getfilesystemencodingr	�dictr �
SystemExit�args)Zsetup_scriptr|rbZdunder_file�ns�vrrrr�s
 

c@s�eZdZdZdZdd�Zdd�Zdd�Zd	d
�Zdd�Z	d
d�Z
x9dddgD](Zee
e�rpe
e�e�e<qpWddd�Zer�ede�Zede�Zxiddddddddddd d!d"d#d$d%d&d'd(gD](Zee
e�ree�e�e<qWd)d*�Zx6d+d,gD](Zee
e�rTee�e�e<qTWd-d.�Zx6d/d0gD](Zee
e�r�ee�e�e<q�Wd1d2�Zd3d4�Zd5d6�Zd7d8�ZdS)9rzDWrap 'os' module and 'open()' builtin for virtualizing setup scriptsFcs&�fdd�tt�D��_dS)Ncs5g|]+}|jd�rt�|�r|�qS)�_)rN�hasattr)rO�name)rDrr�
<listcomp>s	z,AbstractSandbox.__init__.<locals>.<listcomp>)�dir�_os�_attrs)rDr)rDrrs
szAbstractSandbox.__init__cCs1x*|jD]}tt|t||��q
WdS)N)r��setattrr/�getattr)rD�sourcer�rrr�_copyszAbstractSandbox._copycCs8|j|�tr|jt_|jt_d|_dS)NT)r��_filer�file�_openr�_active)rDrrrrEs

zAbstractSandbox.__enter__cCs2d|_trtt_tt_|jt�dS)NF)r�r�rr�r�rr�r�)rD�exc_type�	exc_value�	tracebackrrrrIs
			zAbstractSandbox.__exit__c	Cs|�|�SWdQRXdS)zRun 'func' under os sandboxingNr)rD�funcrrr�run"szAbstractSandbox.runcs(tt�����fdd�}|S)Ncs=|jr*|j�||||�\}}�||||�S)N)r��_remap_pair)rD�src�dstr|�kw)r��originalrr�wrap*s	!z3AbstractSandbox._mk_dual_path_wrapper.<locals>.wrap)r�r�)r�r�r)r�r�r�_mk_dual_path_wrapper'sz%AbstractSandbox._mk_dual_path_wrapper�rename�link�symlinkNcs.�ptt�����fdd�}|S)Ncs1|jr!|j�|||�}�|||�S)N)r��_remap_input)rDr%r|r�)r�r�rrr�8s	z5AbstractSandbox._mk_single_path_wrapper.<locals>.wrap)r�r�)r�r�r�r)r�r�r�_mk_single_path_wrapper5sz'AbstractSandbox._mk_single_path_wrapperr�r�stat�listdirr1�chmod�chown�mkdir�remove�unlink�rmdir�utime�lchown�chroot�lstatZ	startfile�mkfifo�mknod�pathconf�accesscs(tt�����fdd�}|S)NcsM|jr=|j�|||�}|j��|||��S�|||�S)N)r�r��
_remap_output)rDr%r|r�)r�r�rrr�Ms	z4AbstractSandbox._mk_single_with_return.<locals>.wrap)r�r�)r�r�r)r�r�r�_mk_single_with_returnJsz&AbstractSandbox._mk_single_with_return�readlink�tempnamcs(tt�����fdd�}|S)Ncs,�||�}|jr(|j�|�S|S)N)r�r�)rDr|r��retval)r�r�rrr�\s	z'AbstractSandbox._mk_query.<locals>.wrap)r�r�)r�r�r)r�r�r�	_mk_queryYszAbstractSandbox._mk_queryr0�tmpnamcCs|S)z=Called to remap or validate any path, whether input or outputr)rDr%rrr�_validate_pathhszAbstractSandbox._validate_pathcOs
|j|�S)zCalled for path inputs)r�)rD�	operationr%r|r�rrrr�lszAbstractSandbox._remap_inputcCs
|j|�S)zCalled for path outputs)r�)rDr�r%rrrr�pszAbstractSandbox._remap_outputcOs6|j|d|||�|j|d|||�fS)z?Called for path pairs like rename, link, and symlink operationsz-fromz-to)r�)rDr�r�r�r|r�rrrr�tszAbstractSandbox._remap_pair)r>r?r@rAr�rsr�rErIr�r�r�r�r�rr�r�r�r�r�r�r�r�r�rrrrrsB

�devnullc@s�eZdZdZejdddddddd	d
ddd
dg
�ZdgZedd�Z	dd�Z
er�ddd�Zddd�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$cCsctjjtjj|��|_tjj|jd�|_dd�|D�|_tj	|�dS)N�cSs.g|]$}tjjtjj|���qSr)r/r%�normcase�realpath)rOr%rrrr��s	z-DirectorySandbox.__init__.<locals>.<listcomp>)
r/r%r�r��_sandboxr_�_prefix�_exceptionsrrs)rDZsandbox�
exceptionsrrrrs�s
!	
zDirectorySandbox.__init__cOs&ddlm}||||��dS)Nr)r
)r8r
)rDr�r|r�r
rrr�
_violation�szDirectorySandbox._violation�rcOsH|dkr5|j|�r5|jd||||�t||||�S)Nr��rtr�rU�Ur�)r�r�rr�r�)�_okr�r�)rDr%rr|r�rrrr��szDirectorySandbox._filecOsH|dkr5|j|�r5|jd||||�t||||�S)Nr�r�rr�r�r)r�r�rr�r�)r�r�r�)rDr%rr|r�rrrr��szDirectorySandbox._opencCs|jd�dS)Nr�)r�)rDrrrr��szDirectorySandbox.tmpnamcCss|j}zYd|_tjjtjj|��}|j|�p`||jkp`|j|j�SWd||_XdS)NF)	r�r/r%r�r��	_exemptedr�rNr�)rDr%�activer�rrrr��s		zDirectorySandbox._okcsT�fdd�|jD�}�fdd�|jD�}tj||�}t|�S)Nc3s|]}�j|�VqdS)N)rN)rO�	exception)�filepathrrrQ�sz-DirectorySandbox._exempted.<locals>.<genexpr>c3s!|]}tj|��VqdS)N)rerg)rOrh)r�rrrQ�s)r��_exception_patterns�	itertools�chain�any)rDr�Z
start_matchesZpattern_matches�
candidatesr)r�rr��s

zDirectorySandbox._exemptedcOsE||jkrA|j|�rA|j|tjj|�||�|S)zCalled for path inputs)�	write_opsr�r�r/r%r�)rDr�r%r|r�rrrr��s"zDirectorySandbox._remap_inputcOsC|j|�s |j|�r9|j|||||�||fS)z?Called for path pairs like rename, link, and symlink operations)r�r�)rDr�r�r�r|r�rrrr��s zDirectorySandbox._remap_pairi�cOsO|t@r6|j|�r6|jd|||||�tj|||||�S)zCalled for low-level os.open()zos.open)�WRITE_FLAGSr�r�r�r)rDr��flagsrr|r�rrrr�szDirectorySandbox.openN)r>r?r@rArz�fromkeysr�r��_EXCEPTIONSrsr�r�r�r�r�r�r�r�rrrrrr	�s 		
cCs"g|]}tt|d��qS)r)r�r�)rO�arrrr��s	r�z4O_WRONLY O_RDWR O_APPEND O_CREAT O_TRUNC O_TEMPORARYc@s7eZdZdZejd�j�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\}}}|jjt��S)N)r|�tmpl�formatr)rD�cmdr|�kwargsrrr�__str__�szSandboxViolation.__str__N)	r>r?r@rA�textwrap�dedent�lstripr�r�rrrrr
�s
)=r/rr+�operator�	functoolsr�re�
contextlibr5r�Zsetuptools.externrZsetuptools.extern.six.movesrrZpkg_resources.py31compatr(�platformrNZ$org.python.modules.posix.PosixModule�pythonrR�posixZPosixModuler�r�r�r��	NameErrorrr��distutils.errorsrr�__all__r �contextmanagerr$r&r.r3r7r4rCrWrUr\rdrir`rrr�r�r�r	�reduce�or_�splitr�r
rrrr�<module>s^


	
	wV

?>