comparison venv/lib/python2.7/site-packages/setuptools/py31compat.py @ 0:d67268158946 draft

planemo upload commit a3f181f5f126803c654b3a66dd4e83a48f7e203b
author bcclaywell
date Mon, 12 Oct 2015 17:43:33 -0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:d67268158946
1 import sys
2 import unittest
3
4 __all__ = ['get_config_vars', 'get_path']
5
6 try:
7 # Python 2.7 or >=3.2
8 from sysconfig import get_config_vars, get_path
9 except ImportError:
10 from distutils.sysconfig import get_config_vars, get_python_lib
11 def get_path(name):
12 if name not in ('platlib', 'purelib'):
13 raise ValueError("Name must be purelib or platlib")
14 return get_python_lib(name=='platlib')
15
16 try:
17 # Python >=3.2
18 from tempfile import TemporaryDirectory
19 except ImportError:
20 import shutil
21 import tempfile
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 def __init__(self):
29 self.name = None # Handle mkdtemp raising an exception
30 self.name = tempfile.mkdtemp()
31
32 def __enter__(self):
33 return self.name
34
35 def __exit__(self, exctype, excvalue, exctrace):
36 try:
37 shutil.rmtree(self.name, True)
38 except OSError: #removal errors are not the only possible
39 pass
40 self.name = None
41
42
43 unittest_main = unittest.main
44
45 _PY31 = (3, 1) <= sys.version_info[:2] < (3, 2)
46 if _PY31:
47 # on Python 3.1, translate testRunner==None to TextTestRunner
48 # for compatibility with Python 2.6, 2.7, and 3.2+
49 def unittest_main(*args, **kwargs):
50 if 'testRunner' in kwargs and kwargs['testRunner'] is None:
51 kwargs['testRunner'] = unittest.TextTestRunner
52 return unittest.main(*args, **kwargs)