forked from lucastheis/cmt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
executable file
·163 lines (150 loc) · 4.62 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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
#!/usr/bin/env python
import os
import sys
import numpy
sys.path.append('./code')
sys.path.append('./code/cmt')
from distutils.core import setup, Extension
from distutils.ccompiler import CCompiler, get_default_compiler
from utils import parallelCCompiler
from numpy.distutils.intelccompiler import IntelCCompiler
from numpy import any
from python import __version__
INTEL_PATH = '/opt/intel/'
# heuristic for figuring out which compiler is being used (icc, gcc)
if any(['intel' in arg for arg in sys.argv]) or 'intel' in get_default_compiler():
# icc-specific options
include_dirs=[
os.path.join(INTEL_PATH, 'mkl/include')]
library_dirs=[
os.path.join(INTEL_PATH, 'mkl/lib'),
os.path.join(INTEL_PATH, 'lib')]
libraries = [
'mkl_intel_lp64',
'mkl_intel_thread',
'mkl_core',
'mkl_def',
'iomp5']
extra_compile_args = [
'-DEIGEN_PERMANENTLY_DISABLE_STUPID_WARNINGS',
'-DEIGEN_USE_MKL_ALL',
'-Wno-deprecated',
'-wd1224',
'-openmp',
'-std=c++0x']
extra_link_args = []
for path in [os.path.join(INTEL_PATH, 'mkl/lib/intel64'), os.path.join(INTEL_PATH, 'lib/intel64')]:
if os.path.exists(path):
library_dirs += [path]
elif sys.platform == 'darwin':
# clang-specific options
include_dirs = []
library_dirs = []
libraries = []
extra_compile_args = [
'-std=c++0x',
'-Wno-deprecated-register',
'-Wno-#warnings']
extra_link_args = []
if 'CC' not in os.environ:
os.environ['CC'] = 'clang++'
if 'CXX' not in os.environ:
os.environ['CXX'] = 'clang++'
extra_compile_args.append('-stdlib=libc++')
if 'MACOSX_DEPLOYMENT_TARGET' not in os.environ:
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.7'
else:
# gcc-specific options
include_dirs = []
library_dirs = []
libraries = ['gomp']
extra_compile_args = [
'-std=c++0x',
'-Wno-cpp',
'-Wno-unused-local-typedefs',
'-fopenmp']
extra_link_args = []
modules = [
Extension('_cmt',
language='c++',
sources=[
'code/cmt/python/src/callbackinterface.cpp',
'code/cmt/python/src/conditionaldistributioninterface.cpp',
'code/cmt/python/src/distributioninterface.cpp',
'code/cmt/python/src/fvbninterface.cpp',
'code/cmt/python/src/glminterface.cpp',
'code/cmt/python/src/gsminterface.cpp',
'code/cmt/python/src/mcbminterface.cpp',
'code/cmt/python/src/mcgsminterface.cpp',
'code/cmt/python/src/module.cpp',
'code/cmt/python/src/mixtureinterface.cpp',
'code/cmt/python/src/mlrinterface.cpp',
'code/cmt/python/src/nonlinearitiesinterface.cpp',
'code/cmt/python/src/patchmodelinterface.cpp',
'code/cmt/python/src/preconditionerinterface.cpp',
'code/cmt/python/src/pyutils.cpp',
'code/cmt/python/src/stminterface.cpp',
'code/cmt/python/src/toolsinterface.cpp',
'code/cmt/python/src/trainableinterface.cpp',
'code/cmt/python/src/univariatedistributionsinterface.cpp',
'code/cmt/src/affinepreconditioner.cpp',
'code/cmt/src/affinetransform.cpp',
'code/cmt/src/binningtransform.cpp',
'code/cmt/src/conditionaldistribution.cpp',
'code/cmt/src/distribution.cpp',
'code/cmt/src/glm.cpp',
'code/cmt/src/gsm.cpp',
'code/cmt/src/mcbm.cpp',
'code/cmt/src/mcgsm.cpp',
'code/cmt/src/mixture.cpp',
'code/cmt/src/mlr.cpp',
'code/cmt/src/nonlinearities.cpp',
'code/cmt/src/patchmodel.cpp',
'code/cmt/src/pcapreconditioner.cpp',
'code/cmt/src/pcatransform.cpp',
'code/cmt/src/preconditioner.cpp',
'code/cmt/src/regularizer.cpp',
'code/cmt/src/stm.cpp',
'code/cmt/src/tools.cpp',
'code/cmt/src/trainable.cpp',
'code/cmt/src/utils.cpp',
'code/cmt/src/univariatedistributions.cpp',
'code/cmt/src/whiteningpreconditioner.cpp',
'code/cmt/src/whiteningtransform.cpp'],
include_dirs=[
'code',
'code/cmt/include',
'code/cmt/python/include',
'code/liblbfgs/include',
os.path.join(numpy.__path__[0], 'core/include/numpy')] + include_dirs,
library_dirs=[] + library_dirs,
libraries=[] + libraries,
extra_link_args=[
'-fPIC',
'code/liblbfgs/lib/.libs/liblbfgs.a'] + extra_link_args,
extra_compile_args=[
'-DEIGEN_NO_DEBUG',
'-Wno-sign-compare',
'-Wno-int-in-bool-context',
'-Wno-parentheses',
'-Wno-write-strings'] + extra_compile_args)]
if 'CC_PARALLEL' in os.environ and os.environ['CC_PARALLEL'] == '1':
# enable parallel compilation
CCompiler.compile = parallelCCompiler
setup(
name='cmt',
version=__version__,
author='Lucas Theis',
author_email='[email protected]',
description='Fast implementations of different probabilistic models.',
url='http://github.com/lucastheis/cmt',
license='MIT',
ext_modules=modules,
package_dir={'cmt': 'code/cmt/python'},
packages=[
'cmt',
'cmt.models',
'cmt.transforms',
'cmt.tools',
'cmt.utils',
'cmt.nonlinear'])