lbry-rocksdb/setup.py

103 lines
2.8 KiB
Python
Raw Normal View History

2021-11-09 19:29:21 +01:00
import sys
2021-08-26 10:37:33 +02:00
import platform
import os
from setuptools import setup
from setuptools import find_packages
from setuptools import Extension
2021-08-26 10:37:33 +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-26 10:37:33 +02:00
SOURCES = ['rocksdb/_rocksdb.cpp']
else:
SOURCES = ['rocksdb/_rocksdb.pyx']
2021-11-09 19:29:21 +01:00
with open(os.path.join(os.path.dirname(__file__), 'rocksdb', '__init__.py'), 'r') as init_file:
version_line = [l for l in init_file.readlines() if l.startswith('__version__ = "')][0]
version = version_line.split('__version__ = "')[1][:-2]
2021-08-26 10:37:33 +02:00
EXTRA_COMPILE_ARGS = [
2018-01-24 16:50:59 +01:00
'-std=c++11',
2021-08-26 10:37:33 +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-26 10:37:33 +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-26 10:37:33 +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"),
]
2021-11-09 19:29:21 +01:00
print("✔️ all static libraries exist in expected locations")
else:
print('✘ missing static library files')
sys.exit(1)
2014-01-13 19:52:22 +01:00
setup(
2021-11-09 19:29:21 +01:00
name="lbry-rocksdb",
version=version,
2021-08-26 10:37:33 +02:00
keywords=['rocksdb', 'static', 'build'],
2014-02-02 17:40:55 +01:00
description="Python bindings for RocksDB",
2021-11-09 19:29:21 +01:00
long_description=open("README.md").read(),
long_description_content_type='text/markdown',
author='Jack Robison',
author_email="jackrobison@lbry.com",
url="https://github.com/lbryio/lbry-rocksdb",
2014-02-02 17:40:55 +01:00
license='BSD License',
2022-01-18 21:23:08 +01:00
python_requires=">=3.7.0",
2014-01-13 19:52:22 +01:00
package_dir={'rocksdb': 'rocksdb'},
packages=find_packages('.'),
2021-08-26 10:37:33 +02:00
ext_modules=cythonize([Extension(
'rocksdb._rocksdb',
2021-08-26 10:37:33 +02:00
SOURCES,
extra_compile_args=EXTRA_COMPILE_ARGS,
language='c++',
2021-08-26 10:37:33 +02:00
libraries=LIBRARIES,
include_dirs=INCLUDE_DIRS,
extra_objects=EXTRA_OBJECTS,
extra_link_args=EXTRA_LINK_ARGS,
)]),
extras_require={
2021-11-09 19:29:21 +01:00
"doc": ['sphinx_rtd_theme', 'sphinx']
},
2021-08-26 10:37:33 +02:00
include_package_data=False,
zip_safe=False,
2014-01-13 19:52:22 +01:00
)