Re8 @sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl m Z ddl m Z mZddlZejjdrddljjjjZnejejZy eZWnek r dZYnXeZddlm Z ddlm!Z!ddd d gZ"dd d Z#ej$dd dZ%ej$ddZ&ej$ddZ'ej$ddZ(Gddde)Z*GdddZ+ej$ddZ,ddZ-ej$ddZ.ej$dd Z/d!d"Z0d#d$Z1d%d Z2Gd&ddZ3e4ed'rsej5gZ6ngZ6Gd(dde3Z7ej8ej9d)d*d+j:DZ;Gd,d d e Z<dS)-N)six)builtinsmapjava)DistutilsError) working_setAbstractSandboxDirectorySandboxSandboxViolation run_setupc Csd}t||}|j}WdQRXtjddd ksvtjddd krtjddd kr|jdd}|jd d}|dkr|}t||d }t|||dS)z. Python 3 implementation of execfile. rbNrs s s exec)r r)rr)rr )openreadsys version_inforeplacecompiler)filenameglobalslocalsmodestreamscriptcoder/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|tjddtk 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)pickledumps Exceptionsetuptools.sandboxr4dumprepr)typeexcclsrrrr9hs   zUnpickleableException.dumpN)__name__ __module__ __qualname____doc__ staticmethodr9rrrrr4cs r4c@s:eZdZdZddZddZddZdS) 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|||jdS)z"restore and re-raise any exceptionrFN)varsrr5loadsrFrreraiserG)rDr;r<rrrresumeszExceptionSaver.resumeN)r>r?r@rArErIrMrrrrrCvs   rCc #sktjjt }VWdQRXtjjfddtjD}t||jdS)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).0mod_name)r#rr s zsave_modules..)rmodulescopyrCupdate_clear_modulesrM) saved_excZ del_modulesr)r#r save_moduless   rWcCs%xt|D]}tj|=q WdS)N)listrrR) module_namesrPrrrrUsrUc cs*tj}z |VWdtj|XdS)N)r( __getstate__ __setstate__)r#rrrsave_pkg_resources_states  r\c,cstjj|d}tvtettMt<t|(t |t ddVWdQRXWdQRXWdQRXWdQRXWdQRXWdQRXdS)Ntemp setuptools) r/r%joinr\rWhide_setuptoolsr&r$r.r3 __import__) setup_dirtemp_dirrrr setup_contexts       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)(\.|$))rerboolmatch)rPpatternrrr _needs_hidingsricCs 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|tjddtk r"}z|jr|jdrWYdd}~XnXWdQRXdS)z8Run a distutils setup script, sandboxed in its directoryNrcSs |jS)N)activate)distrrrszrun_setup..__file__r>__main__)r/r%abspathdirnamerdrXrr!insertr__init__ callbacksappend isinstancestrencodegetfilesystemencodingr dictr SystemExitargs)Z setup_scriptr|rbZ dunder_filensvrrrr s    c@seZdZdZdZddZddZddZd d Zd d Z d dZ x9dddgD](Z e e e rpe e ee s z,AbstractSandbox.__init__..)dir_os_attrs)rDr)rDrrs szAbstractSandbox.__init__cCs1x*|jD]}tt|t||q WdS)N)rsetattrr/getattr)rDsourcerrrr_copyszAbstractSandbox._copycCs8|j|tr|jt_|jt_d|_dS)NT)r_filerfile_openr_active)rDrrrrEs    zAbstractSandbox.__enter__cCs2d|_trtt_tt_|jtdS)NF)rrrrrrrr)rDexc_type exc_value tracebackrrrrIs    zAbstractSandbox.__exit__c Cs| |SWdQRXdS)zRun 'func' under os sandboxingNr)rDfuncrrrrun"szAbstractSandbox.runcs(ttfdd}|S)Ncs=|jr*|j||||\}}||||S)N)r _remap_pair)rDsrcdstr|kw)roriginalrrwrap*s !z3AbstractSandbox._mk_dual_path_wrapper..wrap)rr)rrr)rrr_mk_dual_path_wrapper'sz%AbstractSandbox._mk_dual_path_wrapperrenamelinksymlinkNcs.pttfdd}|S)Ncs1|jr!|j|||}|||S)N)r _remap_input)rDr%r|r)rrrrr8s z5AbstractSandbox._mk_single_path_wrapper..wrap)rr)rrrr)rrr_mk_single_path_wrapper5sz'AbstractSandbox._mk_single_path_wrapperrrstatlistdirr1chmodchownmkdirremoveunlinkrmdirutimelchownchrootlstatZ startfilemkfifomknodpathconfaccesscs(ttfdd}|S)NcsM|jr=|j|||}|j|||S|||S)N)rr _remap_output)rDr%r|r)rrrrrMs z4AbstractSandbox._mk_single_with_return..wrap)rr)rrr)rrr_mk_single_with_returnJsz&AbstractSandbox._mk_single_with_returnreadlinktempnamcs(ttfdd}|S)Ncs,||}|jr(|j|S|S)N)rr)rDr|rretval)rrrrr\s z'AbstractSandbox._mk_query..wrap)rr)rrr)rrr _mk_queryYszAbstractSandbox._mk_queryr0tmpnamcCs|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|rrrrrlszAbstractSandbox._remap_inputcCs |j|S)zCalled for path outputs)r)rDrr%rrrrpszAbstractSandbox._remap_outputcOs6|j|d||||j|d|||fS)z?Called for path pairs like rename, link, and symlink operationsz-fromz-to)r)rDrrrr|rrrrrtszAbstractSandbox._remap_pair)r>r?r@rArrsrrErIrrrrrrrrrrrrrrrrrrrrsB             devnullc@seZdZdZejdddddddd d d d d dg ZdgZeddZ ddZ e rdddZ dddZ ddZ ddZddZdd Zd!d"Zd#d$d%Zd&S)'r z.) r/r%rr_sandboxr__prefix _exceptionsrrs)rDZsandbox exceptionsrrrrss !  zDirectorySandbox.__init__cOs&ddlm}||||dS)Nr)r )r8r )rDrr|rr rrr _violationszDirectorySandbox._violationrcOsH|dkr5|j| r5|jd||||t||||S)Nrrtr rUUr)rrr rr)_okrr)rDr%rr|rrrrrszDirectorySandbox._filecOsH|dkr5|j| r5|jd||||t||||S)Nrrr rrr)rrr rr)rrr)rDr%rr|rrrrrszDirectorySandbox._opencCs|jddS)Nr)r)rDrrrrszDirectorySandbox.tmpnamc Css|j}zYd|_tjjtjj|}|j|p`||jkp`|j|jSWd||_XdS)NF) rr/r%rr _exemptedrrNr)rDr%activerrrrrs  zDirectorySandbox._okcsTfdd|jD}fdd|jD}tj||}t|S)Nc3s|]}j|VqdS)N)rN)rO exception)filepathrrrQsz-DirectorySandbox._exempted..c3s!|]}tj|VqdS)N)rerg)rOrh)rrrrQs)r_exception_patterns itertoolschainany)rDrZ start_matchesZpattern_matches candidatesr)rrrs   zDirectorySandbox._exemptedcOsE||jkrA|j| rA|j|tjj||||S)zCalled for path inputs) write_opsrrr/r%r)rDrr%r|rrrrrs"zDirectorySandbox._remap_inputcOsC|j| s |j| r9|j|||||||fS)z?Called for path pairs like rename, link, and symlink operations)rr)rDrrrr|rrrrrs zDirectorySandbox._remap_pairicOsO|t@r6|j| r6|jd|||||tj|||||S)zCalled for low-level os.open()zos.open) WRITE_FLAGSrrrr)rDrflagsrr|rrrrrszDirectorySandbox.openN)r>r?r@rArzfromkeysrr _EXCEPTIONSrsrrrrrrrrrrrrrr s      cCs"g|]}tt|dqS)r)rr)rOarrrrs rz4O_WRONLY O_RDWR O_APPEND O_CREAT O_TRUNC O_TEMPORARYc@s7eZdZdZejdjZddZdS)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\}}}|jjtS)N)r|tmplformatr)rDcmdr|kwargsrrr__str__szSandboxViolation.__str__N) r>r?r@rAtextwrapdedentlstriprrrrrrr s  )=r/rr+operator functoolsrre contextlibr5rZsetuptools.externrZsetuptools.extern.six.movesrrZpkg_resources.py31compatr(platformrNZ$org.python.modules.posix.PosixModulepythonrRposixZ PosixModulerrrr NameErrorrrdistutils.errorsrr__all__r contextmanagerr$r&r.r3r7r4rCrWrUr\rdrir`r rrrrr reduceor_splitrr rrrrs^                     wV