-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup.py
123 lines (115 loc) · 4.21 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import sys
import os
from setuptools import setup, Extension
from Cython.Build import cythonize
sys.path.append(os.path.dirname(__file__))
import versioneer
sys.path.remove(os.path.dirname(__file__))
define_macros = []
extra_compile_args = []
extra_link_args = []
libraries = []
extra_objects = []
extra_sources = []
if sys.platform == "win32":
define_macros.extend(
[
("WIN32", None),
("_WIN32_WINNT", "0x0601"),
("LEVELDB_PLATFORM_WINDOWS", None),
("DLLX", "__declspec(dllexport)"),
]
)
extra_sources.extend(
[
"./leveldb-mcpe/port/port_win.cc",
"./leveldb-mcpe/util/env_win.cc",
"./leveldb-mcpe/util/win_logger.cc",
]
)
if sys.maxsize > 2**32: # 64 bit python
extra_objects.append("bin/zlib/win64/zlibstatic.lib")
else: # 32 bit python
extra_objects.append("bin/zlib/win32/zlibstatic.lib")
elif sys.platform in ["linux", "darwin"]:
define_macros.extend([("LEVELDB_PLATFORM_POSIX", None), ("DLLX", "")])
extra_sources.extend(
[
"./leveldb-mcpe/port/port_posix.cc",
"./leveldb-mcpe/util/env_posix.cc",
]
)
libraries.append("z")
if sys.platform == "darwin":
define_macros.append(("OS_MACOSX", None))
# shared_mutex needs MacOS 10.12+
extra_compile_args.extend(
["-mmacosx-version-min=10.12", "-Werror=partial-availability"]
)
extra_link_args.extend(["-Wl,-no_weak_imports"])
else:
raise Exception("Unsupported platform")
setup(
version=versioneer.get_version(),
cmdclass=versioneer.get_cmdclass(),
ext_modules=cythonize(
Extension(
name="leveldb._leveldb",
sources=[
"./src/leveldb/_leveldb.pyx",
"./leveldb-mcpe/db/builder.cc",
"./leveldb-mcpe/db/c.cc",
"./leveldb-mcpe/db/db_impl.cc",
"./leveldb-mcpe/db/db_iter.cc",
"./leveldb-mcpe/db/dbformat.cc",
"./leveldb-mcpe/db/filename.cc",
"./leveldb-mcpe/db/log_reader.cc",
"./leveldb-mcpe/db/log_writer.cc",
"./leveldb-mcpe/db/memtable.cc",
"./leveldb-mcpe/db/repair.cc",
"./leveldb-mcpe/db/table_cache.cc",
"./leveldb-mcpe/db/version_edit.cc",
"./leveldb-mcpe/db/version_set.cc",
"./leveldb-mcpe/db/write_batch.cc",
"./leveldb-mcpe/table/block.cc",
"./leveldb-mcpe/table/block_builder.cc",
"./leveldb-mcpe/table/filter_block.cc",
"./leveldb-mcpe/table/format.cc",
"./leveldb-mcpe/table/iterator.cc",
"./leveldb-mcpe/table/merger.cc",
"./leveldb-mcpe/table/table.cc",
"./leveldb-mcpe/table/table_builder.cc",
"./leveldb-mcpe/table/two_level_iterator.cc",
"./leveldb-mcpe/util/arena.cc",
"./leveldb-mcpe/util/bloom.cc",
"./leveldb-mcpe/util/cache.cc",
"./leveldb-mcpe/util/coding.cc",
"./leveldb-mcpe/util/comparator.cc",
"./leveldb-mcpe/util/crc32c.cc",
"./leveldb-mcpe/util/env.cc",
"./leveldb-mcpe/util/filter_policy.cc",
"./leveldb-mcpe/util/hash.cc",
"./leveldb-mcpe/util/histogram.cc",
"./leveldb-mcpe/util/logging.cc",
"./leveldb-mcpe/util/options.cc",
"./leveldb-mcpe/util/status.cc",
"./leveldb-mcpe/db/zlib_compressor.cc",
"./leveldb-mcpe/db/zstd_compressor.cc",
"./leveldb-mcpe/port/port_posix_sse.cc",
*extra_sources,
],
include_dirs=[
"zlib",
"leveldb-mcpe",
"leveldb-mcpe/include",
],
language="c++",
extra_compile_args=["-std=c++17", *extra_compile_args],
extra_link_args=extra_link_args,
extra_objects=extra_objects,
libraries=libraries,
define_macros=define_macros,
),
language_level=3,
),
)