Mercurial > repos > shellac > guppy_basecaller
comparison env/lib/python3.7/site-packages/virtualenv/create/debug.py @ 2:6af9afd405e9 draft
"planemo upload commit 0a63dd5f4d38a1f6944587f52a8cd79874177fc1"
| author | shellac |
|---|---|
| date | Thu, 14 May 2020 14:56:58 -0400 |
| parents | 26e78fe6e8c4 |
| children |
comparison
equal
deleted
inserted
replaced
| 1:75ca89e9b81c | 2:6af9afd405e9 |
|---|---|
| 1 """Inspect a target Python interpreter virtual environment wise""" | |
| 2 import sys # built-in | |
| 3 | |
| 4 PYPY2_WIN = hasattr(sys, "pypy_version_info") and sys.platform != "win32" and sys.version_info[0] == 2 | |
| 5 | |
| 6 | |
| 7 def encode_path(value): | |
| 8 if value is None: | |
| 9 return None | |
| 10 if not isinstance(value, (str, bytes)): | |
| 11 if isinstance(value, type): | |
| 12 value = repr(value) | |
| 13 else: | |
| 14 value = repr(type(value)) | |
| 15 if isinstance(value, bytes) and not PYPY2_WIN: | |
| 16 value = value.decode(sys.getfilesystemencoding()) | |
| 17 return value | |
| 18 | |
| 19 | |
| 20 def encode_list_path(value): | |
| 21 return [encode_path(i) for i in value] | |
| 22 | |
| 23 | |
| 24 def run(): | |
| 25 """print debug data about the virtual environment""" | |
| 26 try: | |
| 27 from collections import OrderedDict | |
| 28 except ImportError: # pragma: no cover | |
| 29 # this is possible if the standard library cannot be accessed | |
| 30 # noinspection PyPep8Naming | |
| 31 OrderedDict = dict # pragma: no cover | |
| 32 result = OrderedDict([("sys", OrderedDict())]) | |
| 33 path_keys = ( | |
| 34 "executable", | |
| 35 "_base_executable", | |
| 36 "prefix", | |
| 37 "base_prefix", | |
| 38 "real_prefix", | |
| 39 "exec_prefix", | |
| 40 "base_exec_prefix", | |
| 41 "path", | |
| 42 "meta_path", | |
| 43 ) | |
| 44 for key in path_keys: | |
| 45 value = getattr(sys, key, None) | |
| 46 if isinstance(value, list): | |
| 47 value = encode_list_path(value) | |
| 48 else: | |
| 49 value = encode_path(value) | |
| 50 result["sys"][key] = value | |
| 51 result["sys"]["fs_encoding"] = sys.getfilesystemencoding() | |
| 52 result["sys"]["io_encoding"] = getattr(sys.stdout, "encoding", None) | |
| 53 result["version"] = sys.version | |
| 54 import os # landmark | |
| 55 | |
| 56 result["os"] = repr(os) | |
| 57 | |
| 58 try: | |
| 59 # noinspection PyUnresolvedReferences | |
| 60 import site # site | |
| 61 | |
| 62 result["site"] = repr(site) | |
| 63 except ImportError as exception: # pragma: no cover | |
| 64 result["site"] = repr(exception) # pragma: no cover | |
| 65 | |
| 66 try: | |
| 67 # noinspection PyUnresolvedReferences | |
| 68 import datetime # site | |
| 69 | |
| 70 result["datetime"] = repr(datetime) | |
| 71 except ImportError as exception: # pragma: no cover | |
| 72 result["datetime"] = repr(exception) # pragma: no cover | |
| 73 | |
| 74 try: | |
| 75 # noinspection PyUnresolvedReferences | |
| 76 import math # site | |
| 77 | |
| 78 result["math"] = repr(math) | |
| 79 except ImportError as exception: # pragma: no cover | |
| 80 result["math"] = repr(exception) # pragma: no cover | |
| 81 | |
| 82 # try to print out, this will validate if other core modules are available (json in this case) | |
| 83 try: | |
| 84 import json | |
| 85 | |
| 86 result["json"] = repr(json) | |
| 87 print(json.dumps(result, indent=2)) | |
| 88 except (ImportError, ValueError, TypeError) as exception: # pragma: no cover | |
| 89 result["json"] = repr(exception) # pragma: no cover | |
| 90 print(repr(result)) # pragma: no cover | |
| 91 raise SystemExit(1) # pragma: no cover | |
| 92 | |
| 93 | |
| 94 if __name__ == "__main__": | |
| 95 run() |
