U n a@sddlmZddlZddlZddlZddlZddlZddlm Z ddl m Z ddl m Z mZddlmZerddlmZmZmZmZmZmZedd d ZeeZe d d d dZdae ddZGdddeZ da!e ddZ"GdddeZ#e#Z$Gdd d eZ%Gddde%Z&dS))absolute_importN)contextmanager) ExitStack)enumrmtree)MYPY_CHECK_RUNNING)AnyDictIteratorOptionalTypeVarUnion_T TempDirectory)boundz build-envzephem-wheel-cachez req-build) BUILD_ENVEPHEM_WHEEL_CACHE REQ_BUILDc cs2t"}t|}az dVW5|aXW5QRXdSN)r_tempdir_manager)stackold_tempdir_managerr]C:\Users\vtejo\AppData\Local\Temp\pip-unpacked-wheel-6mt8ur68\pip\_internal\utils\temp_dir.pyglobal_tempdir_manager$s   rc@s(eZdZdZddZddZddZdS) TempDirectoryTypeRegistryz$Manages temp directory behavior cCs i|_dSr_should_deleteselfrrr__init__4sz"TempDirectoryTypeRegistry.__init__cCs||j|<dS)z[Indicate whether a TempDirectory of the given kind should be auto-deleted. Nr)rkindvaluerrr set_delete8sz$TempDirectoryTypeRegistry.set_deletecCs|j|dS)z^Get configured auto-delete flag for a given TempDirectory type, default True. T)rget)rr!rrr get_delete?sz$TempDirectoryTypeRegistry.get_deleteN)__name__ __module__ __qualname____doc__r r#r%rrrrr0srccs t}taz tVW5|aXdS)zuProvides a scoped global tempdir registry that can be used to dictate whether directories should be deleted. N)_tempdir_registryr)old_tempdir_registryrrrtempdir_registryJs  r,c@s eZdZdS)_DefaultN)r&r'r(rrrrr-Ysr-cs^eZdZdZdeddffdd ZeddZd d Zd d Z d dZ ddZ ddZ 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. NtempFcsptt||tkr(|dk r$d}nd}|dkr:||}||_d|_||_||_|rlt dk sbt t |dS)NF) superrr _default_create_path_deleteddeleter!rAssertionError enter_context)rpathr4r!globally_managed __class__rrr us  zTempDirectory.__init__cCs|jrtd|j|jS)Nz$Attempted to access deleted path: {})r3r5formatr2rrrrr7s zTempDirectory.pathcCsd|jj|jS)Nz <{} {!r}>)r;r:r&r7rrrr__repr__szTempDirectory.__repr__cCs|Srrrrrr __enter__szTempDirectory.__enter__cCs8|jdk r|j}ntr$t|j}nd}|r4|dS)NT)r4r*r%r!cleanup)rexcr"tbr4rrr__exit__s zTempDirectory.__exit__cCs.tjtjd|d}td||S)zECreate a temporary directory and store its path in self.path pip-{}-prefixCreated temporary directory: {})osr7realpathtempfilemkdtempr;loggerdebug)rr!r7rrrr1s zTempDirectory._createcCs"d|_tj|jrt|jdS)z?Remove the temporary directory created and reset state TN)r3rFr7existsr2rrrrrr>szTempDirectory.cleanup)r&r'r(r)r0r propertyr7r<r=rAr1r> __classcell__rrr9rr`s  cs:eZdZdZdZd fdd ZeddZdd ZZ S) AdjacentTempDirectoryaHelper 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|ddS)Nz/\)r4)rstriporiginalr/rOr )rrQr4r9rrr s zAdjacentTempDirectory.__init__ccstdt|D]D}t|j|dD],}dd|||d}||kr$|Vq$qtt|jD]8}t|j|D]$}dd||}||krt|VqtqbdS)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)rangelen itertoolscombinations_with_replacement LEADING_CHARSjoin)clsnamei candidatenew_namerrr_generate_namess  z%AdjacentTempDirectory._generate_namesc Cstj|j\}}||D]b}tj||}zt|Wn0tk rl}z|jtj kr\W5d}~XYqXtj |}qqtj t j d |d}td ||S)NrBrCrE)rFr7splitrQr`rZmkdirOSErrorerrnoEEXISTrGrHrIr;rJrK)rr!rootr\r^r7exrrrr1s  zAdjacentTempDirectory._create)N) r&r'r(r)rYr classmethodr`r1rNrrr9rrOs  rO)' __future__rrdrWloggingos.pathrFrH contextlibrpip._vendor.contextlib2rpip._internal.utils.miscrrpip._internal.utils.typingrtypingrr r r r r r getLoggerr&rJ tempdir_kindsrrobjectrr*r,r-r0rrOrrrrs:         g