-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
74 lines (60 loc) · 1.49 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
#!/usr/bin/env python
#
# When modifying this file, always keep in mind that it has to work on both
# Python 2.x and 3.x.
#
import functools
import os
import platform
import setuptools
import sys
@functools.cache
def get_dir():
return os.path.dirname(os.path.abspath(__file__))
def get_cflags():
cflags = []
system = platform.system().lower()
if system == "linux":
cflags += [
"-ggdb",
"-Wall",
"-Wextra",
"-O2",
"-fPIC",
"-D_GNU_SOURCE",
"-D_FILE_OFFSET_BITS=64",
# "-DDEBUG"
]
elif system == "windows":
cflags += [
"/nologo",
"/Zi",
"/W3",
"/O2",
# "/D DEBUG"
]
return cflags
def get_sources():
return [
name
for name in os.listdir(get_dir())
if os.path.isfile(os.path.join(get_dir(), name)) and name.endswith(".c")
]
def main(argv):
pyrsistence_mod = setuptools.Extension(
"pyrsistence",
extra_compile_args=get_cflags(),
sources=[os.path.join(get_dir(), name) for name in get_sources()],
)
setuptools.setup(
name="pyrsistence",
version="1.1",
description="pyrsistence",
author="huku",
author_email="[email protected]",
url="https://github.com/huku-/pyrsistence",
ext_modules=[pyrsistence_mod],
)
return os.EX_OK
if __name__ == "__main__":
sys.exit(main(sys.argv))