-
Notifications
You must be signed in to change notification settings - Fork 5
/
setup.py
executable file
·148 lines (120 loc) · 5.29 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
import sys
from numpy.distutils.core import Extension, setup
from mkldiscover import mkl_exists
__author__ = "QML Authors"
__copyright__ = "Copyright 2016"
__credits__ = ["PLZ CITE"]
__license__ = "MIT"
__version__ = "0.1"
__maintainer__ = "Anders S. Christensen"
__email__ = "andersbiceps@gmail.com"
__status__ = "Beta"
__description__ = "Quantum Machine Learning"
__url__ = "https://github.com/qmlcode/qml"
FORTRAN = "f90"
# GNU (default)
COMPILER_FLAGS = ["-O3", "-fopenmp", "-m64", "-march=native", "-fPIC",
"-Wno-maybe-uninitialized", "-Wno-unused-function", "-Wno-cpp"]
LINKER_FLAGS = ["-lgomp"]
MATH_LINKER_FLAGS = ["-lblas", "-llapack"]
# UNCOMMENT TO FORCE LINKING TO MKL with GNU compilers:
if mkl_exists(verbose=True):
LINKER_FLAGS = ["-lgomp", " -lpthread", "-lm", "-ldl"]
MATH_LINKER_FLAGS = ["-L${MKLROOT}/lib/intel64", "-lmkl_rt"]
# For clang without OpenMP: (i.e. most Apple/mac system)
if sys.platform == "darwin" and all(["gnu" not in arg for arg in sys.argv]):
COMPILER_FLAGS = ["-O3", "-m64", "-march=native", "-fPIC"]
LINKER_FLAGS = []
MATH_LINKER_FLAGS = ["-lblas", "-llapack"]
# Intel
if any(["intelem" in arg for arg in sys.argv]):
COMPILER_FLAGS = ["-xHost", "-O3", "-axAVX", "-qopenmp"]
LINKER_FLAGS = ["-liomp5", " -lpthread", "-lm", "-ldl"]
MATH_LINKER_FLAGS = ["-L${MKLROOT}/lib/intel64", "-lmkl_rt"]
ext_fkernels = Extension(name = 'qml.ml.kernels.fkernels',
sources = ['qml/ml/kernels/fkernels.f90'],
extra_f90_compile_args = COMPILER_FLAGS,
extra_f77_compile_args = COMPILER_FLAGS,
extra_compile_args = COMPILER_FLAGS,
extra_link_args = LINKER_FLAGS,
language = FORTRAN,
f2py_options=['--quiet'])
ext_farad_kernels = Extension(name = 'qml.ml.arad.farad_kernels',
sources = ['qml/ml/arad/farad_kernels.f90'],
extra_f90_compile_args = COMPILER_FLAGS,
extra_f77_compile_args = COMPILER_FLAGS,
extra_compile_args = COMPILER_FLAGS,
extra_link_args = LINKER_FLAGS,
language = FORTRAN,
f2py_options=['--quiet'])
ext_frepresentations = Extension(name = 'qml.ml.representations.frepresentations',
sources = ['qml/ml/representations/frepresentations.f90'],
extra_f90_compile_args = COMPILER_FLAGS,
extra_f77_compile_args = COMPILER_FLAGS,
extra_compile_args = COMPILER_FLAGS,
extra_link_args = MATH_LINKER_FLAGS + LINKER_FLAGS,
language = FORTRAN,
f2py_options=['--quiet'])
ext_fdistance = Extension(name = 'qml.ml.kernels.fdistance',
sources = ['qml/ml/kernels/fdistance.f90'],
extra_f90_compile_args = COMPILER_FLAGS,
extra_f77_compile_args = COMPILER_FLAGS,
extra_compile_args = COMPILER_FLAGS,
extra_link_args = LINKER_FLAGS,
language = FORTRAN,
f2py_options=['--quiet'])
ext_fslatm = Extension(name = 'qml.ml.representations.fslatm',
sources = ['qml/ml/representations/fslatm.f90'],
extra_f90_compile_args = COMPILER_FLAGS,
extra_f77_compile_args = COMPILER_FLAGS,
extra_compile_args = COMPILER_FLAGS,
extra_link_args = LINKER_FLAGS,
language = FORTRAN,
f2py_options=['--quiet'])
ext_fsolvers = Extension(name = 'qml.ml.math.fsolvers',
sources = ['qml/ml/math/fsolvers.f90'],
extra_f90_compile_args = COMPILER_FLAGS,
extra_f77_compile_args = COMPILER_FLAGS,
extra_compile_args = COMPILER_FLAGS,
extra_link_args = MATH_LINKER_FLAGS + LINKER_FLAGS,
language = FORTRAN,
f2py_options=['--quiet'])
# use README.md as long description
def readme():
with open('README.md') as f:
return f.read()
def setup_qml():
setup(
name="qml",
packages=[
'qml',
'qml.data',
'qml.ml',
'qml.ml.arad',
'qml.ml.kernels',
'qml.ml.math',
'qml.ml.representations',
'qml.models',
],
# metadata
version=__version__,
author=__author__,
author_email=__email__,
platforms = 'Any',
description = __description__,
long_description = readme(),
keywords = ['Machine Learning', 'Quantum Chemistry'],
classifiers = [],
url = __url__,
# set up compiled package contents
ext_modules = [
ext_fkernels,
ext_frepresentations,
ext_fslatm,
ext_fsolvers,
ext_fdistance,
ext_farad_kernels,
],
)
if __name__ == '__main__':
setup_qml()