Viewing File: /opt/alt/python38/lib/python3.8/site-packages/setuptools/__pycache__/sandbox.cpython-38.pyc

U

+aG7@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl	Z	ddl
Z
ddlZddlm
Z
ddlmZejdrddlmmmmZnejejZzeZWnek
rdZYnXeZddddgZd0d	d
Zejd1ddZ ejd
dZ!ejddZ"ejddZ#Gddde$Z%GdddZ&ejddZ'ddZ(ejddZ)ejddZ*dd d!d"d#hZ+d$d%Z,d&d'Z-d(dZ.Gd)ddZ/e0ed*rej1gZ2ngZ2Gd+dde/Z3e4ej5d,d-d.6DZ7Gd/dde
Z8dS)2N)DistutilsError)working_setjavaAbstractSandboxDirectorySandboxSandboxViolation	run_setupc	CsJd}t||}|}W5QRX|dkr.|}t||d}t|||dS)z.
    Python 3 implementation of execfile.
    rbNexec)openreadcompiler
)filenameglobalslocalsmodestreamscriptcoder:/tmp/pip-install-1bd_1mtk/setuptools/setuptools/sandbox.py	_execfile!src
csDtjdd}|dk	r$|tjdd<z
|VW5|tjdd<XdSN)sysargv)replsavedrrr	save_argv.s
rc
cs.tjdd}z
|VW5|tjdd<XdSr)rpathrrrr	save_path9s
r ccs2tj|ddtj}|t_z
dVW5|t_XdS)zL
    Monkey-patch tempfile.tempdir with replacement, ensuring it exists
    T)exist_okN)osmakedirstempfiletempdir)replacementrrrr
override_tempBs
r'c	cs.t}t|z
|VW5t|XdSr)r"getcwdchdir)targetrrrrpushdSs


r+c@seZdZdZeddZdS)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)pickledumps	Exceptionsetuptools.sandboxr,dumprepr)typeexcclsrrrr1bs
zUnpickleableException.dumpN)__name__
__module____qualname____doc__staticmethodr1rrrrr,]sr,c@s(eZdZdZddZddZddZdS)	ExceptionSaverz^
    A Context Manager that will save an exception, serialized, and restore it
    later.
    cCs|Srrselfrrr	__enter__vszExceptionSaver.__enter__cCs |sdSt|||_||_dSNT)r,r1_saved_tb)r=r3r4tbrrr__exit__ys
zExceptionSaver.__exit__cCs2dt|krdSttj|j\}}||jdS)z"restore and re-raise any exceptionr@N)varsmapr-loadsr@with_tracebackrA)r=r3r4rrrresumeszExceptionSaver.resumeN)r6r7r8r9r>rCrHrrrrr;psr;c	#sVtjt}VW5QRXtjfddtjD}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|ds|VqdS)z
encodings.N
startswith).0mod_namerrr	<genexpr>s
zsave_modules.<locals>.<genexpr>N)rmodulescopyr;update_clear_modulesrH)	saved_excZdel_modulesrrrsave_moduless

rScCst|D]}tj|=qdSr)listrrN)Zmodule_namesrLrrrrQsrQc	cs$t}z
|VW5t|XdSr)
pkg_resources__getstate____setstate__rrrrsave_pkg_resources_states
rXccstj|d}txtftTtt<t|(t	|t
ddVW5QRXW5QRXW5QRXW5QRXW5QRXW5QRXdS)Ntemp
setuptools)r"rjoinrXrSr hide_setuptoolsrr'r+
__import__)	setup_dirtemp_dirrrr
setup_contexts

r`rZ	distutilsrUZCython_distutils_hackcCs|ddd}|tkS)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)rLbase_modulerrr
_needs_hidingsrhcCs6tjdd}|dk	r|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)rrNgetZremove_shimfilterrhrQ)rbrNrrrr\s
r\cCstjtj|}t|zl|gt|tjdd<tjd|t	
t	jddt
|t|dd}t||W5QRXWn4tk
r}z|jr|jdrW5d}~XYnXW5QRXdS)z8Run a distutils setup script, sandboxed in its directoryNrcSs|Sr)activate)distrrr<lambda>zrun_setup.<locals>.<lambda>__main__)__file__r6)r"rabspathdirnamer`rTrrinsertr__init__	callbacksappendrdictr
SystemExitargs)Zsetup_scriptryr^nsvrrrrs

c@seZdZdZdZddZddZddZd	d
ZddZ	d
dZ
dD]Zee
erDe
eee<qDd$ddZerzedeZedeZdD]Zee
ereeee<qddZdD]Zee
ereeee<qddZdD]Zee
ereeee<qddZddZd d!Zd"d#ZdS)%rzDWrap 'os' module and 'open()' builtin for virtualizing setup scriptsFcsfddttD_dS)Ncs$g|]}|dst|r|qS)_)rJhasattr)rKnamer<rr
<listcomp>s

z,AbstractSandbox.__init__.<locals>.<listcomp>)dir_os_attrsr<rr<rrt
s
zAbstractSandbox.__init__cCs"|jD]}tt|t||qdSr)rsetattrr"getattr)r=sourcer~rrr_copys
zAbstractSandbox._copycCs(||tr|jt_|jt_d|_dSr?)r_filebuiltinsfile_openr_activer<rrrr>s

zAbstractSandbox.__enter__cCs$d|_trtt_tt_|tdSNF)rrrrrrrr)r=exc_type	exc_value	tracebackrrrrCs
zAbstractSandbox.__exit__c
Cs"||W5QRSQRXdS)zRun 'func' under os sandboxingNr)r=funcrrrrun"szAbstractSandbox.runcsttfdd}|S)Ncs2|jr |j||f||\}}||f||Sr)r_remap_pair)r=srcdstrykwr~originalrrwrap*sz3AbstractSandbox._mk_dual_path_wrapper.<locals>.wraprrr~rrrr_mk_dual_path_wrapper's
z%AbstractSandbox._mk_dual_path_wrapper)renamelinksymlinkNcs pttfdd}|S)Ncs*|jr|j|f||}|f||Sr)r_remap_inputr=rryrrrrr8sz5AbstractSandbox._mk_single_path_wrapper.<locals>.wrapr)r~rrrrr_mk_single_path_wrapper5sz'AbstractSandbox._mk_single_path_wrapperrr)statlistdirr)rchmodchownmkdirremoveunlinkrmdirutimelchownchrootlstatZ	startfilemkfifomknodpathconfaccesscsttfdd}|S)NcsB|jr2|j|f||}||f||S|f||Sr)rr
_remap_outputrrrrrMsz4AbstractSandbox._mk_single_with_return.<locals>.wraprrrrr_mk_single_with_returnJs
z&AbstractSandbox._mk_single_with_return)readlinktempnamcsttfdd}|S)Ncs ||}|jr||S|Sr)rr)r=ryrretvalrrrr\s
z'AbstractSandbox._mk_query.<locals>.wraprrrrr	_mk_queryYs
zAbstractSandbox._mk_query)r(tmpnamcCs|S)z=Called to remap or validate any path, whether input or outputr)r=rrrr_validate_pathhszAbstractSandbox._validate_pathcOs
||SzCalled for path inputsrr=	operationrryrrrrrlszAbstractSandbox._remap_inputcCs
||S)zCalled for path outputsr)r=rrrrrrpszAbstractSandbox._remap_outputcOs0|j|d|f|||j|d|f||fS)?Called for path pairs like rename, link, and symlink operationsz-fromz-to)rr=rrrryrrrrrtszAbstractSandbox._remap_pair)N)r6r7r8r9rrtrr>rCrrr~r}rrrrrrrrrrrrrrrrs<








devnullc@seZdZdZedddddddd	d
ddd
dg
ZdgZefddZ	ddZ
erXd'ddZd(ddZddZ
ddZddZdd Zd!d"Zd)d$d%Zd&S)*rz<Restrict operations to a single subdirectory - pseudo-chrootrrrrrrrrrrrrrz.*lib2to3.*\.pickle$cCsFtjtj||_tj|jd|_dd|D|_t	|dS)NcSs g|]}tjtj|qSr)r"rnormcaserealpath)rKrrrrrsz-DirectorySandbox.__init__.<locals>.<listcomp>)
r"rrr_sandboxr[_prefix_exceptionsrrt)r=Zsandbox
exceptionsrrrrtszDirectorySandbox.__init__cOsddlm}||||dS)Nr)r)r0r)r=rryrrrrr
_violationszDirectorySandbox._violationrcOs:|dkr(||s(|jd||f||t||f||S)Nrrtr	ZrUUr)_okrrr=rrryrrrrrszDirectorySandbox._filecOs:|dkr(||s(|jd||f||t||f||S)Nrr)rrrrrrrrszDirectorySandbox._opencCs|ddS)Nr)rr<rrrrszDirectorySandbox.tmpnamcCsR|j}z>d|_tjtj|}||p@||jkp@||jWS||_XdSr)	rr"rrr	_exemptedrrJr)r=ractiverrrrrs

zDirectorySandbox._okcs<fdd|jD}fdd|jD}t||}t|S)Nc3s|]}|VqdSrrI)rK	exceptionfilepathrrrMsz-DirectorySandbox._exempted.<locals>.<genexpr>c3s|]}t|VqdSr)rematch)rKpatternrrrrMs)r_exception_patterns	itertoolschainany)r=rZ
start_matchesZpattern_matches
candidatesrrrrs

zDirectorySandbox._exemptedcOs4||jkr0||s0|j|tj|f|||Sr)	write_opsrrr"rrrrrrrszDirectorySandbox._remap_inputcOs2||r||s*|j|||f||||fS)r)rrrrrrrszDirectorySandbox._remap_paircOs@|t@r*||s*|jd|||f||tj|||f||S)zCalled for low-level os.open()zos.open)WRITE_FLAGSrrrr)r=rflagsrryrrrrrszDirectorySandbox.openN)r)r)r)r6r7r8r9rwfromkeysrr_EXCEPTIONSrtrrrrrrrrrrrrrrs:	


cCsg|]}tt|dqS)rr)rKarrrrsrz4O_WRONLY O_RDWR O_APPEND O_CREAT O_TRUNC O_TEMPORARYc@s&eZdZdZedZddZdS)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\}}}|jjftSr)rytmplformatr)r=cmdrykwargsrrr__str__szSandboxViolation.__str__N)	r6r7r8r9textwrapdedentlstriprrrrrrrs)N)N)9r"rr$operator	functoolsrr
contextlibr-rrrUdistutils.errorsrrplatformrJZ$org.python.modules.posix.PosixModulepythonrNposixZPosixModulerr~rr	NameErrorrr__all__rcontextmanagerrr r'r+r/r,r;rSrQrXr`rfrhr\rrr}rrrreduceor_rerrrrrr<module>s 






	


	w
V
Back to Directory File Manager