_d 8 ddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z ddl mZejj!drddlmcmcmcmZnej&ej.Z eZeZgdZddZej>ddZ ej>dZ!ej>d Z"ej>d Z#Gd d e$Z%Gd dZ&ej>dZ'dZ(ej>dZ)ej>dZ*hdZ+dZ,dZ-dZ.GddZ/e0edrejbgZ2ngZ2Gdde/Z3ejhejjdjmDcgc] }e7e|dc}Z8Gdde Z9y#e$rdZY3wxYwcc}w) N)DistutilsError) working_setjava)AbstractSandboxDirectorySandboxSandboxViolation run_setupcd}t||5}|j}ddd||}t|d}t|||y#1swY(xYw)z. Python 3 implementation of execfile. rbNexec)openreadcompiler )filenameglobalslocalsmodestreamscriptcodes 4/usr/lib/python3/dist-packages/setuptools/sandbox.py _execfiler$sY D h  ~ 68V ,Dw s AAc#Ktjdd}||tjdd ||tjddy#|tjddwxYwwN)sysargv)replsaveds r save_argvr1sJ HHQKE    e s)AAAAAc#Ktjdd} ||tjddy#|tjddwxYwwr)rpathrs r save_pathr#<s7 HHQKE  e sA/AAAc#Ktj|dtj}|t_ d|t_y#|t_wxYww)zL Monkey-patch tempfile.tempdir with replacement, ensuring it exists T)exist_okN)osmakedirstempfiletempdir) replacementrs r override_tempr+EsA KK d+   E"H!  5s3AA A AAc#Ktj}tj| |tj|y#tj|wxYwwr)r&getcwdchdir)targetrs rpushdr0Vs= IIKEHHV  s*A!AA!AA!c eZdZdZedZy)UnpickleableExceptionzP An exception representing another Exception that could not be pickled. c  tj|tj|fS#t$r*ddlm}|j ||t |cYSwxYw)z Always return a dumped (pickled) type and exc. If exc can't be pickled, wrap it in UnpickleableException first. r)r2)pickledumps Exceptionsetuptools.sandboxr2dumprepr)typeexcclss rr8zUnpickleableException.dumpesO  1<<%v||C'88 8 1 G88CT#Y0 0  1s),0AAN)__name__ __module__ __qualname____doc__ staticmethodr8rr2r2`s 1 1rCr2c"eZdZdZdZdZdZy)ExceptionSaverz^ A Context Manager that will save an exception, serialized, and restore it later. c|SrrBselfs r __enter__zExceptionSaver.__enter__zs rCcN|sytj|||_||_yNT)r2r8_saved_tb)rHr:r;tbs r__exit__zExceptionSaver.__exit__}s* ,00s; rCcdt|vryttj|j\}}|j |j )z"restore and re-raise any exceptionrLN)varsmapr4loadsrLwith_tracebackrM)rHr:r;s rresumezExceptionSaver.resumes@ 4: %  dkk2 c  **rCN)r=r>r?r@rIrOrUrBrCrrErEts  +rCrEc#6Ktjjt5}dddtjj fdtjD}t |j y#1swY]xYww)z Context in which imported modules are saved. Translates exceptions internal to the context into the equivalent exception outside the context. Nc3LK|]}|vr|jds|yw)z encodings.N startswith).0mod_namers r zsave_modules..s/  5 ##L1 s!$)rmodulescopyrEupdate_clear_modulesrU) saved_exc del_modulesrs @r save_modulesrcsy KK   E  Y KKu K; s)BB AB BBcFt|D]}tj|=yr)listrr]) module_namesr[s rr`r`s"&" KK !"rCc#Ktj} |tj|y#tj|wxYwwr) pkg_resources __getstate__ __setstate__r"s rsave_pkg_resources_staterks:  & & (E* ""5) ""5)sA 2A A  A c #Ktjj|d}t5t 5t 5t t5t|5t|5tddddddddddddddddddddy#1swY2xYw#1swY6xYw#1swY:xYw#1swY>xYw#1swYBxYw#1swYyxYww)Ntemp setuptools) r&r!joinrkrcr#hide_setuptoolsrr+r0 __import__) setup_dirtemp_dirs r setup_contextrtsww||Iv.H ! # " ^ " "!["&x0""9-"&|4!""" " " " " """""" " " " " " "s+C9 C- C!C C $ B= 0B1 B= C CC! C-( C91B:6B= =CC C CC C!!C* &C--C62C9>Cython distutilsrnrh_distutils_hackc<|jddd}|tvS)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)r[ base_modules r _needs_hidingr~s%"..a(+K * **rCctjjdd}||jt t tj}t |y)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. rwN)rr]get _remove_shimfilterr~r`)rwr]s rrprpsCkkoo&7>O"$$&]CKK0G7rCc|tjjtjj|}t |5 |gt |zt jddt jjd|tjtjjdt|5t|d}t||ddddddy#1swYxYw#t $r&}|j"r|j"drYd}~?d}~wwxYw#1swYyxYw)z8Run a distutils setup script, sandboxed in its directoryNrc"|jSr)activate)dists rzrun_setup..s dmmorC__main__)__file__r=)r&r!abspathdirnamertrerrinsertr__init__ callbacksappendrdictr SystemExitargs) setup_scriptrrrnsvs rr r s =>I y !  '.4:5CHHQK HHOOAy )  "  ! ! ( ()E F!), ,<*E,+ ,   , , vv!&&)   sID2 A?D C4#D4C= 9D D/ D*%D2*D//D22D;ceZdZdZdZdZdZdZdZdZ dZ d D]Z e e e s e e ee <dd Zer ed eZed eZdD]Z e e e s ee ee <dZdD]Z e e e s ee ee <dZdD]Z e e e s ee ee <dZdZdZdZy )rzDWrap 'os' module and 'open()' builtin for virtualizing setup scriptsFcttDcgc]!}|jdst||r|#c}|_ycc}w)N_)dir_osrYhasattr_attrs)rHnames rrzAbstractSandbox.__init__s<C ??3'GD$,?    s&Ac \|jD]}tt|t||yr)rsetattrr&getattr)rHsourcers r_copyzAbstractSandbox._copys(KK 5D Bgfd3 4 5rCc|j|tr|jt_|jt_d|_yrK)r_filebuiltinsfile_openr _activerGs rrIzAbstractSandbox.__enter__s. 4  JJHM   rCcd|_trtt_tt_|j tyNF)rrrrrr rr)rHexc_type exc_value tracebacks rrOzAbstractSandbox.__exit__!s% !HM  3rCc@|5|cdddS#1swYyxYw)zRun 'func' under os sandboxingNrB)rHfuncs rrunzAbstractSandbox.run(s  6   sc6ttfd}|S)Ncl|jr|j||g|i|\}}||g|i|Sr)r _remap_pair)rHsrcdstrkwroriginals rwrapz3AbstractSandbox._mk_dual_path_wrapper..wrap0sE||+4++D#sHTHRHSC2t2r2 2rCrrrrrs` @r_mk_dual_path_wrapperz%AbstractSandbox._mk_dual_path_wrapper-s3% 3  rC)renamelinksymlinkNc>xsttfd}|S)Ncb|jr|j|g|i|}|g|i|Sr)r _remap_inputrHr!rrrrs rrz5AbstractSandbox._mk_single_path_wrapper..wrap>s=||(t((tAdAbAD.4.2. .rCr)rrrs`` r_mk_single_path_wrapperz'AbstractSandbox._mk_single_path_wrapper;s 1wsD1 /  rCrr )statlistdirr.r chmodchownmkdirremoveunlinkrmdirutimelchownchrootlstat startfilemkfifomknodpathconfaccessc6ttfd}|S)Nc|jr3|j|g|i|}|j|g|i|S|g|i|Sr)rr _remap_outputrs rrz4AbstractSandbox._mk_single_with_return..wrapcs_||(t((tAdAbA))$0K0K0KLLD.4.2. .rCrrs` @r_mk_single_with_returnz&AbstractSandbox._mk_single_with_return`s3% /  rC)readlinktempnamc6ttfd}|S)NcT|i|}|jr|j|S|Sr)rr)rHrrretvalrrs rrz'AbstractSandbox._mk_query..wraprs1t*r*F||))$77MrCrrs` @r _mk_queryzAbstractSandbox._mk_queryos3%   rC)r-tmpnamc|S)z=Called to remap or validate any path, whether input or outputrB)rHr!s r_validate_pathzAbstractSandbox._validate_path~s rCc$|j|SzCalled for path inputsrrH operationr!rrs rrzAbstractSandbox._remap_input""4((rCc$|j|S)zCalled for path outputsr)rHrr!s rrzAbstractSandbox._remap_outputrrCcj|j|dz|g|i||j|dz|g|i|fS)?Called for path pairs like rename, link, and symlink operationsz-fromz-to)rrHrrrrrs rrzAbstractSandbox._remap_pairsP D  i'13 D D D D  i%/ Bt Br B  rCr)r=r>r?r@rrrrIrOrrrrrrrrrrrrrrrrBrCrrr sNG 5 .9 3 248FHTN9 '6 #FE 2E;* 3 4T:FHTN-;0 (: 3 3D9FHTN: %- 3 &t_FHTN-)) rCrdevnullceZdZdZej gdZgZ efdZ dZ e rddZ ddZ dZ dZd Zd Zd Zdd Zy )rz}tjjtjj|@c}|_tj|ycc}w)N) r&r!normcaserealpath_sandboxro_prefix _exceptionsrr)rHsandbox exceptionsr!s rrzDirectorySandbox.__init__s(()9)9')BC ww||DMM26 AK 9=BGG  RWW--d3 4    & s5ACc"ddlm}||||)Nr)r)r7r)rHrrrrs r _violationzDirectorySandbox._violations7y$33rCc||dvr)|j|s|jd||g|i|t||g|i|S)Nrrtr rUUr)_okrrrHr!rrrs rrzDirectorySandbox._filesH77d@T@R@t1d1b1 1rCc||dvr)|j|s|jd||g|i|t||g|i|S)Nrr )rrrrs rrzDirectorySandbox._opensH 3 3DHHTN DOOFD$ < < <T4-$-"--rCc&|jdy)Nr)rrGs rrzDirectorySandbox.tmpnams !rCcH|j} d|_tjjtjj |}|j |xs,||j k(xs|j|j ||_S#||_wxYwr) rr&r!rr _exemptedrrYr)rHr!activers rrzDirectorySandbox._oks " DLww''(8(8(>?Hx(5t}},5&&t||4  "DL6DLs BB B!cfd|jD}fd|jD}tj||}t |S)Nc3@K|]}j|ywrrX)rZ exceptionfilepaths rr\z-DirectorySandbox._exempted..s! /8H   * sc3JK|]}tj|ywr)rematch)rZpatternr s rr\z-DirectorySandbox._exempted..s! ,3BHHWh ' s #)r_exception_patterns itertoolschainany)rHr  start_matchespattern_matches candidatess ` rrzDirectorySandbox._exemptedsI <@r?r@rfromkeysrr _EXCEPTIONSrrrrrrrrrr rBrCrrrs]F  I$4+6'4   2 . " "  8rCrz4O_WRONLY O_RDWR O_APPEND O_CREAT O_TRUNC O_TEMPORARYcVeZdZdZej dj ZdZy)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. cj|j\}}}|jjditS)NrB)rtmplformatr)rHcmdrkwargss r__str__zSandboxViolation.__str__s. IIT6tyy+&(++rCN) r=r>r?r@textwrapdedentlstriprr#rBrCrrrs+O 8??   fh ,rCrr):r&rr(operator functoolsrr  contextlibr4r$rrhdistutils.errorsrrplatformrY$org.python.modules.posix.PosixModulepythonr]posix PosixModulerrrr NameErrorr r__all__rcontextmanagerrr#r+r0r6r2rErcr`rkrtr|r~rpr rrrrrreduceor_r{rrr)as0rr6s   +%<<6"66 ++bgg C E        ! !  1I1(++< 2"  **  " "+* (E E P 2y::,KK[8[8|i LLHMMO  Q ,~,Q EBsF- F; -F87F8