|
3 | 3 | from Cython.Distutils import build_ext |
4 | 4 | from Cython.Build import cythonize |
5 | 5 | import numpy |
6 | | -import fnmatch |
7 | 6 | import os |
8 | 7 | import glob |
9 | 8 | import re |
|
22 | 21 | ATOM_DIR = os.path.join(SRC_DIR, "atomistic", "lib") |
23 | 22 | MICRO_DIR = os.path.join(SRC_DIR, "micro", "lib") |
24 | 23 | BARYAKHTAR_DIR = os.path.join(MICRO_DIR, "baryakhtar") |
25 | | -DEMAG_DIR = os.path.join(SRC_DIR, "common","dipolar") |
| 24 | +DEMAG_DIR = os.path.join(SRC_DIR, "common", "dipolar") |
26 | 25 |
|
27 | 26 | LOCAL_DIR = os.path.join(MODULE_DIR, "local") |
28 | 27 | INCLUDE_DIR = os.path.join(LOCAL_DIR, "include") |
29 | 28 | LIB_DIR = os.path.join(LOCAL_DIR, "lib") |
30 | 29 | print("LIB_DIR={}".format(LIB_DIR)) |
31 | 30 |
|
32 | 31 |
|
33 | | -pkg_init_path = os.path.join(os.path.dirname(__file__), 'fidimag', '__init__.py') |
| 32 | +pkg_init_path = os.path.join( |
| 33 | + os.path.dirname(__file__), 'fidimag', '__init__.py') |
| 34 | + |
| 35 | + |
34 | 36 | def get_version(): |
35 | 37 | with open(pkg_init_path) as f: |
36 | 38 | for line in f: |
@@ -74,53 +76,92 @@ def glob_cfiles(path, excludes): |
74 | 76 | dipolar_sources.append(os.path.join(DEMAG_DIR, 'dipolar.pyx')) |
75 | 77 | dipolar_sources += glob_cfiles(DEMAG_DIR, excludes=["dipolar.c"]) |
76 | 78 |
|
| 79 | +com_libs = ['m', 'fftw3_omp', 'fftw3', 'sundials_cvodes', |
| 80 | + 'sundials_nvecserial'] |
| 81 | + |
| 82 | +com_args = ['-std=c99'] |
| 83 | +com_link = ['-L%s' % LIB_DIR] |
| 84 | + |
| 85 | +if 'icc' in os.environ['CC']: |
| 86 | + com_args.append('-openmp') |
| 87 | + com_link.append('-openmp') |
| 88 | +else: |
| 89 | + com_args.append('-fopenmp') |
| 90 | + com_args.append('-fopenmp') |
| 91 | + |
| 92 | + |
| 93 | +com_inc = [numpy.get_include(), INCLUDE_DIR] |
| 94 | + |
77 | 95 | ext_modules = [ |
78 | 96 | Extension("fidimag.extensions.clib", |
79 | 97 | sources=sources, |
80 | | - include_dirs=[numpy.get_include(), INCLUDE_DIR], |
81 | | - libraries=['m', 'fftw3_omp', 'fftw3', |
82 | | - 'sundials_cvodes', 'sundials_nvecserial'], |
83 | | - extra_compile_args=["-fopenmp", '-std=c99'], |
84 | | - extra_link_args=['-L%s' % LIB_DIR, '-fopenmp'], |
| 98 | + include_dirs=com_inc, |
| 99 | + libraries=com_libs, |
| 100 | + extra_compile_args=com_args, |
| 101 | + extra_link_args=com_link, |
| 102 | + ), |
| 103 | + Extension("fidimag.extensions.cvode", |
| 104 | + sources=cvode_sources, |
| 105 | + include_dirs=com_inc, |
| 106 | + libraries=com_libs, |
| 107 | + extra_compile_args=com_args, |
| 108 | + extra_link_args=com_link, |
| 109 | + ), |
| 110 | + Extension("fidimag.extensions.baryakhtar_clib", |
| 111 | + sources=baryakhtar_sources, |
| 112 | + include_dirs=com_inc, |
| 113 | + libraries=com_libs, |
| 114 | + extra_compile_args=com_args, |
| 115 | + extra_link_args=com_link, |
| 116 | + ), |
| 117 | + Extension("fidimag.extensions.micro_clib", |
| 118 | + sources=micro_sources, |
| 119 | + include_dirs=com_inc, |
| 120 | + libraries=com_libs, |
| 121 | + extra_compile_args=com_args, |
| 122 | + extra_link_args=com_link, |
| 123 | + ), |
| 124 | + Extension("fidimag.extensions.neb_clib", |
| 125 | + sources=neb_sources, |
| 126 | + include_dirs=com_inc, |
| 127 | + libraries=com_libs, |
| 128 | + extra_compile_args=com_args, |
| 129 | + extra_link_args=com_link, |
85 | 130 | ), |
86 | 131 | Extension("fidimag.extensions.cvode", |
87 | 132 | sources=cvode_sources, |
88 | | - include_dirs=[numpy.get_include(), INCLUDE_DIR], |
89 | | - libraries=[ |
90 | | - 'm', 'fftw3', 'sundials_cvodes', 'sundials_nvecserial'], |
91 | | - extra_compile_args=["-fopenmp", '-std=c99'], |
92 | | - extra_link_args=['-L%s' % LIB_DIR, '-fopenmp'], |
| 133 | + include_dirs=com_inc, |
| 134 | + libraries=com_libs, |
| 135 | + extra_compile_args=com_args, |
| 136 | + extra_link_args=com_link, |
93 | 137 | ), |
94 | 138 | Extension("fidimag.extensions.baryakhtar_clib", |
95 | 139 | sources=baryakhtar_sources, |
96 | | - include_dirs=[numpy.get_include(), INCLUDE_DIR], |
97 | | - libraries=[ |
98 | | - 'm', 'fftw3', 'sundials_cvodes', 'sundials_nvecserial'], |
99 | | - extra_compile_args=["-fopenmp", '-std=c99'], |
100 | | - extra_link_args=['-L%s' % LIB_DIR, '-fopenmp'], |
| 140 | + include_dirs=com_inc, |
| 141 | + libraries=com_libs, |
| 142 | + extra_compile_args=com_args, |
| 143 | + extra_link_args=com_link, |
101 | 144 | ), |
102 | 145 | Extension("fidimag.extensions.micro_clib", |
103 | 146 | sources=micro_sources, |
104 | | - include_dirs=[numpy.get_include(), INCLUDE_DIR], |
105 | | - libraries=[ |
106 | | - 'm', 'fftw3', 'sundials_cvodes', 'sundials_nvecserial'], |
107 | | - extra_compile_args=["-fopenmp", '-std=c99'], |
108 | | - extra_link_args=['-L%s' % LIB_DIR, '-fopenmp'], |
| 147 | + include_dirs=com_inc, |
| 148 | + libraries=com_libs, |
| 149 | + extra_compile_args=com_args, |
| 150 | + extra_link_args=com_link, |
109 | 151 | ), |
110 | 152 | Extension("fidimag.extensions.neb_clib", |
111 | 153 | sources=neb_sources, |
112 | | - include_dirs=[numpy.get_include(), INCLUDE_DIR], |
113 | | - libraries=['m', 'fftw3_omp', 'fftw3', |
114 | | - 'sundials_cvodes', 'sundials_nvecserial'], |
115 | | - extra_compile_args=["-fopenmp", '-std=c99'], |
116 | | - extra_link_args=['-L%s' % LIB_DIR, '-fopenmp'], |
| 154 | + include_dirs=com_inc, |
| 155 | + libraries=com_libs, |
| 156 | + extra_compile_args=com_args, |
| 157 | + extra_link_args=com_link, |
117 | 158 | ), |
118 | 159 | Extension("fidimag.extensions.dipolar", |
119 | | - sources = dipolar_sources, |
120 | | - include_dirs=[numpy.get_include(), INCLUDE_DIR], |
121 | | - libraries=['m', 'fftw3_omp', 'fftw3'], |
122 | | - extra_compile_args=["-fopenmp", '-std=c99'], |
123 | | - extra_link_args=['-L%s' % LIB_DIR, '-fopenmp'], |
| 160 | + sources=dipolar_sources, |
| 161 | + include_dirs=com_inc, |
| 162 | + libraries=com_libs, |
| 163 | + extra_compile_args=com_args, |
| 164 | + extra_link_args=com_link, |
124 | 165 | ), |
125 | 166 | ] |
126 | 167 |
|
|
0 commit comments