add static binaries to setup.py
This commit is contained in:
parent
cb29ca9d3e
commit
9c334ae584
1 changed files with 58 additions and 10 deletions
68
setup.py
68
setup.py
|
@ -1,12 +1,23 @@
|
|||
import platform
|
||||
import os
|
||||
from setuptools import setup
|
||||
from setuptools import find_packages
|
||||
from setuptools import Extension
|
||||
|
||||
try:
|
||||
from Cython.Build import cythonize
|
||||
except ImportError:
|
||||
def cythonize(extensions):
|
||||
return extensions
|
||||
|
||||
extra_compile_args = [
|
||||
SOURCES = ['rocksdb/_rocksdb.cpp']
|
||||
else:
|
||||
SOURCES = ['rocksdb/_rocksdb.pyx']
|
||||
|
||||
EXTRA_COMPILE_ARGS = [
|
||||
'-std=c++11',
|
||||
'-O3',
|
||||
'-fPIC',
|
||||
'-Os',
|
||||
'-Wall',
|
||||
'-Wextra',
|
||||
'-Wconversion',
|
||||
|
@ -14,15 +25,49 @@ extra_compile_args = [
|
|||
'-fno-rtti',
|
||||
]
|
||||
|
||||
LIBRARIES = ['rocksdb', 'snappy', 'bz2', 'z', 'lz4']
|
||||
EXTRA_OBJECTS = []
|
||||
EXTRA_LINK_ARGS = []
|
||||
INCLUDE_DIRS = []
|
||||
|
||||
|
||||
if platform.system() == 'Darwin':
|
||||
extra_compile_args += ['-mmacosx-version-min=10.7', '-stdlib=libc++']
|
||||
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"),
|
||||
]
|
||||
|
||||
|
||||
setup(
|
||||
name="python-rocksdb",
|
||||
version='0.7.0',
|
||||
keywords=['rocksdb', 'static', 'build'],
|
||||
description="Python bindings for RocksDB",
|
||||
keywords='rocksdb',
|
||||
long_description=open("README.rst").read(),
|
||||
author='Ming Hsuan Tu',
|
||||
author_email="qrnnis2623891@gmail.com",
|
||||
url="https://github.com/twmht/python-rocksdb",
|
||||
|
@ -31,17 +76,20 @@ setup(
|
|||
install_requires=['setuptools>=25'],
|
||||
package_dir={'rocksdb': 'rocksdb'},
|
||||
packages=find_packages('.'),
|
||||
ext_modules=[Extension(
|
||||
ext_modules=cythonize([Extension(
|
||||
'rocksdb._rocksdb',
|
||||
['rocksdb/_rocksdb.pyx'],
|
||||
extra_compile_args=extra_compile_args,
|
||||
SOURCES,
|
||||
extra_compile_args=EXTRA_COMPILE_ARGS,
|
||||
language='c++',
|
||||
libraries=['rocksdb', 'snappy', 'bz2', 'z', 'lz4'],
|
||||
)],
|
||||
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'],
|
||||
},
|
||||
include_package_data=True,
|
||||
include_package_data=False,
|
||||
zip_safe=False,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue