3 ”Reº ã@s&ddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z ddlmZmZddlmZer¤ddlmZmZmZmZmZmZed d d �ZejeƒZed d dd�Zdae dd„ƒZ Gdd„de!ƒZ"da#e dd„ƒZ$Gdd„de!ƒZ%e%ƒZ&Gdd „d e!ƒZ'Gdd„de'ƒZ(dS)é)Úabsolute_importN)Úcontextmanager)Ú ExitStack)Ú ensure_text)ÚenumÚrmtree)ÚMYPY_CHECK_RUNNING)ÚAnyÚDictÚIteratorÚOptionalÚTypeVarÚUnionÚ_TÚ TempDirectory)Zboundz build-envzephem-wheel-cachez req-build)Ú BUILD_ENVÚEPHEM_WHEEL_CACHEÚ REQ_BUILDccs2tƒ�"}t|}az dVWd|aXWdQRXdS)N)rÚ_tempdir_manager)ÚstackÚold_tempdir_manager©rú‹/builddir/build/BUILDROOT/alt-python36-pip-20.2.4-5.el8.x86_64/opt/alt/python36/lib/python3.6/site-packages/pip/_internal/utils/temp_dir.pyÚglobal_tempdir_manager%s   rc@s(eZdZdZdd„Zdd„Zdd„ZdS) ÚTempDirectoryTypeRegistryz$Manages temp directory behavior cCs i|_dS)N)Ú_should_delete)ÚselfrrrÚ__init__5sz"TempDirectoryTypeRegistry.__init__cCs||j|<dS)z[Indicate whether a TempDirectory of the given kind should be auto-deleted. N)r)rÚkindÚvaluerrrÚ set_delete9sz$TempDirectoryTypeRegistry.set_deletecCs|jj|dƒS)z^Get configured auto-delete flag for a given TempDirectory type, default True. T)rÚget)rrrrrÚ get_delete@sz$TempDirectoryTypeRegistry.get_deleteN)Ú__name__Ú __module__Ú __qualname__Ú__doc__rr r"rrrrr1src cs t}tƒaz tVWd|aXdS)zuProvides a scoped global tempdir registry that can be used to dictate whether directories should be deleted. N)Ú_tempdir_registryr)Úold_tempdir_registryrrrÚtempdir_registryKs  r)c@s eZdZdS)Ú_DefaultN)r#r$r%rrrrr*Zsr*cs^eZdZdZdeddf‡fdd„ Zedd„ƒZd d „Zd d „Z d d„Z dd„Z dd„Z ‡Z S)raMHelper class that owns and cleans up a temporary directory. This class can be used as a context manager or as an OO representation of a temporary directory. Attributes: path Location to the created temporary directory delete Whether the directory should be deleted when exiting (when used as a contextmanager) Methods: cleanup() Deletes the temporary directory When used as a context manager, if the delete attribute is True, on exiting the context the temporary directory is deleted. NÚtempFcsptt|ƒjƒ|tkr(|dk r$d}nd}|dkr:|j|ƒ}||_d|_||_||_|rlt dk sbt ‚t j |ƒdS)NF) ÚsuperrrÚ_defaultÚ_createÚ_pathÚ_deletedÚdeleterrÚAssertionErrorÚ enter_context)rÚpathr1rÚglobally_managed)Ú __class__rrrvs  zTempDirectory.__init__cCs|j stdj|jƒƒ‚|jS)Nz$Attempted to access deleted path: {})r0r2Úformatr/)rrrrr4•s zTempDirectory.pathcCsdj|jj|jƒS)Nz <{} {!r}>)r7r6r#r4)rrrrÚ__repr__�szTempDirectory.__repr__cCs|S)Nr)rrrrÚ __enter__¡szTempDirectory.__enter__cCs8|jdk r|j}ntr$tj|jƒ}nd}|r4|jƒdS)NT)r1r'r"rÚcleanup)rÚexcrÚtbr1rrrÚ__exit__¥s zTempDirectory.__exit__cCs*tjjtjdj|ƒd�ƒ}tjd|ƒ|S)zECreate a temporary directory and store its path in self.path zpip-{}-)ÚprefixzCreated temporary directory: %s)Úosr4ÚrealpathÚtempfileÚmkdtempr7ÚloggerÚdebug)rrr4rrrr.±s zTempDirectory._createcCs&d|_tjj|jƒr"tt|jƒƒdS)z?Remove the temporary directory created and reset state TN)r0r?r4Úexistsr/rr)rrrrr:¿szTempDirectory.cleanup)r#r$r%r&r-rÚpropertyr4r8r9r=r.r:Ú __classcell__rr)r6rras  cs:eZdZdZdZd ‡fdd„ Zedd„ƒZdd „Z‡Z S) ÚAdjacentTempDirectoryaªHelper class that creates a temporary directory adjacent to a real one. Attributes: original The original directory to create a temp directory for. path After calling create() or entering, contains the full path to the temporary directory. delete Whether the directory should be deleted when exiting (when used as a contextmanager) z-~.=%0123456789Ncs"|jdƒ|_tt|ƒj|d�dS)Nz/\)r1)ÚrstripÚoriginalr,rHr)rrJr1)r6rrrßs zAdjacentTempDirectory.__init__ccs°xZtdt|ƒƒD]H}xBtj|j|dƒD],}ddj|ƒ||d…}||kr(|Vq(WqWxNtt|jƒƒD]<}x6tj|j|ƒD]$}ddj|ƒ|}||kr€|Vq€WqlWdS)a Generates a series of temporary names. The algorithm replaces the leading characters in the name with ones that are valid filesystem characters, but are not valid package names (for both Python and pip definitions of package). éú~ÚN)ÚrangeÚlenÚ itertoolsÚcombinations_with_replacementÚ LEADING_CHARSÚjoin)ÚclsÚnameÚiÚ candidateÚnew_namerrrÚ_generate_namesäs z%AdjacentTempDirectory._generate_namescCs¬tjj|jƒ\}}xˆ|j|ƒD]`}tjj||ƒ}ytj|ƒWn0tk rn}z|jtj kr^‚WYdd}~XqXtjj |ƒ}PqWtjj t j dj |ƒd�ƒ}tjd|ƒ|S)Nzpip-{}-)r>zCreated temporary directory: %s)r?r4ÚsplitrJrYrSÚmkdirÚOSErrorÚerrnoÚEEXISTr@rArBr7rCrD)rrÚrootrUrWr4Úexrrrr.ýs   zAdjacentTempDirectory._create)N) r#r$r%r&rRrÚ classmethodrYr.rGrr)r6rrHÊs   rH))Ú __future__rr]rPÚloggingÚos.pathr?rAÚ contextlibrÚpip._vendor.contextlib2rZpip._vendor.sixrÚpip._internal.utils.miscrrÚpip._internal.utils.typingrÚtypingr r r r r rrÚ getLoggerr#rCÚ tempdir_kindsrrÚobjectrr'r)r*r-rrHrrrrÚs6          i