-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathload_dynamic_library.py
More file actions
62 lines (54 loc) · 1.87 KB
/
Copy pathload_dynamic_library.py
File metadata and controls
62 lines (54 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import ctypes
import platform
import os
import sys
from pathlib import Path
package_dir = Path(__file__).parent.parent.resolve()
lib_path = os.path.join(package_dir, "dynamic_libs")
system = platform.system().lower()
arch = platform.machine().lower()
format_arch = ""
if sys.maxsize == 2**63 - 1:
if arch in ("x86_64", "amd64"):
format_arch = "amd64"
elif arch in ("arm64", "aarch64"):
format_arch = "arm64"
else:
if arch in ("x86", "i686"):
format_arch = "x86"
LIB = None
match system:
case "windows":
if format_arch == "amd64":
LIB = ctypes.cdll.LoadLibrary(
os.path.join(lib_path, "bedrock-chunk-diff_windows_amd64.dll")
)
elif format_arch == "x86":
LIB = ctypes.cdll.LoadLibrary(
os.path.join(lib_path, "bedrock-chunk-diff_windows_x86.dll")
)
case "darwin":
if format_arch == "amd64":
LIB = ctypes.cdll.LoadLibrary(
os.path.join(lib_path, "bedrock-chunk-diff_macos_amd64.dylib")
)
elif format_arch == "arm64":
LIB = ctypes.cdll.LoadLibrary(
os.path.join(lib_path, "bedrock-chunk-diff_macos_arm64.dylib")
)
case _:
if format_arch == "amd64":
LIB = ctypes.cdll.LoadLibrary(
os.path.join(lib_path, "bedrock-chunk-diff_linux_amd64.so")
)
elif format_arch == "arm64":
if arch == "aarch64":
LIB = ctypes.cdll.LoadLibrary(
os.path.join(lib_path, "bedrock-chunk-diff_android_arm64.so")
)
else:
LIB = ctypes.cdll.LoadLibrary(
os.path.join(lib_path, "bedrock-chunk-diff_linux_arm64.so")
)
if LIB is None:
raise Exception(f"Your machine (system={system}, arch={arch}) is not supported.")