Skip to content

Commit c09b903

Browse files
Update DLL loading for cross platform
Still needs testing on Linux and macOS
1 parent 70f6557 commit c09b903

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/ITS/ITU/PSeries/P2108/p2108.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import platform
2+
import sys
23
from ctypes import *
34
from enum import IntEnum
45
from pathlib import Path
@@ -29,19 +30,24 @@ class ClutterType(IntEnum):
2930

3031

3132
# Load the compiled library
33+
lib_name = "P2108"
34+
if sys.maxsize > 2**32:
35+
lib_name += "x64"
36+
else:
37+
# note: 32-bit python is needed to load 32-bit lib.
38+
lib_name += "x86"
3239
if platform.uname()[0] == "Windows":
33-
lib_name = "P2108.dll"
40+
lib_name += ".dll"
3441
elif platform.uname()[0] == "Linux":
35-
lib_name = "libP2108.so.1.0"
36-
# elif platform.uname()[0] == "Darwin":
37-
# lib_name = "P2108.dylib" # TODO test and confirm
42+
lib_name += ".so"
43+
elif platform.uname()[0] == "Darwin":
44+
lib_name += ".dylib"
3845
else:
3946
raise NotImplementedError("Your OS is not yet supported")
4047

4148
# Library should be in the same directory as this file
4249
lib_path = Path(__file__).parent / lib_name
4350
lib = CDLL(str(lib_path.resolve()))
44-
# note: 32-bit python is needed to load 32-bit lib.
4551

4652
# Define function prototypes
4753
lib.AeronauticalStatisticalModel.restype = c_int

0 commit comments

Comments
 (0)