File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change 18
18
19
19
env :
20
20
PYTHONNET_SHUTDOWN_MODE : ${{ matrix.SHUTDOWN_MODE }}
21
+ PYTHONNET_PYVER : ${{ matrix.PYTHON }}
21
22
22
23
steps :
23
24
- name : Set Environment on macOS
Original file line number Diff line number Diff line change 9
9
using Python . Runtime . Native ;
10
10
using Python . Runtime . Platform ;
11
11
using System . Linq ;
12
+ using static System . FormattableString ;
12
13
13
14
namespace Python . Runtime
14
15
{
@@ -30,7 +31,29 @@ public static string PythonDLL
30
31
}
31
32
}
32
33
33
- static string _PythonDll ;
34
+ static string _PythonDll = GetDefaultDllName ( ) ;
35
+ private static string GetDefaultDllName ( )
36
+ {
37
+ string dll = Environment . GetEnvironmentVariable ( "PYTHONNET_PYDLL" ) ;
38
+ if ( dll is not null ) return dll ;
39
+
40
+ string verString = Environment . GetEnvironmentVariable ( "PYTHONNET_PYVER" ) ;
41
+ if ( ! Version . TryParse ( verString , out var version ) ) return null ;
42
+
43
+ return GetDefaultDllName ( version ) ;
44
+ }
45
+
46
+ private static string GetDefaultDllName ( Version version )
47
+ {
48
+ string prefix = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ? "" : "lib" ;
49
+ string suffix = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows )
50
+ ? Invariant ( $ "{ version . Major } { version . Minor } ")
51
+ : Invariant ( $ "{ version . Major } .{ version . Minor } ") ;
52
+ string ext = RuntimeInformation . IsOSPlatform ( OSPlatform . Windows ) ? ".dll"
53
+ : RuntimeInformation . IsOSPlatform ( OSPlatform . OSX ) ? ".dylib"
54
+ : ".so" ;
55
+ return prefix + "python" + suffix + ext ;
56
+ }
34
57
35
58
// set to true when python is finalizing
36
59
internal static object IsFinalizingLock = new object ( ) ;
You can’t perform that action at this time.
0 commit comments