U ë˜Re 8ã@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl m Z ddl mZej d¡r¤ddlmmmmZn ejejZzeZWnek rÐdZYnXeZddddgZd0d d „Zejd1d d „ƒZ ejd d„ƒZ!ejdd„ƒZ"ejdd„ƒZ#Gdd„de$ƒZ%Gdd„dƒZ&ejdd„ƒZ'dd„Z(ejdd„ƒZ)ejdd„ƒZ*dd d!d"d#hZ+d$d%„Z,d&d'„Z-d(d„Z.Gd)d„dƒZ/e0ed*ƒ�rÀej1gZ2ngZ2Gd+d„de/ƒZ3e 4ej5d,d-„d. 6¡Dƒ¡Z7Gd/d„de ƒZ8dS)2éN)ÚDistutilsError)Ú working_setÚjavaÚAbstractSandboxÚDirectorySandboxÚSandboxViolationÚ run_setupc CsJd}t||ƒ�}| ¡}W5QRX|dkr.|}t||dƒ}t|||ƒdS)z. Python 3 implementation of execfile. ÚrbNÚexec)ÚopenÚreadÚcompiler )ÚfilenameÚglobalsÚlocalsÚmodeÚstreamÚscriptÚcode©rúˆ/builddir/build/BUILDROOT/alt-python38-setuptools-58.3.0-2.el8.x86_64/opt/alt/python38/lib/python3.8/site-packages/setuptools/sandbox.pyÚ _execfile$s  rc csDtjdd…}|dk r$|tjdd…<z |VW5|tjdd…<XdS©N)ÚsysÚargv)ÚreplÚsavedrrrÚ save_argv1s  rc cs.tjdd…}z |VW5|tjdd…<XdSr)rÚpath©rrrrÚ save_path<s r ccs2tj|dd�tj}|t_z dVW5|t_XdS)zL Monkey-patch tempfile.tempdir with replacement, ensuring it exists T)Úexist_okN)ÚosÚmakedirsÚtempfileÚtempdir)Ú replacementrrrrÚ override_tempEs  r'c cs.t ¡}t |¡z |VW5t |¡XdSr)r"ÚgetcwdÚchdir)ÚtargetrrrrÚpushdVs   r+c@seZdZdZedd„ƒZdS)Ú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)ÚpickleÚdumpsÚ ExceptionÚsetuptools.sandboxr,ÚdumpÚrepr)ÚtypeÚexcÚclsrrrr1es  zUnpickleableException.dumpN)Ú__name__Ú __module__Ú __qualname__Ú__doc__Ú staticmethodr1rrrrr,`sr,c@s(eZdZdZdd„Zdd„Zdd„ZdS) ÚExceptionSaverz^ A Context Manager that will save an exception, serialized, and restore it later. cCs|Srr©ÚselfrrrÚ __enter__zszExceptionSaver.__enter__cCs |sdSt ||¡|_||_dS©NT)r,r1Ú_savedÚ_tb)r=r3r4ÚtbrrrÚ__exit__}s zExceptionSaver.__exit__cCs2dt|ƒkrdSttj|jƒ\}}| |j¡‚dS)z"restore and re-raise any exceptionr@N)ÚvarsÚmapr-Úloadsr@Úwith_tracebackrA)r=r3r4rrrÚresumeˆs zExceptionSaver.resumeN)r6r7r8r9r>rCrHrrrrr;ts r;c #sVtj ¡‰tƒ� }ˆVW5QRXtj ˆ¡‡fdd„tjDƒ}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| d¡s|VqdS)z encodings.N©Ú startswith)Ú.0Úmod_namerrrÚ  s üzsave_modules..N)rÚmodulesÚcopyr;ÚupdateÚ_clear_modulesrH)Ú saved_excZ del_modulesrrrÚ save_modules’s   þrScCst|ƒD] }tj|=qdSr)ÚlistrrN)Z module_namesrLrrrrQ¬s rQc cs$t ¡}z |VW5t |¡XdSr)Ú pkg_resourcesÚ __getstate__Ú __setstate__rrrrÚsave_pkg_resources_state±s rXccs–tj |d¡}tƒ�xtƒ�ftƒ�Ttƒtƒ�<t|ƒ�(t |ƒ�t dƒdVW5QRXW5QRXW5QRXW5QRXW5QRXW5QRXdS)NÚtempÚ setuptools) r"rÚjoinrXrSr Úhide_setuptoolsrr'r+Ú __import__)Ú setup_dirÚtemp_dirrrrÚ setup_contextºs  r`rZÚ distutilsrUÚCythonÚ_distutils_hackcCs| dd¡d}|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)rLÚ base_modulerrrÚ _needs_hidingÒsricCs6tj dd¡}|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. rcN)rrNÚgetÚ remove_shimÚfilterrirQ)rcrNrrrr\çs  r\c CsÎtj tj |¡¡}t|ƒ�¨zl|gt|ƒtjdd…<tj d|¡t   ¡t j   dd„¡t |ƒ�t|dd�}t||ƒW5QRXWn4tk r¾}z|jr®|jdr®‚W5d}~XYnXW5QRXdS)z8Run a distutils setup script, sandboxed in its directoryNrcSs| ¡Sr)Úactivate)ÚdistrrrÚÿózrun_setup..Ú__main__)Ú__file__r6)r"rÚabspathÚdirnamer`rTrrÚinsertrÚ__init__Ú callbacksÚappendrÚdictrÚ SystemExitÚargs)Z setup_scriptr{r^ÚnsÚvrrrrös   c@seZdZdZdZdd„Zdd„Zdd„Zd d „Zd d „Z d d„Z dD]Z e e e ƒrDe e ƒeƒe <qDd$dd„ZerzedeƒZedeƒZdD]Z e e e ƒrˆee ƒeƒe <qˆdd„ZdD]Z e e e ƒr²ee ƒeƒe <q²dd„ZdD]Z e e e ƒrÜee ƒeƒe <qÜdd„Zdd„Zd d!„Zd"d#„ZdS)%rzDWrap 'os' module and 'open()' builtin for virtualizing setup scriptsFcs‡fdd„ttƒDƒˆ_dS)Ncs$g|]}| d¡stˆ|ƒr|‘qS)Ú_)rJÚhasattr)rKÚnamer<rrÚ s þz,AbstractSandbox.__init__..)ÚdirÚ_osÚ_attrsr<rr<rrvs þzAbstractSandbox.__init__cCs"|jD]}tt|t||ƒƒqdSr)r„Úsetattrr"Úgetattr)r=Úsourcer€rrrÚ_copys zAbstractSandbox._copycCs(| |¡tr|jt_|jt_d|_dSr?)rˆÚ_fileÚbuiltinsÚfileÚ_openr Ú_activer<rrrr>s  zAbstractSandbox.__enter__cCs$d|_trtt_tt_| t¡dS©NF)r�r‰rŠr‹rŒr rˆrƒ)r=Úexc_typeÚ exc_valueÚ tracebackrrrrC!s zAbstractSandbox.__exit__c Cs"|�|ƒW5QR£SQRXdS)zRun 'func' under os sandboxingNr)r=ÚfuncrrrÚrun(szAbstractSandbox.runcsttˆƒ‰‡‡fdd„}|S)Ncs2|jr |jˆ||f|ž|Ž\}}ˆ||f|ž|ŽSr)r�Ú _remap_pair)r=ÚsrcÚdstr{Úkw©r€ÚoriginalrrÚwrap0sz3AbstractSandbox._mk_dual_path_wrapper..wrap©r†rƒ©r€ršrr˜rÚ_mk_dual_path_wrapper-s z%AbstractSandbox._mk_dual_path_wrapper)ÚrenameÚlinkÚsymlinkNcs ˆp ttˆƒ‰‡‡fdd„}|S)Ncs*|jr|jˆ|f|ž|Ž}ˆ|f|ž|ŽSr)r�Ú _remap_input©r=rr{r—r˜rrrš>sz5AbstractSandbox._mk_single_path_wrapper..wrapr›)r€r™ršrr˜rÚ_mk_single_path_wrapper;sz'AbstractSandbox._mk_single_path_wrapperr‹r )ÚstatÚlistdirr)r ÚchmodÚchownÚmkdirÚremoveÚunlinkÚrmdirÚutimeÚlchownÚchrootÚlstatZ startfileÚmkfifoÚmknodÚpathconfÚaccesscsttˆƒ‰‡‡fdd„}|S)NcsB|jr2|jˆ|f|ž|Ž}| ˆˆ|f|ž|Ž¡Sˆ|f|ž|ŽSr)r�r¡Ú _remap_outputr¢r˜rrršcsz4AbstractSandbox._mk_single_with_return..wrapr›rœrr˜rÚ_mk_single_with_return`s z&AbstractSandbox._mk_single_with_return)ÚreadlinkÚtempnamcsttˆƒ‰‡‡fdd„}|S)Ncs ˆ||Ž}|jr| ˆ|¡S|Sr)r�r´)r=r{r—Úretvalr˜rrršrs  z'AbstractSandbox._mk_query..wrapr›rœrr˜rÚ _mk_queryos zAbstractSandbox._mk_query)r(ÚtmpnamcCs|S)z=Called to remap or validate any path, whether input or outputr)r=rrrrÚ_validate_path~szAbstractSandbox._validate_pathcOs | |¡S©zCalled for path inputs©r»©r=Ú operationrr{r—rrrr¡‚szAbstractSandbox._remap_inputcCs | |¡S)zCalled for path outputsr½)r=r¿rrrrr´†szAbstractSandbox._remap_outputcOs0|j|d|f|ž|Ž|j|d|f|ž|ŽfS)ú?Called for path pairs like rename, link, and symlink operationsz-fromz-to)r¡©r=r¿r•r–r{r—rrrr”ŠsþzAbstractSandbox._remap_pair)N)r6r7r8r9r�rvrˆr>rCr“r�r€rrƒrr£r‰rŒrµr¹r»r¡r´r”rrrrr s<          Údevnullc@s–eZdZdZe dddddddd d d d d dg ¡ZgZefdd„Z dd„Z e rVd&dd„Z d'dd„Z dd„Z dd„Zdd„Zdd„Zd d!„Zd(d#d$„Zd%S))rz.) r"rrÄrÅÚ_sandboxr[Ú_prefixÚ _exceptionsrrv)r=ZsandboxÚ exceptionsrrrrv°s ÿzDirectorySandbox.__init__cOsddlm}||||ƒ‚dS)Nr)r)r0r)r=r¿r{r—rrrrÚ _violation¸s zDirectorySandbox._violationÚrcOs:|dkr(| |¡s(|jd||f|ž|Žt||f|ž|ŽS)N©rËÚrtr ZrUÚUr‹)Ú_okrÊr‰©r=rrr{r—rrrr‰¿szDirectorySandbox._filecOs:|dkr(| |¡s(|jd||f|ž|Žt||f|ž|ŽS)NrÌr )rÏrÊrŒrÐrrrrŒÄszDirectorySandbox._opencCs| d¡dS)Nrº)rÊr<rrrrºÉszDirectorySandbox.tmpnamcCsR|j}z>d|_tj tj |¡¡}| |¡p@||jkp@| |j¡W¢S||_XdSrŽ) r�r"rrÄrÅÚ _exemptedrÆrJrÇ)r=rÚactiverÅrrrrÏÌs ÿ ýzDirectorySandbox._okcs<‡fdd„|jDƒ}‡fdd„|jDƒ}t ||¡}t|ƒS)Nc3s|]}ˆ |¡VqdSrrI)rKÚ exception©ÚfilepathrrrMÚsz-DirectorySandbox._exempted..c3s|]}t |ˆ¡VqdSr)ÚreÚmatch)rKÚpatternrÔrrrMÝs)rÈÚ_exception_patternsÚ itertoolsÚchainÚany)r=rÕZ start_matchesZpattern_matchesÚ candidatesrrÔrrÑÙs ÿ ÿ zDirectorySandbox._exemptedcOs4||jkr0| |¡s0|j|tj |¡f|ž|Ž|Sr¼)Ú write_opsrÏrÊr"rrÅr¾rrrr¡ãszDirectorySandbox._remap_inputcOs2| |¡r| |¡s*|j|||f|ž|Ž||fS)rÀ)rÏrÊrÁrrrr”észDirectorySandbox._remap_pairéÿcOs@|t@r*| |¡s*|jd|||f|ž|Žtj|||f|ž|ŽS)zCalled for low-level os.open()zos.open)Ú WRITE_FLAGSrÏrÊrƒr )r=r‹Úflagsrr{r—rrrr ïszDirectorySandbox.openN)rË)rË)rß)r6r7r8r9ryÚfromkeysrÞrÙÚ _EXCEPTIONSrvrÊr‰rŒrºrÏrÑr¡r”r rrrrr˜s:óÿ     cCsg|]}tt|dƒ‘qS)rr›)rKÚarrrr�øsÿr�z4O_WRONLY O_RDWR O_APPEND O_CREAT O_TRUNC O_TEMPORARYc@s&eZdZdZe d¡ ¡Zdd„ZdS)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\}}}|jjftƒŽSr)r{ÚtmplÚformatr)r=Úcmdr{ÚkwargsrrrÚ__str__s zSandboxViolation.__str__N) r6r7r8r9ÚtextwrapÚdedentÚlstriprårérrrrrÿs ÿ)N)N)9r"rr$ÚoperatorÚ functoolsrÚrÖÚ contextlibr-rêrŠrUÚdistutils.errorsrrÚplatformrJZ$org.python.modules.posix.PosixModuleÚpythonrNÚposixZ PosixModulerƒr€r‹r‰Ú NameErrorr rŒÚ__all__rÚcontextmanagerrr r'r+r/r,r;rSrQrXr`rgrir\rrrrÂrãrÚreduceÚor_rfràrrrrrÚs„      ü        û   ^þþ