11import urllib .request
22import tarfile
3+ import zipfile
34import os
45
56# Script used to download objectbox-c shared libraries for all supported platforms. Execute by running `make get-lib`
67# on first checkout of this repo and any time after changing the objectbox-c lib version.
78
8- version = "0.10.0" # see objectbox/c.py required_version
9+ version = "v0.14.0" # see objectbox/c.py required_version
10+ variant = 'objectbox' # or 'objectbox-sync'
911
10- conan_repo = "https://dl.bintray.com/objectbox/conan/objectbox/objectbox-c"
11- conan_channel = "testing"
12+ base_url = "https://github.com/objectbox/objectbox-c/releases/download/"
1213
13- # map between ./objectbox/lib paths and hashes in the conan_repo
14- # see https://github.com/objectbox/objectbox-c/blob/main/download.sh for the hashes
14+ # map between ./objectbox/lib paths and artifact suffixes at https://github.com/objectbox/objectbox-c/releases
1515out_dir = "objectbox/lib"
16- file_hashes = {
16+ files = {
1717 # header file is the same for all platforms, get it from the linux x86_64 distributable
18- "objectbox.h" : "4db1be536558d833e52e862fd84d64d75c2b3656 " ,
18+ "objectbox.h" : "linux-x64.tar.gz " ,
1919
2020 # linux
21- "x86_64/libobjectbox.so" : "4db1be536558d833e52e862fd84d64d75c2b3656" ,
22- "armv7l/libobjectbox.so" : "4a625f0bd5f477eacd9bd35e9c44c834d057524b" ,
23- "armv6l/libobjectbox.so" : "d42930899c74345edc43f8b7519ec7645c13e4d8" ,
21+ "x86_64/libobjectbox.so" : "linux-x64.tar.gz" ,
22+ "aarch64/libobjectbox.so" : "linux-aarch64.tar.gz" ,
23+ "armv7l/libobjectbox.so" : "linux-armv7hf.tar.gz" ,
24+ "armv6l/libobjectbox.so" : "linux-armv6hf.tar.gz" ,
2425
2526 # mac
26- "x86_64 /libobjectbox.dylib" : "46f53f156846659bf39ad6675fa0ee8156e859fe " ,
27+ "macos-universal /libobjectbox.dylib" : "macos-universal.zip " ,
2728
2829 # windows
29- "AMD64/objectbox.dll" : "ca33edce272a279b24f87dc0d4cf5bbdcffbc187 " ,
30+ "AMD64/objectbox.dll" : "windows-x64.zip " ,
3031}
3132
32-
3333def url_for (rel_path : str ) -> str :
34- return conan_repo + "/" + version + "/" + conan_channel + "/0/package/" \
35- + file_hashes [rel_path ] + "/0/conan_package.tgz"
34+ return base_url + "/" + version + "/" + variant + "-" + files [rel_path ]
3635
3736
3837def fullmkdir (path : str ):
@@ -49,17 +48,21 @@ def download(rel_path: str):
4948 fullmkdir (os .path .dirname (out_path ))
5049
5150 # Download the file from `url`, save it in a temporary directory and get the path to it (e.g. '/tmp/tmpb48zma')
52- tmp_file , headers = urllib .request .urlretrieve (url_for (rel_path ))
51+ source_url = url_for (rel_path );
52+ tmp_file , headers = urllib .request .urlretrieve (source_url )
5353
5454 # extract the file
55- archive = tarfile .open (tmp_file , mode = 'r:gz' )
56- archived_file = archive .extractfile (archive_dir + "/" + basename )
5755 with open (out_path , 'wb' ) as file :
58- file .writelines (archived_file .readlines ())
59- archived_file .close ()
60- archive .close ()
56+ if source_url .endswith ('.zip' ):
57+ with zipfile .ZipFile (tmp_file ) as archive :
58+ with archive .open (archive_dir + "/" + basename ) as archived_file :
59+ file .writelines (archived_file .readlines ())
60+ else :
61+ with tarfile .open (tmp_file , mode = 'r:gz' ) as archive :
62+ with archive .extractfile (archive_dir + "/" + basename ) as archived_file :
63+ file .writelines (archived_file .readlines ())
6164
6265
6366# execute the download for each item in the file hashes
64- for key in file_hashes :
67+ for key in files :
6568 download (key )
0 commit comments