Skip to content

Commit 17e33ac

Browse files
committed
fix load dll
1 parent 9af26d8 commit 17e33ac

File tree

1 file changed

+3
-29
lines changed

1 file changed

+3
-29
lines changed

msc/msp.py

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
import platform
32

43
from ctypes import cdll
54
from ctypes import CDLL
@@ -9,35 +8,10 @@
98
from ctypes import c_int, c_uint, c_void_p, c_char_p
109

1110

12-
def LoadLibrary(
13-
file_name: str, base_dir: str = os.path.dirname(os.path.abspath(__file__))
14-
) -> CDLL:
15-
try:
16-
file_path = os.path.join(base_dir, "bin", file_name)
17-
msc = cdll.LoadLibrary(file_path)
18-
except Exception as e:
19-
raise Exception("Failed to load library: %s" % e)
20-
return msc
21-
22-
2311
def LoadMSC() -> CDLL:
24-
system = platform.system()
25-
arch = platform.architecture()[0]
26-
27-
if system == "Windows":
28-
if arch == "64bit":
29-
msc = LoadLibrary("msc_x64.dll")
30-
else:
31-
msc = LoadLibrary("msc_x86.dll")
32-
elif system == "Linux":
33-
if arch == "64bit":
34-
msc = LoadLibrary("msc_x64.so")
35-
else:
36-
msc = LoadLibrary("msc_x86.so")
37-
else:
38-
raise Exception("Unsupported system: %s" % system)
39-
return msc
40-
12+
name = os.getenv('MSC_SDK_PATH')
13+
assert name is not None, 'MSC_SDK_PATH is not set.'
14+
return cdll.LoadLibrary(name)
4115

4216
msc = LoadMSC()
4317

0 commit comments

Comments
 (0)