B š•Reº ã@s&ddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z ddlmZmZddlmZer¤ddlmZmZmZmZmZmZed d d �Ze e¡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)Úboundz build-envzephem-wheel-cachez req-build)Ú BUILD_ENVÚEPHEM_WHEEL_CACHEÚ REQ_BUILDc cs2tƒ�"}t|}az dVWd|aXWdQRXdS)N)rÚ_tempdir_manager)ÚstackÚold_tempdir_manager©rú‹/builddir/build/BUILDROOT/alt-python37-pip-20.2.4-6.el8.x86_64/opt/alt/python37/lib/python3.7/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|j |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#rrrrr1srccs 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|ƒ ¡|tkr(|dk r$d}nd}|dkr:| |¡}||_d|_||_||_|rlt dk sbt ‚t   |¡dS)NF) ÚsuperrrÚ_defaultÚ_createÚ_pathÚ_deletedÚdeleterrÚAssertionErrorÚ enter_context)rÚpathr2rÚglobally_managed)Ú __class__rrrvs  zTempDirectory.__init__cCs|jrtd |j¡ƒ‚|jS)Nz$Attempted to access deleted path: {})r1r3Úformatr0)rrrrr5•szTempDirectory.pathcCsd |jj|j¡S)Nz <{} {!r}>)r8r7r$r5)rrrrÚ__repr__�szTempDirectory.__repr__cCs|S)Nr)rrrrÚ __enter__¡szTempDirectory.__enter__cCs8|jdk r|j}ntr$t |j¡}nd}|r4| ¡dS)NT)r2r(r#rÚcleanup)rÚexcr Útbr2rrrÚ__exit__¥s zTempDirectory.__exit__cCs*tj tjd |¡d�¡}t d|¡|S)zECreate a temporary directory and store its path in self.path zpip-{}-)ÚprefixzCreated temporary directory: %s)Úosr5ÚrealpathÚtempfileÚmkdtempr8ÚloggerÚdebug)rrr5rrrr/±s zTempDirectory._createcCs&d|_tj |j¡r"tt|jƒƒdS)z?Remove the temporary directory created and reset state TN)r1r@r5Úexistsr0rr)rrrrr;¿szTempDirectory.cleanup)r$r%r&r'r.rÚpropertyr5r9r:r>r/r;Ú __classcell__rr)r7rras  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"| d¡|_tt|ƒj|d�dS)Nz/\)r2)ÚrstripÚoriginalr-rIr)rrKr2)r7rrrßs zAdjacentTempDirectory.__init__ccs°xZtdt|ƒƒD]H}xBt |j|d¡D],}dd |¡||d…}||kr(|Vq(WqWxNtt|jƒƒD]<}x6t |j|¡D]$}dd |¡|}||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_namesc Cs¬tj |j¡\}}xˆ| |¡D]`}tj ||¡}yt |¡Wn0tk rn}z|jtj kr^‚Wdd}~XYqXtj  |¡}PqWtj  t j d  |¡d�¡}t d|¡|S)Nzpip-{}-)r?zCreated temporary directory: %s)r@r5ÚsplitrKrZrTÚmkdirÚOSErrorÚerrnoÚEEXISTrArBrCr8rDrE)rrÚrootrVrXr5Úexrrrr/ýs   zAdjacentTempDirectory._create)N) r$r%r&r'rSrÚ classmethodrZr/rHrr)r7rrIÊs   rI))Ú __future__rr^rQÚloggingÚos.pathr@rBÚ contextlibrÚpip._vendor.contextlib2rZpip._vendor.sixrÚpip._internal.utils.miscrrÚpip._internal.utils.typingrÚtypingr r r r r rrÚ getLoggerr$rDÚ tempdir_kindsrrÚobjectrr(r*r+r.rrIrrrrÚs6          i