lbry-rocksdb/setup.py

96 lines
2.5 KiB
Python
Raw Normal View History

2018-01-24 16:50:59 +01:00
import platform
2021-08-18 22:41:17 +02:00
import os
from setuptools import setup
from setuptools import find_packages
from setuptools import Extension
2021-08-18 22:41:17 +02:00
try:
from Cython.Build import cythonize
except ImportError:
def cythonize(extensions):
return extensions
2014-01-13 19:52:22 +01:00
2021-08-18 22:41:17 +02:00
SOURCES = ['rocksdb/_rocksdb.cpp']
else:
SOURCES = ['rocksdb/_rocksdb.pyx']
EXTRA_COMPILE_ARGS = [
2018-01-24 16:50:59 +01:00
'-std=c++11',
2021-08-18 22:41:17 +02:00
'-fPIC',
'-Os',
2018-01-24 16:50:59 +01:00
'-Wall',
'-Wextra',
'-Wconversion',
'-fno-strict-aliasing',
'-fno-rtti',
2018-01-24 16:50:59 +01:00
]
2021-08-18 22:41:17 +02:00
LIBRARIES = ['rocksdb', 'snappy', 'bz2', 'z', 'lz4']
EXTRA_OBJECTS = []
EXTRA_LINK_ARGS = []
INCLUDE_DIRS = []
2018-01-24 16:50:59 +01:00
if platform.system() == 'Darwin':
2021-08-18 22:41:17 +02:00
EXTRA_COMPILE_ARGS += ['-mmacosx-version-min=10.7', '-stdlib=libc++']
EXTRA_LINK_ARGS += ['-Wl,-s']
if platform.system() == 'Linux':
EXTRA_LINK_ARGS += ['-Wl,--strip-all']
STATIC_LIBRARIES = [os.path.join("src", "rocksdb", item) for item in [
"librocksdb.a",
"libbz2.a",
"liblz4.a",
"libsnappy.a",
"libz.a",
"libzstd.a",
]]
if all(map(os.path.exists, STATIC_LIBRARIES)):
LIBRARIES = []
EXTRA_OBJECTS = STATIC_LIBRARIES
INCLUDE_DIRS = [
os.path.join("src", "rocksdb", "bzip2-1.0.8"),
os.path.join("src", "rocksdb", "zstd-1.4.9", "lib"),
os.path.join("src", "rocksdb", "zlib-1.2.11"),
os.path.join("src", "rocksdb", "snappy-1.1.8"),
os.path.join("src", "rocksdb", "snappy-1.1.8", "build"),
os.path.join("src", "rocksdb", "lz4-1.9.3", "lib"),
os.path.join("src", "rocksdb", "include"),
]
2018-01-24 16:50:59 +01:00
2014-01-13 19:52:22 +01:00
setup(
2017-03-23 15:13:45 +01:00
name="python-rocksdb",
2019-02-01 15:02:14 +01:00
version='0.7.0',
2021-08-18 22:41:17 +02:00
keywords=['rocksdb', 'static', 'build'],
2014-02-02 17:40:55 +01:00
description="Python bindings for RocksDB",
2021-08-18 22:41:17 +02:00
long_description=open("README.rst").read(),
2017-03-23 15:13:45 +01:00
author='Ming Hsuan Tu',
2018-01-25 16:27:57 +01:00
author_email="qrnnis2623891@gmail.com",
2017-04-23 13:33:42 +02:00
url="https://github.com/twmht/python-rocksdb",
2014-02-02 17:40:55 +01:00
license='BSD License',
setup_requires=['setuptools>=25', 'Cython>=0.20'],
install_requires=['setuptools>=25'],
2014-01-13 19:52:22 +01:00
package_dir={'rocksdb': 'rocksdb'},
packages=find_packages('.'),
2021-08-18 22:41:17 +02:00
ext_modules=cythonize([Extension(
'rocksdb._rocksdb',
2021-08-18 22:41:17 +02:00
SOURCES,
extra_compile_args=EXTRA_COMPILE_ARGS,
language='c++',
2021-08-18 22:41:17 +02:00
libraries=LIBRARIES,
include_dirs=INCLUDE_DIRS,
extra_objects=EXTRA_OBJECTS,
extra_link_args=EXTRA_LINK_ARGS,
)]),
extras_require={
"doc": ['sphinx_rtd_theme', 'sphinx'],
"test": ['pytest'],
},
2021-08-18 22:41:17 +02:00
include_package_data=False,
zip_safe=False,
2014-01-13 19:52:22 +01:00
)