diff options
| author | Glenn Smith <glenn@vector35.com> | 2022-04-28 16:01:09 -0400 |
|---|---|---|
| committer | Glenn Smith <glenn@vector35.com> | 2022-04-28 16:01:43 -0400 |
| commit | 46772f349364c9bf62fd0b43dd5a106446c8cff0 (patch) | |
| tree | 95a4d81cb6ba40881e1289caf814863d6259cecf /scripts | |
| parent | 0f2b20ae34a101ce3b1c36f666c2685cedca8967 (diff) | |
Fix install_api.py checking for binaryninjaui by importing it in headless
Instead, use importlib to detect if the module exists
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/install_api.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/scripts/install_api.py b/scripts/install_api.py index 4b23ed99..aa12679f 100755 --- a/scripts/install_api.py +++ b/scripts/install_api.py @@ -3,8 +3,9 @@ # Thanks to @withzombies for letting us adapt his script # -import sys +import importlib.util import os +import sys from site import check_enableusersite # Handle both normal environments and virtualenvs @@ -29,8 +30,11 @@ if '-v' in sys.argv[1:]: sys.exit(1) try: - import binaryninja - import binaryninjaui #To better detect if migrating from a version without UI plugin support + binaryninja = importlib.util.find_spec('binaryninja') + assert binaryninja is not None + binaryninjaui = importlib.util.find_spec('binaryninjaui') + assert binaryninjaui is not None + if '-u' in sys.argv[1:]: #Uninstall mode userpth = os.path.join(getusersitepackages(), 'binaryninja.pth') @@ -47,7 +51,9 @@ try: sys.exit(0) print("Binary Ninja API already in the path") sys.exit(1) -except ImportError: +except ModuleNotFoundError: + pass +except AssertionError: pass if '-u' in sys.argv[1:]: |
