-
Notifications
You must be signed in to change notification settings - Fork 4
/
setup.py
122 lines (102 loc) · 2.79 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
import os
import os.path
import subprocess
import sys
from setuptools import Extension, setup
def build_judy() -> None:
print('INFO: building judy static library...')
CC = os.environ.get('CC', 'clang')
ARCH_FLAGS = os.environ.get('ARCHFLAGS', '')
is_clang = False
is_gcc_46 = False
# test if CC is clang/gcc-4.6
exitcode, output = subprocess.getstatusoutput('%s -v' % (CC,))
if exitcode != 0:
sys.exit(output)
if 'clang' in output:
print('INFO: compiler is Clang')
is_clang = True
elif 'gcc version 4.6' in output:
print('INFO: compiler is GCC 4.6')
is_gcc_46 = True
# adding last two flags because of compiler and/or code bugs
# see http://sourceforge.net/p/judy/mailman/message/32417284/
assert sys.maxsize == (2**63 - 1)
if is_clang or is_gcc_46:
CFLAGS = '-DJU_64BIT -O0 -fPIC -fno-strict-aliasing -Wall -D_REENTRANT -D_GNU_SOURCE -g ' + ARCH_FLAGS
else:
CFLAGS = '-DJU_64BIT -O0 -fPIC -fno-strict-aliasing -fno-aggressive-loop-optimizations'
exitcode, output = subprocess.getstatusoutput('(cd judy-1.0.5/src; CC=\'%s\' COPT=\'%s\' sh ./sh_build)' % (CC, CFLAGS))
if exitcode != 0:
sys.exit(output)
print(output)
build_judy()
setup(
ext_modules=[
Extension(
'pointless',
include_dirs=[
'./include',
],
sources=[
# python stuff
'pointless_ext.c',
# pypointless
'python/pointless_create.c',
'python/pointless_vector.c',
'python/pointless_bitvector.c',
'python/pointless_set.c',
'python/pointless_map.c',
'python/pointless_object.c',
'python/pointless_instance_dispatch.c',
'python/pointless_pyobject_hash.c',
'python/pointless_pyobject_cmp.c',
'python/pointless_print.c',
'python/pointless_prim_vector.c',
# libpointless
'src/custom_sort.c',
'src/bitutils.c',
'src/pointless_reader.c',
'src/pointless_reader_helpers.c',
'src/pointless_create.c',
'src/pointless_create_cache.c',
'src/pointless_dynarray.c',
'src/pointless_value.c',
'src/pointless_unicode_utils.c',
'src/pointless_hash.c',
'src/pointless_cmp.c',
'src/pointless_hash_table.c',
'src/pointless_bitvector.c',
'src/pointless_walk.c',
'src/pointless_cycle_marker.c',
'src/pointless_cycle_marker_wrappers.c',
'src/pointless_validate.c',
'src/pointless_validate_heap_ref.c',
'src/pointless_validate_heap.c',
'src/pointless_validate_hash_table.c',
'src/pointless_malloc.c',
'src/pointless_int_ops.c',
'src/pointless_recreate.c',
'src/pointless_eval.c'
],
extra_compile_args=[
'-I./include',
'-I./judy-1.0.5/src',
'-Wall',
'-Wno-strict-prototypes',
'-g',
'-D_GNU_SOURCE',
'-O2',
'-DNDEBUG',
'-std=c99',
],
extra_link_args=[
'-L./judy-1.0.5/src',
'-Bstatic',
'-lJudy',
'-Bdynamic',
'-lm',
],
),
],
)