forked from wbolster/plyvel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
94 lines (77 loc) · 2.77 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 glob
import os
from os.path import join, dirname
from setuptools import setup
from setuptools.extension import Extension
import shutil
import sys
CURRENT_DIR = dirname(__file__)
with open(join(CURRENT_DIR, 'plyvel/_version.py')) as fp:
exec(fp.read(), globals(), locals())
def get_file_contents(filename):
with open(join(CURRENT_DIR, filename)) as fp:
return fp.read()
def is_leveldb_source(p):
suffix = p.split('_')[-1].split('.')[0]
return suffix not in ('test', 'bench', 'posix', 'main')
def leveldb_configure(ext, root):
ext.include_dirs = [root, join(root, 'include')]
ext.sources.extend(filter(is_leveldb_source,
glob.glob(join(root, '*/*.cc'))))
ext.sources.extend(filter(is_leveldb_source,
glob.glob(join(root, 'helpers/*/*.cc'))))
ext.sources.extend([
join(root, 'port/port_posix.cc'), join(root, 'util/env_posix.cc')])
ext.libraries = []
ext.define_macros = [
('LEVELDB_PLATFORM_POSIX', '1'),
]
def snappy_configure(ext, root):
ext.include_dirs.append(root)
ext.sources.extend([
join(root, 'snappy.cc'),
join(root, 'snappy-c.cc'),
join(root, 'snappy-sinksource.cc'),
join(root, 'snappy-stubs-internal.cc'),
])
ext.define_macros.append(('SNAPPY', '1'))
LEVELDB = Extension(
'plyvel._plyvel',
sources=['plyvel/_plyvel.cpp', 'plyvel/comparator.cpp'],
libraries=['leveldb'],
extra_compile_args=['-Wall', '-g'],
)
leveldb_root = os.environ.get('PLYVEL_LEVELDB', 'parts/leveldb')
if os.path.exists(leveldb_root):
leveldb_configure(LEVELDB, leveldb_root)
snappy_root = os.environ.get('PLYVEL_SNAPPY', 'parts/snappy')
if os.path.exists(snappy_root):
snappy_configure(LEVELDB, snappy_root)
setup(
name='plyvel',
description="Plyvel, a fast and feature-rich Python interface to LevelDB",
long_description=get_file_contents('README.rst'),
url="https://github.com/wbolster/plyvel",
version=__version__,
author="Wouter Bolsterlee",
author_email="[email protected]",
ext_modules=[LEVELDB],
packages=['plyvel'],
license="BSD License",
classifiers=[
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"Intended Audience :: Information Technology",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: BSD License",
"Operating System :: POSIX",
"Programming Language :: C++",
"Programming Language :: Cython",
"Programming Language :: Python",
"Programming Language :: Python :: 2",
"Programming Language :: Python :: 3",
"Topic :: Database",
"Topic :: Database :: Database Engines/Servers",
"Topic :: Software Development :: Libraries :: Python Modules",
]
)