forked from aimhubio/aimrocks
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
94 lines (78 loc) · 2.69 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import os
import sys
import platform
from glob import glob
from setuptools import setup
from setuptools import find_packages
from setuptools import Extension
from distutils.dir_util import copy_tree
from distutils.file_util import copy_file
try:
from Cython.Build import cythonize
except ImportError:
print("Warning: Cython is not installed", file=sys.stderr)
# Falling back to simpler build
cythonize = lambda x: x
aimrocks_extra_compile_args = [
'-std=c++11',
'-O3',
'-Wall',
'-Wextra',
'-Wconversion',
'-fno-strict-aliasing',
'-fno-rtti',
'-fPIC',
]
aimrocks_extra_link_args = []
if platform.system() == 'Darwin':
aimrocks_extra_compile_args += ['-mmacosx-version-min=10.7', '-stdlib=libc++']
aimrocks_extra_link_args += ["-Wl,-rpath,@loader_path"]
else:
aimrocks_extra_link_args += ["-Wl,-rpath,$ORIGIN"]
third_party_install_dir = os.environ.get('AIM_DEP_DIR', '/usr/local')
third_party_deps = ['rocksdb']
third_party_lib_dir = os.path.join(third_party_install_dir, 'lib')
third_party_libs = glob(os.path.join(third_party_lib_dir, 'librocksdb.*'))
third_party_headers = [os.path.join(third_party_install_dir, 'include/rocksdb')]
# We define a local include directory to store all the required public headers.
# The third party headers are copied into this directory to enable binding with
# the precompiled aimrocks binaries without third-party dependencies.
local_include_dir = os.path.abspath(
os.path.join(os.path.dirname(__file__), 'src/aimrocks/include')
)
local_lib_dir = os.path.abspath(
os.path.join(os.path.dirname(__file__), 'src/aimrocks')
)
print('third party libs detected:', third_party_libs)
for source in third_party_libs:
print('copying third party lib', source, local_lib_dir)
copy_file(source, local_lib_dir)
for source in third_party_headers:
basename = os.path.basename(source)
destination = os.path.join(local_include_dir, basename)
copy_tree(source, destination,
preserve_symlinks=False, update=True)
exts = [
Extension(
'aimrocks.lib_rocksdb',
['src/aimrocks/lib_rocksdb.pyx'],
extra_compile_args=aimrocks_extra_compile_args,
extra_link_args=aimrocks_extra_link_args,
language='c++',
include_dirs=[local_include_dir],
library_dirs=[third_party_lib_dir],
libraries=['rocksdb'],
)
]
setup(
name="aimrocks",
version='0.2.1',
description='RocksDB wrapper implemented in Cython.',
setup_requires=['setuptools>=25', 'Cython>=3.0.0a9'],
packages=find_packages('./src'),
package_dir={'': 'src'},
package_data={'aimrocks': ['src/*']},
ext_modules=cythonize(exts),
include_package_data=True,
zip_safe=False,
)