Skip to content

Commit 8985967

Browse files
author
Ivan
committed
Merge branch 'ci' into 'dev'
CI See merge request objectbox/objectbox-python!1
2 parents 2734adb + dd37032 commit 8985967

4 files changed

Lines changed: 91 additions & 14 deletions

File tree

.gitlab-ci.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
stages:
2+
- build
3+
- test
4+
5+
before_script:
6+
- pip3 install virtualenv pytest
7+
8+
build:
9+
image: python:latest
10+
stage: build
11+
script:
12+
# a function to download a library from another Gitlab repos CI artifacts
13+
- 'download_library(){ curl --create-dirs -o objectbox/lib/$1 -H "PRIVATE-TOKEN: $CI_API_TOKEN" $2; }'
14+
- 'download_library x86_64/libobjectbox.so "${OBXLIB_URL_Linux64}"'
15+
- 'download_library x86_64/libobjectbox.dylib "${OBXLIB_URL_Mac64}"'
16+
- 'download_library armv7l/libobjectbox.so "${OBXLIB_URL_LinuxARMv7hf}"'
17+
- 'download_library armv6l/libobjectbox.so "${OBXLIB_URL_LinuxARMv6hf}"'
18+
- make test
19+
- make build
20+
artifacts:
21+
expire_in: 1 days
22+
paths:
23+
- dist/*.whl
24+
25+
.test:
26+
stage: test
27+
script:
28+
- rm -r objectbox
29+
- pip3 install --force-reinstall dist/*.whl
30+
- python3 -m pytest
31+
32+
.test:linux:x64:
33+
extends: .test
34+
tags: [x64, docker, linux]
35+
36+
test:linux:x64:3.4:
37+
extends: .test:linux:x64
38+
image: python:3.4
39+
40+
test:linux:x64:3.5:
41+
extends: .test:linux:x64
42+
image: python:3.5
43+
44+
test:linux:x64:3.6:
45+
extends: .test:linux:x64
46+
image: python:3.6
47+
48+
test:linux:x64:3.7:
49+
extends: .test:linux:x64
50+
image: python:3.7
51+
52+
test:linux:x64:3.8:
53+
extends: .test:linux:x64
54+
image: python:3.8-rc
55+
56+
test:linux:armv6hf:
57+
extends: .test
58+
tags: [armv6hf, docker, linux]
59+
image: balenalib/raspberry-pi-python:3.7-stretch
60+
61+
test:linux:armv7hf:
62+
extends: .test
63+
tags: [armv7hf, docker, linux]
64+
image: python:3.7
65+
66+
test:mac:x64:
67+
extends: .test
68+
tags: [mac, x64, shell, python3]

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ ${VENV}: ${VENV}/bin/activate
99
${VENV}/bin/activate: requirements.txt
1010
test -d ${VENV} || virtualenv ${VENV}
1111
# remove packages not in the requirements.txt
12-
pip freeze | grep -v -f requirements.txt - | grep -v '^#' | grep -v '^-e ' | xargs pip uninstall -y || echo "never mind"
12+
pip3 freeze | grep -v -f requirements.txt - | grep -v '^#' | grep -v '^-e ' | xargs pip3 uninstall -y || echo "never mind"
1313
# install and upgrade based on the requirements.txt
14-
pip install --upgrade -r requirements.txt
14+
pip3 install --upgrade -r requirements.txt
1515
# let make know this is the last time requirements changed
1616
touch ${VENV}/bin/activate
1717

1818
init: ${VENV}
1919

2020
test: ${VENV}
21-
python -m pytest -s
21+
python3 -m pytest -s
2222

2323
build: ${VENV} clean
24-
python setup.py bdist_wheel
24+
python3 setup.py bdist_wheel
2525
ls -lh dist
2626

2727
clean:

objectbox/c.py

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,23 @@ class CoreException(Exception):
182182
def __init__(self, code):
183183
self.code = code
184184
self.message = py_str(C.obx_last_error_message())
185-
super(CoreException, self).__init__("%d (%s) - %s" % (code, self.codes[code], self.message))
185+
name = self.codes[code] if code in self.codes else "n/a"
186+
super(CoreException, self).__init__("%d (%s) - %s" % (code, name, self.message))
186187

187188

188-
class NotFoundException(CoreException):
189+
class NotFoundException(Exception):
189190
pass
190191

191192

192193
# assert the the returned obx_err is empty
193-
def check_obx_err(code: obx_err, func, args):
194+
def check_obx_err(code: obx_err, func, args) -> obx_err:
194195
if code == 404:
195-
raise NotFoundException(code)
196+
raise NotFoundException()
196197
elif code != 0:
197198
raise CoreException(code)
198199

200+
return code
201+
199202

200203
# assert that the returned pointer/int is non-empty
201204
def check_result(result, func, args):
@@ -208,13 +211,15 @@ def check_result(result, func, args):
208211
def fn(name: str, restype: type, argtypes):
209212
func = C.__getattr__(name)
210213

214+
func.argtypes = argtypes
215+
func.restype = restype
216+
211217
if restype is obx_err:
212218
func.errcheck = check_obx_err
219+
pass
213220
elif restype is not None:
214221
func.errcheck = check_result
215-
func.restype = restype
216222

217-
func.argtypes = argtypes
218223
return func
219224

220225

@@ -250,13 +255,13 @@ def c_voidp_as_bytes(voidp, size):
250255
obx_model_property_flags = fn('obx_model_property_flags', obx_err, [OBX_model_p, OBXPropertyFlags])
251256

252257
# obx_err (OBX_model*, obx_schema_id entity_id, obx_uid entity_uid);
253-
obx_model_last_entity_id = fn('obx_model_last_entity_id', obx_err, [OBX_model_p, obx_schema_id, obx_uid])
258+
obx_model_last_entity_id = fn('obx_model_last_entity_id', None, [OBX_model_p, obx_schema_id, obx_uid])
254259

255260
# obx_err (OBX_model* model, obx_schema_id index_id, obx_uid index_uid);
256-
obx_model_last_index_id = fn('obx_model_last_index_id', obx_err, [OBX_model_p, obx_schema_id, obx_uid])
261+
obx_model_last_index_id = fn('obx_model_last_index_id', None, [OBX_model_p, obx_schema_id, obx_uid])
257262

258263
# obx_err (OBX_model* model, obx_schema_id relation_id, obx_uid relation_uid);
259-
obx_model_last_relation_id = fn('obx_model_last_relation_id', obx_err, [OBX_model_p, obx_schema_id, obx_uid])
264+
obx_model_last_relation_id = fn('obx_model_last_relation_id', None, [OBX_model_p, obx_schema_id, obx_uid])
260265

261266
# obx_err (OBX_model* model, obx_schema_id property_id, obx_uid property_uid);
262267
obx_model_entity_last_property_id = fn('obx_model_entity_last_property_id', obx_err,

setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646

4747
packages=setuptools.find_packages(),
4848
package_data={
49-
'objectbox': ['lib/x86_64/*'],
49+
'objectbox': [
50+
'lib/x86_64/*',
51+
'lib/armv7l/*',
52+
'lib/armv6l/*',
53+
],
5054
}
5155
)

0 commit comments

Comments
 (0)