1
1
import urllib .request
2
2
import tarfile
3
+ import zipfile
3
4
import os
4
5
5
6
# Script used to download objectbox-c shared libraries for all supported platforms. Execute by running `make get-lib`
6
7
# on first checkout of this repo and any time after changing the objectbox-c lib version.
7
8
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'
9
11
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/"
12
13
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
15
15
out_dir = "objectbox/lib"
16
- file_hashes = {
16
+ files = {
17
17
# 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 " ,
19
19
20
20
# 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" ,
24
25
25
26
# mac
26
- "x86_64 /libobjectbox.dylib" : "46f53f156846659bf39ad6675fa0ee8156e859fe " ,
27
+ "macos-universal /libobjectbox.dylib" : "macos-universal.zip " ,
27
28
28
29
# windows
29
- "AMD64/objectbox.dll" : "ca33edce272a279b24f87dc0d4cf5bbdcffbc187 " ,
30
+ "AMD64/objectbox.dll" : "windows-x64.zip " ,
30
31
}
31
32
32
-
33
33
def 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 ]
36
35
37
36
38
37
def fullmkdir (path : str ):
@@ -49,17 +48,21 @@ def download(rel_path: str):
49
48
fullmkdir (os .path .dirname (out_path ))
50
49
51
50
# 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 )
53
53
54
54
# extract the file
55
- archive = tarfile .open (tmp_file , mode = 'r:gz' )
56
- archived_file = archive .extractfile (archive_dir + "/" + basename )
57
55
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 ())
61
64
62
65
63
66
# execute the download for each item in the file hashes
64
- for key in file_hashes :
67
+ for key in files :
65
68
download (key )
0 commit comments