Skip to content

Commit 6970cbb

Browse files
author
Ivan Dlugos
committed
update package build and c-loading for local library distribution
1 parent 519ee2a commit 6970cbb

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

objectbox/c.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,26 @@
11
import ctypes.util
2+
import os
3+
import platform
24

35
# This file contains C-API bindings based on the objectbox.h, linking to the 'objectbox' shared library
46

7+
8+
def shlib_name(library: str) -> str:
9+
"""Returns the platform-specific name of the shared library"""
10+
if platform.system() == 'Linux':
11+
return 'lib' + library + '.so'
12+
elif platform.system() == 'Windows':
13+
return library + '.dll'
14+
elif platform.system() == 'Darwin':
15+
return 'lib' + library + '.dylib'
16+
else:
17+
assert False, 'Unsupported platform: ' + platform.system()
18+
19+
520
# initialize the C library
6-
C = ctypes.CDLL(ctypes.util.find_library("objectbox"))
21+
lib_path = os.path.dirname(os.path.realpath(__file__))
22+
lib_path = os.path.join(lib_path, 'lib', platform.machine(), shlib_name('objectbox'))
23+
C = ctypes.CDLL(lib_path)
724

825
assert C.obx_version_is_at_least(0, 5, 103) == 1, \
926
"ObjectBox v0.5.103+ is not installed. " \

setup.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@
1111
long_description=long_description,
1212
long_description_content_type="text/markdown",
1313
url="https://github.com/objectbox/objectbox-python",
14-
packages=setuptools.find_packages(),
1514
python_requires='>=3.4, <4',
1615
license='Apache 2.0',
1716
classifiers=[
1817
"Development Status :: 3 - Alpha",
18+
1919
"Programming Language :: Python :: 3",
2020
"Programming Language :: Python :: 3.4",
2121
"Programming Language :: Python :: 3.5",
@@ -24,14 +24,27 @@
2424
"Programming Language :: Python :: 3.8",
2525
"Programming Language :: C",
2626
"Programming Language :: C++",
27+
28+
'Operating System :: POSIX :: Linux',
29+
# 'Operating System :: MacOS',
30+
# 'Operating System :: Microsoft :: Windows',
31+
2732
"Topic :: Database",
2833
"Topic :: Database :: Database Engines/Servers",
2934
"Topic :: Database :: Front-Ends",
3035
"Topic :: Software Development",
3136
"Topic :: Software Development :: Libraries",
37+
3238
"License :: OSI Approved :: Apache Software License",
33-
"Operating System :: OS Independent",
3439
"Intended Audience :: Developers",
3540
],
3641

42+
install_requires=[
43+
'flatbuffers==1.11',
44+
],
45+
46+
packages=setuptools.find_packages(),
47+
package_data={
48+
'objectbox': ['lib/x86_64/*'],
49+
}
3750
)

0 commit comments

Comments
 (0)