Skip to content

Commit f10c198

Browse files
Download to proper libs folder
1 parent b78d38f commit f10c198

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

python/okapi/okapi_utils.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,11 @@ def download_binaries(force_download=True):
151151
"""
152152
Download the latest released binaries from github
153153
"""
154-
extract_dir = abspath(join(dirname(abspath(__file__)), 'okapi'))
154+
extract_dir = abspath(join(dirname(abspath(__file__)), 'libs'))
155155
# Remove the binaries for other environments.
156-
copy_from, copy_to = get_os_arch_binary(extract_dir)
156+
copy_from = get_os_arch_binary(extract_dir)
157157

158-
if not force_download and os.path.exists(abspath(join(copy_to, basename(copy_from)))):
158+
if not force_download and os.path.exists(abspath(join(extract_dir, basename(copy_from)))):
159159
return
160160

161161
latest_release = requests.get('https://api.github.com/repos/trinsic-id/okapi/releases/latest').json()
@@ -165,8 +165,8 @@ def download_binaries(force_download=True):
165165
zip_download = requests.get(libs_asset['browser_download_url'], stream=True)
166166
z = zipfile.ZipFile(io.BytesIO(zip_download.content))
167167
z.extractall(extract_dir)
168-
shutil.copy2(copy_from, copy_to)
169-
cleanup_zip_download(copy_to)
168+
shutil.copy2(copy_from, extract_dir)
169+
cleanup_zip_download(extract_dir)
170170

171171

172172
def cleanup_zip_download(copy_to):
@@ -179,21 +179,21 @@ def cleanup_zip_download(copy_to):
179179

180180
def get_os_arch_binary(extract_dir):
181181
copy_from = ''
182-
copy_to = join(extract_dir, 'libs')
182+
lib_dir = join(extract_dir, 'libs')
183183
os_name = platform.system().lower()
184184
processor_name = platform.machine().lower()
185185
if os_name == 'windows':
186-
copy_from = join(copy_to, 'windows', 'okapi.dll')
186+
copy_from = join(lib_dir, 'windows', 'okapi.dll')
187187
elif os_name == 'linux':
188188
if processor_name == 'x86_64':
189-
copy_from = join(copy_to, 'linux', 'libokapi.so')
189+
copy_from = join(lib_dir, 'linux', 'libokapi.so')
190190
elif processor_name == 'armv7l':
191-
copy_from = join(copy_to, 'linux-armv7', 'libokapi.so')
191+
copy_from = join(lib_dir, 'linux-armv7', 'libokapi.so')
192192
elif processor_name == 'aarch64':
193-
copy_from = join(copy_to, 'linux-aarch64', 'libokapi.so')
193+
copy_from = join(lib_dir, 'linux-aarch64', 'libokapi.so')
194194
elif os_name == 'darwin':
195-
copy_from = join(copy_to, 'macos', 'libokapi.dylib')
196-
return copy_from, copy_to
195+
copy_from = join(lib_dir, 'macos', 'libokapi.dylib')
196+
return copy_from
197197

198198

199199
def wrap_native_function(function_name: str, *, arg_types: Optional[List[Any]] = None,

python/tests/test_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import unittest
22

3+
from okapi.okapi_utils import download_binaries
4+
35

46
class UtilitiesTests(unittest.TestCase):
57
def test_download_binaries(self):
68
# Only run this locally, it should take 20-30 seconds the first run, and instantaneous on the second.
7-
# okapi.okapi_utils.download_binaries(False)
9+
download_binaries(False)
810
pass
911

1012

0 commit comments

Comments
 (0)