o 7]h@sUddlZddlZddlZddlZddlZddlmZmZddl m Z m Z m Z m Z mZmZddlmZmZeeZedddZedd d d Zdae eed <ed e dfddZGdddZdae eed<ed e efddZGdddZeZGdddZ Gddde Z!dS)N) ExitStackcontextmanager)AnyDictIteratorOptionalTypeVarUnion)enumrmtree_T TempDirectory)boundz build-envzephem-wheel-cachez req-build) BUILD_ENVEPHEM_WHEEL_CACHE REQ_BUILD_tempdir_managerreturnccsNt}t|}azdVW|an|awWddS1s wYdSN)rr)stackold_tempdir_managerr>/usr/lib/python3/dist-packages/pip/_internal/utils/temp_dir.pyglobal_tempdir_managers "rc@sBeZdZdZd ddZdededdfdd Zdedefd d ZdS) TempDirectoryTypeRegistryzManages temp directory behaviorrNcCs i|_dSr_should_deleteselfrrr__init__*s z"TempDirectoryTypeRegistry.__init__kindvaluecCs||j|<dS)z[Indicate whether a TempDirectory of the given kind should be auto-deleted. Nr)rr r!rrr set_delete-z$TempDirectoryTypeRegistry.set_deletecCs|j|dS)z^Get configured auto-delete flag for a given TempDirectory type, default True. T)rget)rr rrr get_delete3r#z$TempDirectoryTypeRegistry.get_deleterN) __name__ __module__ __qualname____doc__rstrboolr"r%rrrrr's  r_tempdir_registryccs$t}taztVW|adS|aw)zuProvides a scoped global tempdir registry that can be used to dictate whether directories should be deleted. N)r-r)old_tempdir_registryrrrtempdir_registry=s r/c@s eZdZdS)_DefaultN)r'r(r)rrrrr0Ksr0c seZdZdZdeddfdeedeede fdedeffd d Z e d efd d Z d efddZ ded efddZdededed dfddZded efddZdddZZS)r aMHelper 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. NtempFpathdeleter globally_managedcspt|tur|durd}nd}|dur||}||_d|_||_||_|r6tdus/Jt |dSdS)NF) superr_default_create_path_deletedr3r r enter_context)rr2r3r r4 __class__rrrgs   zTempDirectory.__init__rcCs|jr Jd|j|jS)Nz"Attempted to access deleted path: )r9r8rrrrr2szTempDirectory.pathcCsd|jjd|jdS)N< >)r<r'r2rrrr__repr__szTempDirectory.__repr__rcCs|Srrrrrr __enter__szTempDirectory.__enter__excr!tbcCs<|jdur |j}n trt|j}nd}|r|dSdS)NT)r3r-r%r cleanup)rrBr!rCr3rrr__exit__s  zTempDirectory.__exit__cCs,tjtjd|dd}td||S)zs4      ^