GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — pythonnet/pythonnet/__init__.py at master · ywscr/pythonnet Expand file tree/ Copy path__init__.pyMore file actions 59 lines (41 loc) · 1.41 KB / Copy path__init__.pyFile metadata and controls59 lines (41 loc) · 1.41 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 import sys import clr_loader _RUNTIME = None _LOADER_ASSEMBLY = None _FFI = None _LOADED = False def set_runtime(runtime): global _RUNTIME if _LOADED: raise RuntimeError("The runtime {} has already been loaded".format(_RUNTIME)) _RUNTIME = runtime def set_default_runtime() -> None: if sys.platform == 'win32': set_runtime(clr_loader.get_netfx()) else: set_runtime(clr_loader.get_mono()) def load(): global _FFI, _LOADED, _LOADER_ASSEMBLY if _LOADED: return from os.path import join, dirname if _RUNTIME is None: # TODO: Warn, in the future the runtime must be set explicitly, either # as a config/env variable or via set_runtime set_default_runtime() dll_path = join(dirname(__file__), "runtime", "Python.Runtime.dll") _LOADER_ASSEMBLY = _RUNTIME.get_assembly(dll_path) func = _LOADER_ASSEMBLY["Python.Runtime.Loader.Initialize"] if func(''.encode("utf8")) != 0: raise RuntimeError("Failed to initialize Python.Runtime.dll") import atexit atexit.register(unload) def unload(): global _RUNTIME if _LOADER_ASSEMBLY is not None: func = _LOADER_ASSEMBLY["Python.Runtime.Loader.Shutdown"] if func(b"") != 0: raise RuntimeError("Failed to call Python.NET shutdown") if _RUNTIME is not None: # TODO: Add explicit `close` to clr_loader _RUNTIME = None |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |