3 ig@sUddlZddlZddlZddlZddlZddlmZmZddl m Z m Z m Z m Z mZmZddlmZmZejeZedddZedd d d Zdae eee dd d dZGdddZdae eee ed ddZGdddZeZGdddZGdddeZ dS)N) ExitStackcontextmanager)AnyDictIteratorOptionalTypeVarUnion)enumrmtree_T TempDirectory)Zboundz build-envzephem-wheel-cachez req-build)Z BUILD_ENVZEPHEM_WHEEL_CACHEZ REQ_BUILD)returnccs2t"}t|}az dVWd|aXWdQRXdS)N)r_tempdir_manager)stackZold_tempdir_managerr;/tmp/pip-build-88gy_88q/pip/pip/_internal/utils/temp_dir.pyglobal_tempdir_managers   rc@s@eZdZdZddddZeeddddZeed d d ZdS) TempDirectoryTypeRegistryzManages temp directory behaviorN)rcCs i|_dS)N)_should_delete)selfrrr__init__*sz"TempDirectoryTypeRegistry.__init__)kindvaluercCs||j|<dS)z[Indicate whether a TempDirectory of the given kind should be auto-deleted. N)r)rrrrrr set_delete-sz$TempDirectoryTypeRegistry.set_delete)rrcCs|jj|dS)z^Get configured auto-delete flag for a given TempDirectory type, default True. T)rget)rrrrr get_delete3sz$TempDirectoryTypeRegistry.get_delete) __name__ __module__ __qualname____doc__rstrboolrrrrrrr'src cs t}taz tVWd|aXdS)zuProvides a scoped global tempdir registry that can be used to dictate whether directories should be deleted. N)_tempdir_registryr)Zold_tempdir_registryrrrtempdir_registry=s  r$c@s eZdZdS)_DefaultN)rrrrrrrr%Ksr%cseZdZdZdeddfeeeede feedfdd Z e edd d Z edd d Z eed ddZeeeddddZeedddZddddZZS)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. NtempF)pathdeleterglobally_managedcsltj|tkr$|dk r d}nd}|dkr6|j|}||_d|_||_||_|rhtdk s^t tj |dS)NF) superr_default_create_path_deletedr(rrAssertionError enter_context)rr'r(rr)) __class__rrrgs   zTempDirectory.__init__)rcCs|j std|j|jS)Nz"Attempted to access deleted path: )r.r/r-)rrrrr'szTempDirectory.pathcCsd|jjd|jdS)N< >)r1rr')rrrr__repr__szTempDirectory.__repr__)rrcCs|S)Nr)rrrr __enter__szTempDirectory.__enter__)excrtbrcCs8|jdk r|j}ntr$tj|j}nd}|r4|jdS)NT)r(r#rrcleanup)rr7rr8r(rrr__exit__s zTempDirectory.__exit__)rrcCs,tjjtjd|dd}tjd||S)zr?r@rArB)rrrootrIrUr'exrrrr,s   zAdjacentTempDirectory._create)N)rrrr rQr!rr"r classmethodrrWr,rErr)r1rrFs  rF)!r[rOloggingos.pathr=r? contextlibrrZtypingrrrrrr Zpip._internal.utils.miscr r getLoggerrrAr Z tempdir_kindsrrrr#r$r%r+r rFrrrrs2       ^