-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathsetup.py
68 lines (58 loc) · 2.65 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
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy as np
# Selects the type of math libraries to be used; Available options: lapack, mkl
math_lib_type = "mkl"
#math_lib_type = "lapack"
# Directories including the math libraries
math_lib_dir = "${MKLROOT}/lib/intel64/"
#math_lib_dir = "/my_disk/my_name/lapack/"
# Selects whether binaries for QED is built separately; True, False
do_qed = False
sourcefile1 = ["./src/mqc/el_prop/el_propagator.pyx", "./src/mqc/el_prop/rk4.c", "./src/mqc/el_prop/exponential.c"]
sourcefile2 = ["./src/mqc/el_prop/el_propagator_xf.pyx", "./src/mqc/el_prop/rk4_xf.c"]
sourcefile3 = ["./src/mqc/el_prop/el_propagator_ct.pyx", "./src/mqc/el_prop/rk4_ct.c"]
sourcefile4 = ["./src/qm/cioverlap/cioverlap.pyx", "./src/qm/cioverlap/tdnac.c"]
sourcefile1_qed = ["./src/mqc_qed/el_prop/el_propagator.pyx", "./src/mqc_qed/el_prop/rk4.c", "./src/mqc_qed/el_prop/exponential.c"]
sourcefile2_qed = ["./src/mqc_qed/el_prop/el_propagator_xf.pyx", "./src/mqc_qed/el_prop/rk4_xf.c", "./src/mqc_qed/el_prop/exponential_xf.c"]
# External libraries to be linked
libs = []
# Directories for linking external libraries
lib_dirs = []
# Extra flags for compilation
extra_flags = []
if (math_lib_type == "lapack"):
libs += ["lapack", "refblas", "gfortran"]
lib_dirs += [math_lib_dir]
extra_flags += ["-D HAVE_LAPACK"]
elif (math_lib_type == "mkl"):
libs += ["mkl_intel_lp64", "mkl_sequential", "mkl_core", ":libmkl_avx512.so.1"]
lib_dirs += [math_lib_dir]
extra_flags += ["-D HAVE_MKL"]
else:
error_message = "Invalid type of math libraries is given!"
error_vars = f"math_lib_type = {math_lib_type}"
raise ValueError (f"( setup.py ) {error_message} ( {error_vars} )")
extensions = [
Extension("el_propagator", sources=sourcefile1, include_dirs=[np.get_include()], \
libraries=libs, library_dirs=lib_dirs),
Extension("el_propagator_xf", sources=sourcefile2, include_dirs=[np.get_include()]),
Extension("el_propagator_ct", sources=sourcefile3, include_dirs=[np.get_include()]),
Extension("cioverlap", sources=sourcefile4, include_dirs=[np.get_include()], \
libraries=libs, library_dirs=lib_dirs, extra_compile_args=extra_flags)
]
extensions_qed = [
Extension("el_propagator", sources=sourcefile1_qed, include_dirs=[np.get_include()]),
Extension("el_propagator_xf", sources=sourcefile2_qed, include_dirs=[np.get_include()])
]
if (not do_qed):
setup(
cmdclass = {"build_ext": build_ext},
ext_modules = extensions
)
else:
setup(
cmdclass = {"build_qed_ext": build_ext},
ext_modules = extensions_qed
)