Path: blob/master/venv/Lib/site-packages/setuptools/py31compat.py
811 views
__all__ = []12__metaclass__ = type345try:6# Python >=3.27from tempfile import TemporaryDirectory8except ImportError:9import shutil10import tempfile1112class TemporaryDirectory:13"""14Very simple temporary directory context manager.15Will try to delete afterward, but will also ignore OS and similar16errors on deletion.17"""1819def __init__(self, **kwargs):20self.name = None # Handle mkdtemp raising an exception21self.name = tempfile.mkdtemp(**kwargs)2223def __enter__(self):24return self.name2526def __exit__(self, exctype, excvalue, exctrace):27try:28shutil.rmtree(self.name, True)29except OSError: # removal errors are not the only possible30pass31self.name = None323334