| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,7 +10,7 @@ license = {text = "MIT"} | |||
| 10 | 10 | readme = "README.rst" | |
| 11 | 11 | ||
| 12 | 12 | dependencies = [ | |
| 13 | - "clr_loader>=0.1.7" | ||
| 13 | + "clr_loader>=0.2.2,<0.3.0" | ||
| 14 | 14 | ] | |
| 15 | 15 | ||
| 16 | 16 | classifiers = [ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,12 +1,12 @@ | |||
| 1 | 1 | import sys | |
| 2 | 2 | from pathlib import Path | |
| 3 | - from typing import Dict, Optional, Union | ||
| 3 | + from typing import Dict, Optional, Union, Any | ||
| 4 | 4 | import clr_loader | |
| 5 | 5 | ||
| 6 | 6 | __all__ = ["set_runtime", "set_runtime_from_env", "load"] | |
| 7 | 7 | ||
| 8 | 8 | _RUNTIME: Optional[clr_loader.Runtime] = None | |
| 9 | - _LOADER_ASSEMBLY: Optional[clr_loader.wrappers.Assembly] = None | ||
| 9 | + _LOADER_ASSEMBLY: Optional[clr_loader.Assembly] = None | ||
| 10 | 10 | _LOADED: bool = False | |
| 11 | 11 | ||
| 12 | 12 | ||
@@ -27,6 +27,13 @@ def set_runtime(runtime: Union[clr_loader.Runtime, str], **params: str) -> None: | |||
| 27 | 27 | _RUNTIME = runtime | |
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | + def get_runtime_info() -> Optional[clr_loader.RuntimeInfo]: | ||
| 31 | + if _RUNTIME is None: | ||
| 32 | + return None | ||
| 33 | + else: | ||
| 34 | + return _RUNTIME.info() | ||
| 35 | + | ||
| 36 | + | ||
| 30 | 37 | def _get_params_from_env(prefix: str) -> Dict[str, str]: | |
| 31 | 38 | from os import environ | |
| 32 | 39 | ||
@@ -43,7 +50,7 @@ def _get_params_from_env(prefix: str) -> Dict[str, str]: | |||
| 43 | 50 | ||
| 44 | 51 | ||
| 45 | 52 | def _create_runtime_from_spec( | |
| 46 | - spec: str, params: Optional[Dict[str, str]] = None | ||
| 53 | + spec: str, params: Optional[Dict[str, Any]] = None | ||
| 47 | 54 | ) -> clr_loader.Runtime: | |
| 48 | 55 | if spec == "default": | |
| 49 | 56 | if sys.platform == "win32": | |
@@ -109,9 +116,9 @@ def load( | |||
| 109 | 116 | ||
| 110 | 117 | dll_path = Path(__file__).parent / "runtime" / "Python.Runtime.dll" | |
| 111 | 118 | ||
| 112 | - _LOADER_ASSEMBLY = _RUNTIME.get_assembly(str(dll_path)) | ||
| 119 | + _LOADER_ASSEMBLY = assembly = _RUNTIME.get_assembly(str(dll_path)) | ||
| 120 | + func = assembly.get_function("Python.Runtime.Loader.Initialize") | ||
| 113 | 121 | ||
| 114 | - func = _LOADER_ASSEMBLY["Python.Runtime.Loader.Initialize"] | ||
| 115 | 122 | if func(b"") != 0: | |
| 116 | 123 | raise RuntimeError("Failed to initialize Python.Runtime.dll") | |
| 117 | 124 | ||
@@ -125,12 +132,12 @@ def unload() -> None: | |||
| 125 | 132 | ||
| 126 | 133 | global _RUNTIME, _LOADER_ASSEMBLY | |
| 127 | 134 | if _LOADER_ASSEMBLY is not None: | |
| 128 | - func = _LOADER_ASSEMBLY["Python.Runtime.Loader.Shutdown"] | ||
| 135 | + func = _LOADER_ASSEMBLY.get_function("Python.Runtime.Loader.Shutdown") | ||
| 129 | 136 | if func(b"full_shutdown") != 0: | |
| 130 | 137 | raise RuntimeError("Failed to call Python.NET shutdown") | |
| 131 | 138 | ||
| 132 | 139 | _LOADER_ASSEMBLY = None | |
| 133 | 140 | ||
| 134 | 141 | if _RUNTIME is not None: | |
| 135 | - # TODO: Add explicit `close` to clr_loader | ||
| 142 | + _RUNTIME.shutdown() | ||
| 136 | 143 | _RUNTIME = None | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -53,10 +53,12 @@ def pytest_configure(config): | |||
| 53 | 53 | runtime_params = {} | |
| 54 | 54 | ||
| 55 | 55 | if runtime_opt == "coreclr": | |
| 56 | - fw = "net6.0" | ||
| 57 | - runtime_params["runtime_config"] = str( | ||
| 58 | - bin_path / "Python.Test.runtimeconfig.json" | ||
| 59 | - ) | ||
| 56 | + # This is optional now: | ||
| 57 | + # | ||
| 58 | + # fw = "net6.0" | ||
| 59 | + # runtime_params["runtime_config"] = str( | ||
| 60 | + # bin_path / "Python.Test.runtimeconfig.json" | ||
| 61 | + # ) | ||
| 60 | 62 | collect_ignore.append("domain_tests/test_domain_reload.py") | |
| 61 | 63 | else: | |
| 62 | 64 | domain_tests_dir = cwd / "domain_tests" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments