N3{Y '@sddlZddlZddlZddlZddlZddlZddlZddlZejdkrddl j j j j Znej ejZy eZWnek rdZYnXeZddlmZddlmZddlmZmZdddd gZd d ZGd ddZeed rJejgZngZy'dd l m!Z!ej"e![!Wne#k rYnXGdddeZ$ej%ej&dddj'DZ(GdddeZ)dS)Njava)DistutilsError) working_set)builtinsexecfileAbstractSandboxDirectorySandboxSandboxViolation run_setupc stj}tjdd}tjdd}tjjtjj}tjj|d}tjj|stj |nt j }tj j tj}z|t _ tj|yvgt|tjddtk rztjd} | jrv| jdrvnYnXWdtj|tj jfdd tj D} tttj j| tj||tjdd<|tjdd<|t _ XdS) z8Run a distutils setup script, sandboxed in its directoryNtemprcSs |jS)N)activate)distr-/tmp/pip-r2rszybt-build/setuptools/sandbox.py0szrun_setup..cstdid6dd6S)Nzsetup.py__file____main____name__)rr) setup_scriptrrr2scs2g|](}|kr|jd r|qS)z encodings.) startswith).0Zmod_name) save_modulesrr As  zrun_setup..) osgetcwdsysargvpathabspathdirnamejoinisdirmakedirstempfiletempdirmodulescopy pkg_resources __getstate__chdirlistinsertr__init__ callbacksappendrrun SystemExitexc_infoargs __setstate__updatemap __delitem__) rr3Zold_dir save_argvZ save_pathZ setup_dirtemp_dirZsave_tmpZpr_statevZ del_modulesr)rrrr s@           c@seZdZdZdZddZddZddZd d Zx<d d d gD]+Z e e e rXee e e .)dir_os_attrs)r>r)r>rr-RszAbstractSandbox.__init__cCs1x*|jD]}tt|t||q WdS)N)rAsetattrrgetattr)r>sourcer=rrr_copyXszAbstractSandbox._copyc Cs{zB|j|tr%|jt_n|jt_d|_|SWdd|_tr`tt_ntt_|jtXdS)zRun 'func' under os sandboxingTNF)rE_filerfile_openopen_activer@)r>funcrrrr0\s       zAbstractSandbox.runcs(ttfdd}|S)Ncs@|jr-|j||||\}}n||||S)N)rJ _remap_pair)r>srcdstr3kw)r=originalrrwrapns $z3AbstractSandbox._mk_dual_path_wrapper..wrap)rCr@)r=rQr)r=rPr_mk_dual_path_wrapperlsz%AbstractSandbox._mk_dual_path_wrapperrenamelinksymlinkNcs.pttfdd}|S)Ncs4|jr$|j|||}n|||S)N)rJ _remap_input)r>rr3rO)r=rPrrrQys z5AbstractSandbox._mk_single_path_wrapper..wrap)rCr@)r=rPrQr)r=rPr_mk_single_path_wrapperwsz'AbstractSandbox._mk_single_path_wrapperrGrIstatlistdirr*chmodchownmkdirremoveunlinkrmdirutimelchownchrootlstatZ startfilemkfifomknodpathconfaccesscs(ttfdd}|S)NcsM|jr=|j|||}|j|||S|||S)N)rJrV _remap_output)r>rr3rO)r=rPrrrQs z4AbstractSandbox._mk_single_with_return..wrap)rCr@)r=rQr)r=rPr_mk_single_with_returnsz&AbstractSandbox._mk_single_with_returnreadlinktempnamcs(ttfdd}|S)Ncs,||}|jr(|j|S|S)N)rJrh)r>r3rOretval)r=rPrrrQs z'AbstractSandbox._mk_query..wrap)rCr@)r=rQr)r=rPr _mk_queryszAbstractSandbox._mk_queryrtmpnamcCs|S)z=Called to remap or validate any path, whether input or outputr)r>rrrr_validate_pathszAbstractSandbox._validate_pathcOs |j|S)zCalled for path inputs)ro)r> operationrr3rOrrrrVszAbstractSandbox._remap_inputcCs |j|S)zCalled for path outputs)ro)r>rprrrrrhszAbstractSandbox._remap_outputcOs6|j|d||||j|d|||fS)z?Called for path pairs like rename, link, and symlink operationsz-fromz-to)rV)r>rprMrNr3rOrrrrLszAbstractSandbox._remap_pair)r __module__ __qualname____doc__rJr-rEr0rRr=r<r@localsrWrFrHrirmrorVrhrLrrrrrMs>          devnull)GetGeneratePathc@seZdZdZejdddddddd d d d d dg ZdgZeddZ ddZ e rdddZ ndddZ ddZ ddZddZdd Zd!d"Zd#d$d%Zd&S)'rz.) rrrxry_sandboxr!_prefix _exceptionsrr-)r>Zsandbox exceptionsrrrr-s !  zDirectorySandbox.__init__cOst|||dS)N)r )r>rpr3rOrrr _violationszDirectorySandbox._violationrcOsK|dkr8|j| r8|jd||||nt||||S)NrrtrbrUUrG)rzrtzrbzrUr)_okr~rF)r>rmoder3rOrrrrFszDirectorySandbox._filecOsK|dkr8|j| r8|jd||||nt||||S)NrrrrrrI)rzrtzrbzrUr)rr~rH)r>rrr3rOrrrrHszDirectorySandbox._opencCs|jddS)Nrn)r~)r>rrrrnszDirectorySandbox.tmpnamc Css|j}zYd|_tjjtjj|}|j|p`||jkp`|j|jSWd||_XdS)NF) rJrrrxry _exemptedrzrr{)r>rZactiveryrrrrs  zDirectorySandbox._okcsTfdd|jD}fdd|jD}tj||}t|S)Nc3s|]}j|VqdS)N)r)r exception)filepathrr sz-DirectorySandbox._exempted..c3s!|]}tj|VqdS)N)rematch)rpattern)rrrrs)r|_exception_patterns itertoolschainany)r>rZ start_matchesZpattern_matchesZ candidatesr)rrrs   zDirectorySandbox._exemptedcOsH||jkrD|j| rD|j|tjj|||n|S)zCalled for path inputs) write_opsrr~rrry)r>rprr3rOrrrrVs%zDirectorySandbox._remap_inputcOsF|j| s |j| r<|j|||||n||fS)z?Called for path pairs like rename, link, and symlink operations)rr~)r>rprMrNr3rOrrrrL s zDirectorySandbox._remap_pairicOsR|t@r9|j| r9|jd|||||ntj|||||S)zCalled for low-level os.open()zos.open) WRITE_FLAGSrr~r@rI)r>rGflagsrr3rOrrrrIszDirectorySandbox.openN)rrqrrrsdictfromkeysrr _EXCEPTIONSr-r~rFrHrnrrrVrLrIrrrrrs      cCs"g|]}tt|dqS)r)rCr@)rarrrrs rz4O_WRONLY O_RDWR O_APPEND O_CREAT O_TRUNC O_TEMPORARYc@s"eZdZdZddZdS)r zEA setup script attempted to modify the filesystem outside the sandboxcCs d|jS)NaSandboxViolation: %s%r %s 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.)r3)r>rrr__str__s zSandboxViolation.__str__N)rrqrrrsrrrrrr s )*rrr$operator functoolsrrr(r=Z$org.python.modules.posix.PosixModulepythonr&posixZ PosixModuler@rGrF NameErrorrIrHdistutils.errorsrrZsetuptools.compatrr__all__r rr<rurZwin32com.client.gencachervr/ ImportErrorrreduceor_splitrr rrrrsF            0h S