File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change 1
1
import sys
2
2
from pathlib import Path
3
- from typing import Optional
3
+ from typing import Optional , Tuple
4
4
5
5
import cffi # type: ignore
6
6
@@ -23,7 +23,7 @@ def load_hostfxr(dotnet_root: Path):
23
23
hostfxr_path = dotnet_root / "host" / "fxr"
24
24
hostfxr_paths = hostfxr_path .glob (f"?.*/{ hostfxr_name } " )
25
25
26
- for hostfxr_path in reversed (sorted (hostfxr_paths )):
26
+ for hostfxr_path in reversed (sorted (hostfxr_paths , key = _path_to_version )):
27
27
try :
28
28
return ffi .dlopen (str (hostfxr_path ))
29
29
except Exception :
@@ -61,6 +61,15 @@ def load_netfx():
61
61
return ffi .dlopen (str (path ))
62
62
63
63
64
+ def _path_to_version (path : Path ) -> Tuple [int , int , int ]:
65
+ name = path .parent .name
66
+ try :
67
+ res = list (map (int , name .split ("." )))
68
+ return tuple (res + [0 , 0 , 0 ])[:3 ]
69
+ except Exception :
70
+ return (0 , 0 , 0 )
71
+
72
+
64
73
def _get_dll_name (name : str ) -> str :
65
74
if sys .platform == "win32" :
66
75
return f"{ name } .dll"
You can’t perform that action at this time.
0 commit comments