-
Notifications
You must be signed in to change notification settings - Fork 38
/
setup.py
138 lines (110 loc) · 3.76 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import sys
from setuptools import setup
from setuptools.extension import Extension
from setuptools.command.build_ext import build_ext
from setuptools.command.build_clib import build_clib
from setuptools.command.bdist_egg import bdist_egg
AD3_FLAGS_UNIX = [
'-O3',
'-Wall',
'-Wno-sign-compare',
'-Wno-overloaded-virtual',
'-c',
'-fmessage-length=0',
'-fPIC',
'-ffast-math',
'-march=native'
]
AD3_FLAGS_MSVC = [
'/O2',
'/fp:fast',
'/favor:INTEL64',
'/wd4267' # suppress sign-compare--like warning
]
AD3_CFLAGS = {
'cygwin' : AD3_FLAGS_UNIX,
'mingw32' : AD3_FLAGS_UNIX,
'unix' : AD3_FLAGS_UNIX,
'msvc' : AD3_FLAGS_MSVC
}
# support compiler-specific cflags in extensions and libs
class our_build_ext(build_ext):
def build_extensions(self):
# bug in distutils: flag not valid for c++
flag = '-Wstrict-prototypes'
if (hasattr(self.compiler, 'compiler_so')
and flag in self.compiler.compiler_so):
self.compiler.compiler_so.remove(flag)
compiler_type = self.compiler.compiler_type
compile_args = AD3_CFLAGS.get(compiler_type, [])
for e in self.extensions:
e.extra_compile_args.extend(compile_args)
build_ext.build_extensions(self)
class our_build_clib(build_clib):
def build_libraries(self, libraries):
# bug in distutils: flag not valid for c++
flag = '-Wstrict-prototypes'
if (hasattr(self.compiler, 'compiler_so')
and flag in self.compiler.compiler_so):
self.compiler.compiler_so.remove(flag)
compiler_type = self.compiler.compiler_type
compile_args = AD3_CFLAGS.get(compiler_type, [])
for (lib_name, build_info) in libraries:
build_info['cflags'] = compile_args
build_clib.build_libraries(self, libraries)
# this is a backport of a workaround for a problem in distutils.
# install_lib doesn't call build_clib
class our_bdist_egg(bdist_egg):
def run(self):
self.call_command('build_clib')
bdist_egg.run(self)
cmdclass = {
'build_ext': our_build_ext,
'build_clib': our_build_clib,
'bdist_egg': our_bdist_egg}
WHEELHOUSE_UPLOADER_COMMANDS = set(['fetch_artifacts', 'upload_all'])
if WHEELHOUSE_UPLOADER_COMMANDS.intersection(sys.argv):
import wheelhouse_uploader.cmd
cmdclass.update(vars(wheelhouse_uploader.cmd))
libad3 = ('ad3', {
'language': "c++",
'sources': ['ad3/FactorGraph.cpp',
'ad3/GenericFactor.cpp',
'ad3/Factor.cpp',
'ad3/Utils.cpp',
'examples/cpp/parsing/FactorTree.cpp'
],
'include_dirs': ['.',
'./ad3',
'./Eigen',
'./examples/cpp/parsing'
],
})
setup(name='ad3',
version="2.3.dev0",
author="Andre Martins",
description='Alternating Directions Dual Decomposition',
url="http://www.ark.cs.cmu.edu/AD3",
author_email="afm@cs.cmu.edu",
package_dir={
'ad3': 'python/ad3',
'ad3.tests': 'python/ad3/tests'
},
packages=['ad3', 'ad3.tests'],
libraries=[libad3],
cmdclass=cmdclass,
include_package_data=True,
ext_modules=[
Extension("ad3.factor_graph",
["python/ad3/factor_graph.cpp"],
include_dirs=[".", "ad3"],
language="c++"),
Extension("ad3.base",
["python/ad3/base.cpp"],
include_dirs=[".", "ad3"],
language="c++"),
Extension("ad3.extensions",
["python/ad3/extensions.cpp"],
include_dirs=[".", "ad3"],
language="c++")
])