OSDN Git Service

データを追加
[stux/ultron.git] / venv / Lib / site-packages / setuptools / py31compat.py
1 __all__ = ['get_config_vars', 'get_path']
2
3 try:
4     # Python 2.7 or >=3.2
5     from sysconfig import get_config_vars, get_path
6 except ImportError:
7     from distutils.sysconfig import get_config_vars, get_python_lib
8
9     def get_path(name):
10         if name not in ('platlib', 'purelib'):
11             raise ValueError("Name must be purelib or platlib")
12         return get_python_lib(name == 'platlib')
13
14
15 try:
16     # Python >=3.2
17     from tempfile import TemporaryDirectory
18 except ImportError:
19     import shutil
20     import tempfile
21
22     class TemporaryDirectory(object):
23         """
24         Very simple temporary directory context manager.
25         Will try to delete afterward, but will also ignore OS and similar
26         errors on deletion.
27         """
28
29         def __init__(self):
30             self.name = None  # Handle mkdtemp raising an exception
31             self.name = tempfile.mkdtemp()
32
33         def __enter__(self):
34             return self.name
35
36         def __exit__(self, exctype, excvalue, exctrace):
37             try:
38                 shutil.rmtree(self.name, True)
39             except OSError:  # removal errors are not the only possible
40                 pass
41             self.name = None