Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 82ce912

Browse files
Add preprocessor directive to load proper platform dll
1 parent ea98492 commit 82ce912

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

src/runtime/pythonengine.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,14 @@ public static void InitializeLibrary()
151151
{
152152
if (!libraryLoaded)
153153
{
154-
var _loader = Python.Runtime.Platform.LibraryLoader.Get(Runtime.OperatingSystem);
154+
#if MONO_OSX
155+
var os = Python.Runtime.Platform.OperatingSystemType.Darwin;
156+
#elif MONO_LINUX
157+
var os = Python.Runtime.Platform.OperatingSystemType.Linux;
158+
#else
159+
var os = Python.Runtime.Platform.OperatingSystemType.Windows;
160+
#endif
161+
var _loader = Python.Runtime.Platform.LibraryLoader.Get(os);
155162
_loader.Load(Runtime.pythonlib, Runtime.dllDirectory);
156163
libraryLoaded = true;
157164
}

src/runtime/runtime.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,16 @@ internal static void Initialize(bool initSigs = false)
318318
InitializePlatformData();
319319

320320
IntPtr dllLocal = IntPtr.Zero;
321-
var loader = LibraryLoader.Get(OperatingSystem);
322321

323-
if (!(OperatingSystem == OperatingSystemType.Windows))
322+
#if MONO_OSX
323+
var os = Python.Runtime.Platform.OperatingSystemType.Darwin;
324+
#elif MONO_LINUX
325+
var os = Python.Runtime.Platform.OperatingSystemType.Linux;
326+
#else
327+
var os = Python.Runtime.Platform.OperatingSystemType.Windows;
328+
#endif
329+
var loader = LibraryLoader.Get(os);
330+
if (!(os == OperatingSystemType.Windows))
324331
{
325332
if (_PythonDll != "__Internal")
326333
{

0 commit comments

Comments
 (0)