MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / install

Function install

scripts/install_api.py:102–172  ·  view source on GitHub ↗
(interactive=False, on_root=False, on_pyenv=False, force=False)

Source from the content-addressed store, hash-verified

100
101
102def install(interactive=False, on_root=False, on_pyenv=False, force=False) -> bool:
103
104 if binaryninja_installed() and not force:
105 print_error("Binary Ninja API already in the path. Use --force to overwrite.")
106 return False
107
108 api_path = get_expected_binaryninja_installed_directory()
109 if not os.path.isdir(api_path):
110 print_error("Failed to find installed python expected at {}".format(api_path))
111 return False
112
113 print(f"Found install folder of {api_path}")
114
115 while not validate_path(api_path):
116
117 print(f"Binary Ninja not found: {api_path}")
118
119 if not interactive:
120 print_error("silent mode selected (-s, --silent), failing.")
121 return False
122
123 try:
124 new_path = input("Please provide the path to Binary Ninja's install directory: \n [{}] : ".format(api_path))
125 except KeyboardInterrupt:
126 print_error("KeyboardInterrupt detected.")
127 return False
128
129 if not new_path:
130 print("Invalid path.")
131 continue
132
133 if not new_path.endswith("python"):
134 os.path.join(new_path, "python")
135
136 api_path = new_path
137
138 if on_root:
139 install_path = getsitepackage()
140 if not install_path or not os.access(install_path, os.W_OK):
141 print_error(f"Root install specified but cannot write to \"{install_path}\"")
142 return False
143 else:
144 print(f"Installing on root site: \"{install_path}\"")
145
146 elif on_pyenv:
147 install_path = getsitepackage()
148 print(f"Installing on pyenv site: \"{install_path}")
149
150 elif check_virtual_environment():
151 install_path = getsitepackage()
152 print(f"Installing on virtual environment site: \"{install_path}\"")
153
154 else:
155 if not check_enableusersite():
156 print_error("Warning, trying to write to user site packages, but check_enableusersite fails.")
157 return False
158 else:
159 install_path = getusersitepackages()

Callers 1

install_api.pyFile · 0.85

Calls 10

binaryninja_installedFunction · 0.85
print_errorFunction · 0.85
validate_pathFunction · 0.85
getsitepackageFunction · 0.85
joinMethod · 0.80
encodeMethod · 0.80
formatMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected