Spade
Mini Shell
| Directory:~$ /lib/python3.6/site-packages/setuptools/__pycache__/ |
| [Home] [System Details] [Kill Me] |
3
J$�\�7�@s�ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl
mZddlm
Z
mZddlZejjd�r�ddljjjjZnejejZyeZWnek
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�Z7ej8ej9d)d*�d+j:�D��Z;Gd,d �d e
�Z<dS)/�N)�six)�builtins�map�java)�DistutilsError)�working_set�AbstractSandbox�DirectorySandbox�SandboxViolation� run_setupcCsJd}t||��}|j�}WdQRX|dkr.|}t||d�}t|||�dS)z.
Python 3 implementation of execfile.
�rbN�exec)�open�read�compiler
)�filename�globals�locals�mode�streamZscript�code�r�/usr/lib/python3.6/sandbox.py� _execfile#src
csDtjdd�}|dk r$|tjdd�<z
|VWd|tjdd�<XdS)N)�sys�argv)�repl�savedrrr� save_argv0s
rc
cs.tjdd�}z
|VWd|tjdd�<XdS)N)r�path)rrrr� save_path;s
r ccs4tjj|dd�tj}|t_z
dVWd|t_XdS)zL
Monkey-patch tempfile.tempdir with replacement, ensuring it exists
T)�exist_okN)�
pkg_resourcesZ
py31compat�makedirs�tempfileZtempdir)Zreplacementrrrr�
override_tempDs
r%ccs.tj�}tj|�z
|VWdtj|�XdS)N)�os�getcwd�chdir)�targetrrrr�pushdUs
r*c@seZdZdZedd��ZdS)�UnpickleableExceptionzP
An exception representing another Exception that could not be pickled.
cCsJytj|�tj|�fStk
rDddlm}|j||t|���SXdS)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�clsrrrr0ds
zUnpickleableException.dumpN)�__name__�
__module__�__qualname__�__doc__�staticmethodr0rrrrr+_sr+c@s(eZdZdZdd�Zdd�Zdd�ZdS) �ExceptionSaverz^
A Context Manager that will save an exception, serialized, and restore
it
later.
cCs|S)Nr)�selfrrr� __enter__xszExceptionSaver.__enter__cCs
|sdStj||�|_||_dS)NT)r+r0�_saved�_tb)r;r2r3�tbrrr�__exit__{s
zExceptionSaver.__exit__cCs6dt|�krdSttj|j�\}}tj|||j�dS)z"restore
and re-raise any
exceptionr=N)�varsrr,�loadsr=rZreraiser>)r;r2r3rrr�resume�szExceptionSaver.resumeN)r5r6r7r8r<r@rCrrrrr:rsr:c
#sVtjj��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.
Nc3s&|]}|�kr|jd�r|VqdS)z
encodings.N)�
startswith)�.0�mod_name)rrr� <genexpr>�szsave_modules.<locals>.<genexpr>)r�modules�copyr:�update�_clear_modulesrC)� saved_excZdel_modulesr)rr�save_modules�s
rMcCsxt|�D]}tj|=q
WdS)N)�listrrH)Zmodule_namesrFrrrrK�srKccs$tj�}z
|VWdtj|�XdS)N)r"�__getstate__�__setstate__)rrrr�save_pkg_resources_state�s
rQc,cs�tjj|d�}t��xt��ft�t��Nt��<t|��(t |��t
d�dVWdQRXWdQRXWdQRXWdQRXWdQRXWdQRXdS)NZtempZ
setuptools)r&r�joinrQrM�hide_setuptoolsr rr%r*�
__import__)� setup_dirZtemp_dirrrr�
setup_context�s
rVcCstjd�}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)rF�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[rrHrK)rHrrrrS�srScCs�tjjtjj|��}t|���y�|gt|�tjdd�<tjjd|�t j
�t jjdd��t
|t�rl|n|jtj��}t|��t|dd�}t||�WdQRXWn4tk
r�}z|jr�|jdrʂWYdd}~XnXWdQRXdS)z8Run a distutils
setup script, sandboxed in its
directoryNrcSs|j�S)N)Zactivate)Zdistrrr�<lambda>�szrun_setup.<locals>.<lambda>�__main__)�__file__r5)r&r�abspath�dirnamerVrNrr�insertr�__init__Z callbacks�append�
isinstance�str�encode�getfilesystemencodingr �dictr�
SystemExit�args)Zsetup_scriptrkrUZdunder_file�ns�vrrrr�s
c@s2eZdZdZdZdd�Zdd�Zdd�Zd d
�Zdd�Z d
d�Z
x$d9D]Zee
e�rFe
e�e�e<qFWd:dd�Zer~ede�Zede�Zx$d;D]Zee
e�r�ee�e�e<q�Wd)d*�Zx$d<D]Zee
e�r�ee�e�e<q�Wd-d.�Zx(d=D]
Zee
e��r�ee�e�e<�q�Wd1d2�Zd3d4�Zd5d6�Zd7d8�ZdS)>rzDWrap
'os' module and 'open()' builtin for virtualizing setup
scriptsFcs�fdd�tt�D��_dS)Ncs&g|]}|jd�rt�|�r|�qS)�_)rD�hasattr)rE�name)r;rr�
<listcomp>sz,AbstractSandbox.__init__.<locals>.<listcomp>)�dir�_os�_attrs)r;r)r;rrcszAbstractSandbox.__init__cCs&x
|jD]}tt|t||��qWdS)N)rt�setattrr&�getattr)r;�sourcerprrr�_copyszAbstractSandbox._copycCs(|j|�tr|jt_|jt_d|_dS)NT)rx�_filer�file�_openr�_active)r;rrrr<s
zAbstractSandbox.__enter__cCs$d|_trtt_tt_|jt�dS)NF)r|ryrrzr{rrxrs)r;�exc_type� exc_value� tracebackrrrr@s
zAbstractSandbox.__exit__c Cs|�|�SQRXdS)zRun
'func' under os
sandboxingNr)r;�funcrrr�runszAbstractSandbox.runcstt�����fdd�}|S)Ncs2|jr
|j�||f|�|�\}}�||f|�|�S)N)r|�_remap_pair)r;�src�dstrk�kw)rp�originalrr�wrap&sz3AbstractSandbox._mk_dual_path_wrapper.<locals>.wrap)rvrs)rpr�r)rpr�r�_mk_dual_path_wrapper#s
z%AbstractSandbox._mk_dual_path_wrapper�rename�link�symlinkNcs
�ptt�����fdd�}|S)Ncs*|jr|j�|f|�|�}�|f|�|�S)N)r|�_remap_input)r;rrkr�)rpr�rrr�4sz5AbstractSandbox._mk_single_path_wrapper.<locals>.wrap)rvrs)rpr�r�r)rpr�r�_mk_single_path_wrapper1sz'AbstractSandbox._mk_single_path_wrapperrzr�stat�listdirr(�chmod�chown�mkdir�remove�unlink�rmdir�utime�lchown�chroot�lstat� startfile�mkfifo�mknod�pathconf�accesscstt�����fdd�}|S)NcsB|jr2|j�|f|�|�}|j��|f|�|��S�|f|�|�S)N)r|r��
_remap_output)r;rrkr�)rpr�rrr�Isz4AbstractSandbox._mk_single_with_return.<locals>.wrap)rvrs)rpr�r)rpr�r�_mk_single_with_returnFs
z&AbstractSandbox._mk_single_with_return�readlink�tempnamcstt�����fdd�}|S)Ncs
�||�}|jr|j�|�S|S)N)r|r�)r;rkr�Zretval)rpr�rrr�Xs
z'AbstractSandbox._mk_query.<locals>.wrap)rvrs)rpr�r)rpr�r� _mk_queryUs
zAbstractSandbox._mk_queryr'�tmpnamcCs|S)z=Called to
remap or validate any path, whether input or
outputr)r;rrrr�_validate_pathdszAbstractSandbox._validate_pathcOs
|j|�S)zCalled for path
inputs)r�)r;� operationrrkr�rrrr�hszAbstractSandbox._remap_inputcCs
|j|�S)zCalled for path
outputs)r�)r;r�rrrrr�lszAbstractSandbox._remap_outputcOs0|j|d|f|�|�|j|d|f|�|�fS)z?Called
for path pairs like rename, link, and symlink
operationsz-fromz-to)r�)r;r�r�r�rkr�rrrr�pszAbstractSandbox._remap_pair)r�r�r�)N)r�r�r(rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�)r�r�)r'r�)r5r6r7r8r|rcrxr<r@r�r�rprorsrr�ryr{r�r�r�r�r�r�rrrrrsB
�devnullc@s�eZdZdZejdddddddd d
ddd
dg
�ZdgZefdd�Z dd�Z
erXd'dd�Zd(dd�Zdd�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$cCsFtjjtjj|��|_tjj|jd�|_dd�|D�|_tj |�dS)N�cSs
g|]}tjjtjj|���qSr)r&r�normcase�realpath)rErrrrrq�sz-DirectorySandbox.__init__.<locals>.<listcomp>)
r&rr�r��_sandboxrR�_prefix�_exceptionsrrc)r;Zsandbox�
exceptionsrrrrc�s
zDirectorySandbox.__init__cOsddlm}||||��dS)Nr)r
)r/r
)r;r�rkr�r
rrr�
_violation�szDirectorySandbox._violation�rcOs<|dkr*|j|�r*|jd||f|�|�t||f|�|�S)Nr��rtr�rU�Urz)r�r�rr�r�)�_okr�ry)r;rrrkr�rrrry�szDirectorySandbox._filecOs<|dkr*|j|�r*|jd||f|�|�t||f|�|�S)Nr�r�rr�r�r)r�r�rr�r�)r�r�r{)r;rrrkr�rrrr{�szDirectorySandbox._opencCs|jd�dS)Nr�)r�)r;rrrr��szDirectorySandbox.tmpnamcCsN|j}z:d|_tjjtjj|��}|j|�p@||jkp@|j|j�S||_XdS)NF) r|r&rr�r�� _exemptedr�rDr�)r;rZactiver�rrrr��s
zDirectorySandbox._okcs<�fdd�|jD�}�fdd�|jD�}tj||�}t|�S)Nc3s|]}�j|�VqdS)N)rD)rEZ exception)�filepathrrrG�sz-DirectorySandbox._exempted.<locals>.<genexpr>c3s|]}tj|��VqdS)N)rWrY)rErZ)r�rrrG�s)r��_exception_patterns� itertools�chain�any)r;r�Z
start_matchesZpattern_matchesZ
candidatesr)r�rr��s
zDirectorySandbox._exemptedcOs6||jkr2|j|�r2|j|tjj|�f|�|�|S)zCalled
for path
inputs)� write_opsr�r�r&rr�)r;r�rrkr�rrrr��szDirectorySandbox._remap_inputcOs6|j|�s|j|�r.|j|||f|�|�||fS)z?Called
for path pairs like rename, link, and symlink
operations)r�r�)r;r�r�r�rkr�rrrr��szDirectorySandbox._remap_pair�cOsB|t@r,|j|�r,|jd|||f|�|�tj|||f|�|�S)zCalled
for low-level
os.open()zos.open)�WRITE_FLAGSr�r�rsr)r;rz�flagsrrkr�rrrr�szDirectorySandbox.openN)r�)r�)r�)r5r6r7r8ri�fromkeysr�r��_EXCEPTIONSrcr�ryr{r�r�r�r�r�rrrrrr ~s
cCsg|]}tt|d��qS)r)rvrs)rE�arrrrq�srqz4O_WRONLY
O_RDWR O_APPEND O_CREAT O_TRUNC
O_TEMPORARYc@s&eZdZdZejd�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\}}}|jjft��S)N)rk�tmpl�formatr)r;�cmdrk�kwargsrrr�__str__�szSandboxViolation.__str__N) r5r6r7r8�textwrap�dedent�lstripr�r�rrrrr
�s
)N)N)=r&rr$�operator� functoolsr�rW�
contextlibr,r�Zsetuptools.externrZsetuptools.extern.six.movesrrZpkg_resources.py31compatr"�platformrDZ$org.python.modules.posix.PosixModule�pythonrH�posixZPosixModulersrprzry� NameErrorrr{Zdistutils.errorsrr�__all__r�contextmanagerrr
r%r*r.r+r:rMrKrQrVr[rSrrror�r�r �reduce�or_�splitr�r
rrrr�<module>s^
w
V