-
Notifications
You must be signed in to change notification settings - Fork 7
/
setup.py
255 lines (220 loc) · 7.89 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
#!/usr/bin/env python
# Copyright (C) 2003 CAMP
# Please see the accompanying LICENSE file for further information.
import os
import sys
import re
import distutils
import distutils.util
from distutils.core import setup, Extension
from distutils.sysconfig import get_config_var
from glob import glob
from os.path import join
from config import *
# Get the current version number:
execfile('gpaw/svnversion_io.py') # write gpaw/svnversion.py and get svnversion
execfile('gpaw/version.py') # get version_base
if svnversion:
version = version_base + '.' + svnversion
else:
version = version_base
long_description = """\
A grid-based real-space Projector Augmented Wave (PAW) method Density
Functional Theory (DFT) code featuring: Flexible boundary conditions,
k-points and gradient corrected exchange-correlation functionals."""
msg = [' ']
libraries = []
library_dirs = []
include_dirs = []
extra_link_args = []
extra_compile_args = []
runtime_library_dirs = []
extra_objects = []
define_macros = []
undef_macros = []
mpi_libraries = []
mpi_library_dirs = []
mpi_include_dirs = []
mpi_runtime_library_dirs = []
mpi_define_macros = []
platform_id = ''
packages = ['gpaw',
'gpaw.analyse',
'gpaw.atom',
'gpaw.eigensolvers',
'gpaw.io',
'gpaw.lcao',
'gpaw.lrtddft',
'gpaw.mpi',
'gpaw.pes',
'gpaw.response',
'gpaw.sphere',
'gpaw.tddft',
'gpaw.test',
'gpaw.test.big',
'gpaw.test.parallel',
'gpaw.test.vdw',
'gpaw.testing',
'gpaw.transport',
'gpaw.utilities',
'gpaw.wavefunctions',
'gpaw.xc',
'gpaw.xc.gllb']
include_ase = False
if '--include-ase' in sys.argv:
include_ase = True
sys.argv.remove('--include-ase')
import_numpy = True
if '--ignore-numpy' in sys.argv:
import_numpy = False
sys.argv.remove('--ignore-numpy')
remove_default_flags = False
if '--remove-default-flags' in sys.argv:
remove_default_flags = True
sys.argv.remove('--remove-default-flags')
customize = 'customize.py'
for i, arg in enumerate(sys.argv):
if arg.startswith('--customize'):
customize = sys.argv.pop(i).split('=')[1]
break
check_packages(packages, msg, include_ase, import_numpy)
get_system_config(define_macros, undef_macros,
include_dirs, libraries, library_dirs,
extra_link_args, extra_compile_args,
runtime_library_dirs, extra_objects, msg,
import_numpy)
mpicompiler = get_parallel_config(mpi_libraries,
mpi_library_dirs,
mpi_include_dirs,
mpi_runtime_library_dirs,
mpi_define_macros)
mpilinker = mpicompiler
compiler = None
scalapack = False
#User provided customizations
if os.path.isfile(customize):
execfile(customize)
if platform_id != '':
my_platform = distutils.util.get_platform() + '-' + platform_id
def my_get_platform(): return my_platform
distutils.util.get_platform = my_get_platform
if compiler is not None:
msg += ['* Compiling gpaw with %s' % compiler]
# A hack to change the used compiler and linker:
vars = get_config_vars()
if remove_default_flags:
for key in ['BASECFLAGS', 'CFLAGS', 'OPT', 'PY_CFLAGS',
'CCSHARED', 'CFLAGSFORSHARED', 'LINKFORSHARED',
'LIBS', 'SHLIBS']:
value = vars[key].split()
# remove all gcc flags (causing problems with other compilers)
for v in list(value):
value.remove(v)
vars[key] = ' '.join(value)
for key in ['CC', 'LDSHARED']:
value = vars[key].split()
# first argument is the compiler/linker. Replace with mpicompiler:
value[0] = compiler
vars[key] = ' '.join(value)
custom_interpreter = False
# Check the command line so that custom interpreter is build only with
# 'build', 'build_ext', or 'install':
if mpicompiler is not None:
for cmd in ['build', 'build_ext', 'install']:
if cmd in sys.argv:
custom_interpreter = True
break
# apply ScaLapack settings
if scalapack:
get_scalapack_config(define_macros)
msg.append('* Compiling with ScaLapack')
# distutils clean does not remove the _gpaw.so library and gpaw-python
# binary so do it here:
plat = distutils.util.get_platform()
msg += ['* Architecture: '+plat]
plat = plat + '-' + sys.version[0:3]
gpawso = 'build/lib.%s/' % plat + '_gpaw.so'
gpawbin = 'build/bin.%s/' % plat + 'gpaw-python'
if 'clean' in sys.argv:
if os.path.isfile(gpawso):
print 'removing ', gpawso
os.remove(gpawso)
if os.path.isfile(gpawbin):
print 'removing ', gpawbin
os.remove(gpawbin)
sources = glob('c/*.c') + ['c/bmgs/bmgs.c']
# libxc sources
sources = sources + glob('c/libxc/src/*.c')
sources2remove = ['c/libxc/src/test.c',
'c/libxc/src/xc_f.c',
'c/libxc/src/work_gga_x.c',
'c/libxc/src/work_lda.c'
]
for s2r in glob('c/libxc/src/funcs_*.c'): sources2remove.append(s2r)
for s2r in sources2remove:
if s2r in sources: sources.remove(s2r)
check_dependencies(sources)
extension = Extension('_gpaw',
sources,
libraries=libraries,
library_dirs=library_dirs,
include_dirs=include_dirs,
define_macros=define_macros,
undef_macros=undef_macros,
extra_link_args=extra_link_args,
extra_compile_args=extra_compile_args,
runtime_library_dirs=runtime_library_dirs,
extra_objects=extra_objects)
scripts = [join('tools', script)
for script in ('gpaw', 'gpaw-test', 'gpaw-setup', 'gpaw-basis',
'gpaw-mpisim')]
write_configuration(define_macros, include_dirs, libraries, library_dirs,
extra_link_args, extra_compile_args,
runtime_library_dirs,extra_objects, mpicompiler,
mpi_libraries, mpi_library_dirs, mpi_include_dirs,
mpi_runtime_library_dirs, mpi_define_macros)
setup(name = 'gpaw',
version=version,
description='A grid-based real-space PAW method DFT code',
author='J. J. Mortensen, et.al.',
author_email='[email protected]',
url='http://www.fysik.dtu.dk',
license='GPLv3+',
platforms=['unix'],
packages=packages,
ext_modules=[extension],
scripts=scripts,
long_description=long_description,
)
if custom_interpreter:
scripts.append('build/bin.%s/' % plat + 'gpaw-python')
error, par_msg = build_interpreter(
define_macros, include_dirs, libraries,
library_dirs, extra_link_args, extra_compile_args,
runtime_library_dirs, extra_objects,
mpicompiler, mpilinker, mpi_libraries,
mpi_library_dirs,
mpi_include_dirs,
mpi_runtime_library_dirs, mpi_define_macros)
msg += par_msg
# install also gpaw-python
if 'install' in sys.argv and error == 0:
setup(name='gpaw',
version=version,
description='A grid-based real-space PAW method DFT code',
author='J. J. Mortensen, et.al.',
author_email='[email protected]',
url='http://www.fysik.dtu.dk',
license='GPLv3+',
platforms=['unix'],
packages=packages,
ext_modules=[extension],
scripts=scripts,
long_description=long_description,
)
else:
msg += ['* Only a serial version of gpaw was built!']
# Messages make sense only when building
if 'build' in sys.argv or 'build_ext' in sys.argv or 'install' in sys.argv:
for line in msg:
print line