Skip to content

Commit 3170c52

Browse files
committed
update C-API to v0.14.0
1 parent 1ebce61 commit 3170c52

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,5 @@ share/python-wheels/
2828
*.egg-info/
2929
.installed.cfg
3030
*.egg
31-
MANIFEST
31+
MANIFEST
32+
**/__pycache__

download-c-lib.py

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,37 @@
11
import urllib.request
22
import tarfile
3+
import zipfile
34
import 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
1515
out_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-
3333
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]
3635

3736

3837
def 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)

objectbox/c.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
# Version of the library used by the binding. This version is checked at runtime to ensure binary compatibility.
2626
# Don't forget to update download-c-lib.py when upgrading to a newer version.
27-
required_version = "0.10.0"
27+
required_version = "0.14.0"
2828

2929

3030
def shlib_name(library: str) -> str:
@@ -323,7 +323,7 @@ def c_voidp_as_bytes(voidp, size):
323323
# OBX_box* (OBX_store* store, obx_schema_id entity_id);
324324
obx_box = fn('obx_box', OBX_box_p, [OBX_store_p, obx_schema_id])
325325

326-
# obx_err (OBX_box* box, obx_id id, void** data, size_t* size);
326+
# obx_err (OBX_box* box, obx_id id, const void** data, size_t* size);
327327
obx_box_get = fn('obx_box_get', obx_err,
328328
[OBX_box_p, obx_id, ctypes.POINTER(ctypes.c_void_p), ctypes.POINTER(ctypes.c_size_t)])
329329

0 commit comments

Comments
 (0)