Skip to content

Commit 26b295e

Browse files
committed
Added binaryen not installed protections
1 parent b4a34ba commit 26b295e

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

binaryen/lib.py

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,38 @@
22
from typing import Any, cast
33
from ._binaryen_cffi import ffi
44

5+
__macos_error = """You either do not have the binaryen library installed, or it is not in your standard C library path.
6+
7+
Recommended: Using the brew package manager (https://brew.sh/) run brew install binaryen
8+
9+
Alternatively add the precompiled libbinaryen.dylib from https://github.com/WebAssembly/binaryen/releases to your path.
10+
"""
11+
12+
__windows_error = """You either do not have the binaryen library installed, or it is not in your standard C library path.
13+
14+
Add the precompiled libbinaryen.dll from https://github.com/WebAssembly/binaryen/releases to your path.
15+
"""
16+
17+
__linux_error = """You either do not have the binaryen library installed, or it is not in your standard C library path.
18+
19+
Recommended: Use your distributions package manager to install binaryen.
20+
21+
Alternatively add the precompiled libbinaryen.so from https://github.com/WebAssembly/binaryen/releases to your path.
22+
"""
23+
524
__lib_string = ""
25+
__error_message = ""
626
if platform.system() == "Linux":
27+
__error_message = __linux_error
728
__lib_string = "libbinaryen.so"
829
if platform.system() == "Windows":
30+
__error_message = __windows_error
931
__lib_string = "libbinaryen.dll"
1032
if platform.system() == "Darwin":
33+
__error_message = __macos_error
1134
__lib_string = "libbinaryen.dylib"
12-
lib = cast(Any, ffi.dlopen(__lib_string))
35+
36+
try:
37+
lib = cast(Any, ffi.dlopen(__lib_string))
38+
except OSError as error:
39+
raise OSError(__error_message) from error

0 commit comments

Comments
 (0)