/
setup.py
285 lines (246 loc) · 9.11 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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
#!/usr/bin/env python
# Copyright (C) 2003 CAMP
# Please see the accompanying LICENSE file for further information.
import os
import sys
import distutils
import distutils.util
from distutils.core import setup, Extension
from glob import glob
from os.path import join
from config import (check_packages, get_system_config, get_parallel_config,
get_scalapack_config, get_hdf5_config, check_dependencies,
write_configuration, build_interpreter, get_config_vars)
# Get the current version number:
try:
execfile('gpaw/svnversion_io.py') # write gpaw/svnversion.py and get
# svnversion
except ValueError:
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 = [('NPY_NO_DEPRECATED_API', 7)]
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.lrtddft2',
'gpaw.mpi',
'gpaw.pes',
'gpaw.response',
'gpaw.sphere',
'gpaw.tddft',
'gpaw.test',
'gpaw.test.big',
'gpaw.test.big.dcdft',
'gpaw.test.big.g2_1',
'gpaw.test.big.scf',
'gpaw.test.big.setups',
'gpaw.test.cmrtest',
'gpaw.test.fileio',
'gpaw.test.noncollinear',
'gpaw.test.parallel',
'gpaw.test.pw',
'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
hdf5 = False
# User provided customizations:
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']:
if key in vars:
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']:
if key in vars:
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']
sources = sources + glob('c/xc/*.c')
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)
extensions = [extension]
if hdf5:
hdf5_sources = ['c/hdf5.c']
get_hdf5_config(define_macros)
msg.append('* Compiling with HDF5')
hdf5_extension = Extension('_hdf5',
hdf5_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)
extensions.append(hdf5_extension)
scripts = [join('tools', script)
for script in ('gpaw-run', 'gpaw-test', 'gpaw-setup', 'gpaw-basis',
'gpaw-mpisim', 'gpaw-mapfile-bgp',
'gpaw-mapfile-cray', 'gpaw-runscript',
'gpaw-install-setups')]
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='jensj@fysik.dtu.dk',
url='http://www.fysik.dtu.dk',
license='GPLv3+',
platforms=['unix'],
packages=packages,
ext_modules=extensions,
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='jensj@fysik.dtu.dk',
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