Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit3f12469

Browse files
committed
Bump clr-loader dependency to 0.2.3 and adjust interface
- Supports loading without explicitly specifying the runtime config now- Exposes information on the loaded runtime
1 parentbdf671e commit3f12469

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

‎pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license = {text = "MIT"}
1010
readme ="README.rst"
1111

1212
dependencies = [
13-
"clr_loader>=0.1.7"
13+
"clr_loader>=0.2.2,<0.3.0"
1414
]
1515

1616
classifiers = [

‎pythonnet/__init__.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
importsys
22
frompathlibimportPath
3-
fromtypingimportDict,Optional,Union
3+
fromtypingimportDict,Optional,Union,Any
44
importclr_loader
55

66
__all__= ["set_runtime","set_runtime_from_env","load"]
77

88
_RUNTIME:Optional[clr_loader.Runtime]=None
9-
_LOADER_ASSEMBLY:Optional[clr_loader.wrappers.Assembly]=None
9+
_LOADER_ASSEMBLY:Optional[clr_loader.Assembly]=None
1010
_LOADED:bool=False
1111

1212

@@ -27,6 +27,13 @@ def set_runtime(runtime: Union[clr_loader.Runtime, str], **params: str) -> None:
2727
_RUNTIME=runtime
2828

2929

30+
defget_runtime_info()->Optional[clr_loader.RuntimeInfo]:
31+
if_RUNTIMEisNone:
32+
returnNone
33+
else:
34+
return_RUNTIME.info()
35+
36+
3037
def_get_params_from_env(prefix:str)->Dict[str,str]:
3138
fromosimportenviron
3239

@@ -43,7 +50,7 @@ def _get_params_from_env(prefix: str) -> Dict[str, str]:
4350

4451

4552
def_create_runtime_from_spec(
46-
spec:str,params:Optional[Dict[str,str]]=None
53+
spec:str,params:Optional[Dict[str,Any]]=None
4754
)->clr_loader.Runtime:
4855
ifspec=="default":
4956
ifsys.platform=="win32":
@@ -109,9 +116,9 @@ def load(
109116

110117
dll_path=Path(__file__).parent/"runtime"/"Python.Runtime.dll"
111118

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")
113121

114-
func=_LOADER_ASSEMBLY["Python.Runtime.Loader.Initialize"]
115122
iffunc(b"")!=0:
116123
raiseRuntimeError("Failed to initialize Python.Runtime.dll")
117124

@@ -125,12 +132,12 @@ def unload() -> None:
125132

126133
global_RUNTIME,_LOADER_ASSEMBLY
127134
if_LOADER_ASSEMBLYisnotNone:
128-
func=_LOADER_ASSEMBLY["Python.Runtime.Loader.Shutdown"]
135+
func=_LOADER_ASSEMBLY.get_function("Python.Runtime.Loader.Shutdown")
129136
iffunc(b"full_shutdown")!=0:
130137
raiseRuntimeError("Failed to call Python.NET shutdown")
131138

132139
_LOADER_ASSEMBLY=None
133140

134141
if_RUNTIMEisnotNone:
135-
# TODO: Add explicit `close` to clr_loader
142+
_RUNTIME.shutdown()
136143
_RUNTIME=None

‎tests/conftest.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ def pytest_configure(config):
5353
runtime_params= {}
5454

5555
ifruntime_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+
# )
6062
collect_ignore.append("domain_tests/test_domain_reload.py")
6163
else:
6264
domain_tests_dir=cwd/"domain_tests"

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp