Skip to content
This repository
Newer
Older
100644 305 lines (257 sloc) 9.759 kb
06ef74c4 » cournape
2011-06-10 ENH: scipy.lib is implemented.
1 import os
4cf2a890 » cournape
2011-06-01 FEAT: cluster + fftpack build on darwin.
2 import sys
4c6fa4c7 » cournape
2011-06-01 ENH: create __config__.py file.
3 import os.path as op
4cf2a890 » cournape
2011-06-01 FEAT: cluster + fftpack build on darwin.
4
5 from numpy.distutils.misc_util \
6 import \
d2f22a7e » cournape
2011-06-03 ENH: add npymath configuration.
7 get_numpy_include_dirs, get_pkg_info
4cf2a890 » cournape
2011-06-01 FEAT: cluster + fftpack build on darwin.
8 from numpy.distutils.conv_template \
9 import \
10 process_str as process_c_str
06ef74c4 » cournape
2011-06-10 ENH: scipy.lib is implemented.
11 from numpy.distutils.from_template \
12 import \
13 process_str as process_f_str, resolve_includes
4cf2a890 » cournape
2011-06-01 FEAT: cluster + fftpack build on darwin.
14
15 from bento.commands import hooks
16 from bento.commands.extras.waf \
17 import \
18 ConfigureWafContext, BuildWafContext, register_options
4c6fa4c7 » cournape
2011-06-01 ENH: create __config__.py file.
19 from bento.installed_package_description \
20 import \
21 InstalledSection
4cf2a890 » cournape
2011-06-01 FEAT: cluster + fftpack build on darwin.
22
23 import waflib
24 from waflib import Options
25
26 # FIXME: add this to numpy so that we can reuse it
27 class CTemplateTask(waflib.Task.Task):
28 color = 'BLUE'
06ef74c4 » cournape
2011-06-10 ENH: scipy.lib is implemented.
29 #ext_out = ['.c', '.pyf']
4cf2a890 » cournape
2011-06-01 FEAT: cluster + fftpack build on darwin.
30 def run(self):
31 s = self.inputs[0]
32 cnt = s.read()
33 writestr = process_c_str(cnt)
34 o = self.outputs[0]
35 o.write(writestr)
36
06ef74c4 » cournape
2011-06-10 ENH: scipy.lib is implemented.
37 class FTemplateTask(waflib.Task.Task):
38 color = 'BLUE'
39 ext_out = ['.pyf']
40 def run(self):
41 s = self.inputs[0]
42 lines = resolve_includes(s.abspath())
43 writestr = process_f_str("".join(lines))
44 o = self.outputs[0]
45 o.write(writestr)
46 return 0
47
4cf2a890 » cournape
2011-06-01 FEAT: cluster + fftpack build on darwin.
48 @waflib.TaskGen.extension(".src")
49 def c_template(self, node):
06ef74c4 » cournape
2011-06-10 ENH: scipy.lib is implemented.
50 output_name = node.name.rsplit(".", 1)[0]
51 output = node.parent.find_or_declare(output_name)
52 assert output.is_bld()
53
54 ext = output.name.rsplit(".")[1]
55 if ext in ["f", "pyf", "ipyf"]:
56 tsk = self.create_task('FTemplateTask', node, output)
57 if "fc" in self.features:
58 self.source.append(output)
59 else:
60 raise ValueError("FTemplateTask without feature 'fc' ?")
61 elif ext in ["c"]:
62 tsk = self.create_task('CTemplateTask', node, output)
63 if "c" in self.features:
64 self.source.append(output)
65 else:
66 raise ValueError("FTemplateTask without feature 'c' ?")
67 else:
68 raise ValueError("Unknown extension in templating: %r" % ext)
4cf2a890 » cournape
2011-06-01 FEAT: cluster + fftpack build on darwin.
69
ab4effb4 » cournape
2011-06-03 ENH: scipy.linalg build almost complete.
70 # FIXME: abstract those module gen tasks...
71 class write_module(waflib.Task.Task):
72 color = "CYAN"
73 vars = ["CONTENT"]
74 def run(self):
75 # FIXME: put actual data here
76 self.outputs[0].write(self.env.CONTENT)
77
78 @waflib.TaskGen.feature("gen_pymodule")
79 def process_write_config(self):
80 if not hasattr(self, "content"):
81 raise ValueError("task gen %r expects a 'content' argument" % self.name)
82 else:
83 self.env.CONTENT = self.content
84 output = self.path.find_or_declare(self.target)
85 name = getattr(self, "name", None) or self.target
86
87 bento_context = self.bld.bento_context
88 b_output = bento_context.build_node.make_node(output.bldpath())
89 bento_context.outputs_registry.register_outputs(
90 "gen_pymodule", name, [b_output], bento_context.build_node, "$sitedir")
91
92 tsk = self.create_task("write_module")
93 tsk.set_outputs(output)
94 return tsk
95
4cf2a890 » cournape
2011-06-01 FEAT: cluster + fftpack build on darwin.
96 @hooks.startup
97 def startup(context):
98 context.register_context("configure", ConfigureWafContext)
99 context.register_context("build", BuildWafContext)
100
101 @hooks.options
102 def options(context):
103 register_options(context)
104
ee665f4c » cournape
2011-06-15 REF: use new hook format.
105 @hooks.pre_configure
4cf2a890 » cournape
2011-06-01 FEAT: cluster + fftpack build on darwin.
106 def pre_configure(context):
107 opts = context.waf_options_context
9c06cc5a » cournape
2011-08-27 HACK: temp hack to set up cxx/fortran compilers on windows.
108 conf = context.waf_context
109
06ef74c4 » cournape
2011-06-10 ENH: scipy.lib is implemented.
110 opts.load("compiler_cxx")
4cf2a890 » cournape
2011-06-01 FEAT: cluster + fftpack build on darwin.
111 opts.load("compiler_fc")
112 opts.load("f2py")
113 Options.options.check_fc = "gfortran"
06ef74c4 » cournape
2011-06-10 ENH: scipy.lib is implemented.
114 Options.options.check_cxx_compiler = "g++"
9c06cc5a » cournape
2011-08-27 HACK: temp hack to set up cxx/fortran compilers on windows.
115 if sys.platform == "win32" and conf.env.CC_NAME == "msvc":
116 Options.options.check_fc = "ifort"
b28f9e5c » cournape
2011-08-29 BUG: fix various arch-related issues for bento config on darwin.
117 Options.options.check_cxx_compiler = "msvc"
4cf2a890 » cournape
2011-06-01 FEAT: cluster + fftpack build on darwin.
118
06ef74c4 » cournape
2011-06-10 ENH: scipy.lib is implemented.
119 conf.load("compiler_cxx")
4cf2a890 » cournape
2011-06-01 FEAT: cluster + fftpack build on darwin.
120 conf.load("compiler_fc")
121 conf.load("f2py")
122
b28f9e5c » cournape
2011-08-29 BUG: fix various arch-related issues for bento config on darwin.
123 if conf.env.CC_NAME == 'gcc':
124 conf.env.append_value('CFLAGS_PYEXT', "-Wfatal-errors")
125 conf.env.append_value('CXXFLAGS_PYEXT', "-Wfatal-errors")
126
127 if sys.platform == "darwin":
128 # FIXME: fix upstream waf tool to work on mac os X
129 for flag in [conf.env.CFLAGS_PYEXT, conf.env.LINKFLAGS_PYEXT,
130 conf.env.CXXFLAGS_PYEXT, conf.env.FCFLAGS]:
131 remove_flag_prevalue("ppc", flag)
132 conf.env.append_value('FCFLAGS', ['-arch', 'i386'])
133 conf.env.append_value('CFLAGS', ['-arch', 'i386'])
134 conf.env["MACOSX_DEPLOYMENT_TARGET"] = "10.4"
135
136 conf.check_fortran_verbose_flag()
ab4effb4 » cournape
2011-06-03 ENH: scipy.linalg build almost complete.
137 conf.check_fortran_clib()
b47889d2 » cournape
2011-08-27 REF: no need to explicitly dependencies for check_fortran_clib.
138 conf.check_fortran_dummy_main()
59cc3500 » cournape
2011-08-26 ENH: set fortran mangling cpp macros.
139 u, du, c = conf.check_fortran_mangling()
140 _set_mangling_var(conf, u, du, c)
141
142 def _set_mangling_var(conf, u, du, case, f2pycompat=True):
143 env = conf.env
144 macros = []
145
146 if du == '_':
147 env['F77_UNDERSCORE_G77'] = 1
148 macros.append('F77_UNDERSCORE_G77')
149 if f2pycompat:
150 macros.append('UNDERSCORE_G77')
151 else:
152 env['F77_UNDERSCORE_G77'] = 0
153
154 if u == '_':
155 env['F77_NO_APPEND_FORTRAN'] = 0
156 else:
157 env['F77_NO_APPEND_FORTRAN'] = 1
158 macros.append('F77_NO_APPEND_FORTRAN')
159 if f2pycompat:
160 macros.append('NO_APPEND_FORTRAN')
161
162 if case == 'upper':
163 env['F77_UPPERCASE_FORTRAN'] = 1
164 macros.append('F77_UPPERCASE_FORTRAN')
165 if f2pycompat:
166 macros.append('UPPERCASE_FORTRAN')
167 else:
168 env['F77_UPPERCASE_FORTRAN'] = 0
169
170 env.DEFINES.extend(macros)
ab4effb4 » cournape
2011-06-03 ENH: scipy.linalg build almost complete.
171
4cf2a890 » cournape
2011-06-01 FEAT: cluster + fftpack build on darwin.
172 def remove_flag(name, flag):
173 while True:
174 if name in flag:
175 i = flag.index(name)
176 flag.pop(i)
177 else:
178 break
179
180 def remove_flag_postvalue(name, flag):
181 while True:
182 if name in flag:
183 i = flag.index(name)
184 flag.pop(i)
185 flag.pop(i)
186 else:
187 break
188
189 def remove_flag_prevalue(name, flag):
190 while True:
191 if name in flag:
192 i = flag.index(name)
193 flag.pop(i-1)
194 flag.pop(i-1)
195 else:
196 break
197
ee665f4c » cournape
2011-06-15 REF: use new hook format.
198 @hooks.post_configure
4cf2a890 » cournape
2011-06-01 FEAT: cluster + fftpack build on darwin.
199 def post_configure(context):
200 conf = context.waf_context
201
202 conf.env.INCLUDES = get_numpy_include_dirs()
203
ab4effb4 » cournape
2011-06-03 ENH: scipy.linalg build almost complete.
204 conf.env.HAS_FBLAS = False
205 conf.env.HAS_CBLAS = False
206 conf.env.HAS_FLAPACK = False
207 conf.env.HAS_CLAPACK = False
180cda7d » cournape
2011-06-11 BUG: missing atlas_version/calc_work.
208 conf.env.HAS_ATLAS = False
4c6fa4c7 » cournape
2011-06-01 ENH: create __config__.py file.
209
d011c796 » cournape
2011-08-26 ENH: add example using MKL on win32.
210 if sys.platform == "win32":
211 mkl_libs = "mkl_lapack95,mkl_blas95,mkl_intel_c,mkl_intel_thread,mkl_core,libiomp5md".split(",")
212 mkl_base = r"C:\Program Files\Intel\Compiler\11.1\051"
213 conf.env.INCLUDES.append("%s\mkl\include" % mkl_base)
214 conf.env.LIBPATH.extend(["%s\mkl\ia32\lib" % mkl_base,
215 "%s\lib\ia32" % mkl_base])
216
217 try:
218 conf.check_cc(lib=mkl_libs, msg="Checking for MKL (CBLAS)",
219 uselib_store="CBLAS")
220 conf.env.HAS_CBLAS = True
221
222 conf.check_cc(lib=mkl_libs, msg="Checking for MKL (FLAPACK)",
223 uselib_store="FLAPACK")
224 conf.env.HAS_FLAPACK = True
225
226 conf.check_cc(lib=mkl_libs, msg="Checking for MKL (FBLAS)",
227 uselib_store="FBLAS")
228 conf.env.HAS_FBLAS = True
229
230 except waflib.Errors.ConfigurationError:
231 pass
232 conf.env['FCFLAGS'] = []
233 conf.env['FCFLAGS'].extend(['/MD'])
234 elif sys.platform == "darwin":
ab4effb4 » cournape
2011-06-03 ENH: scipy.linalg build almost complete.
235 try:
236 conf.check(framework="Accelerate", msg="Checking for framework Accelerate", uselib_store="CBLAS")
237 conf.env.HAS_CBLAS = True
4c6fa4c7 » cournape
2011-06-01 ENH: create __config__.py file.
238
ab4effb4 » cournape
2011-06-03 ENH: scipy.linalg build almost complete.
239 conf.check(framework="Accelerate", msg="Checking for framework Accelerate", uselib_store="FLAPACK")
240 conf.env.HAS_FLAPACK = True
4c6fa4c7 » cournape
2011-06-01 ENH: create __config__.py file.
241
ab4effb4 » cournape
2011-06-03 ENH: scipy.linalg build almost complete.
242 conf.check(framework="Accelerate", msg="Checking for framework Accelerate", uselib_store="FBLAS")
243 conf.env.HAS_FBLAS = True
244
245 except waflib.Errors.ConfigurationError:
246 pass
247 # FIXME: bug in waf ?
248 conf.env.FRAMEWORK_ST = ["-framework"]
46d67009 » cournape
2011-06-03 ENH: quick hack to make scipy config work on linux.
249 else:
250 try:
251 conf.check_cc(lib=["f77blas", "cblas", "atlas"], uselib_store="FBLAS")
252 conf.env.HAS_FBLAS = True
253
254 conf.check_cc(lib=["cblas", "atlas"], uselib_store="CBLAS")
255 conf.env.HAS_CBLAS = True
256
257 conf.check_cc(lib=["lapack", "f77blas", "cblas", "atlas"], uselib_store="FLAPACK")
258 conf.env.HAS_FLAPACK = True
259
260 conf.check_cc(lib=["lapack", "f77blas", "cblas", "atlas"], uselib_store="CLAPACK")
261
262 conf.env.HAS_CLAPACK = True
263 except waflib.Errors.ConfigurationError:
264 pass
265
266 # FIXME: waf bug ? Did not find a way to compile both fortran and c
267 # files with -fPIC
268 fcflags = conf.env.FCFLAGS
7ef2a104 » cournape
2011-06-12 BUG: fix static lib build on linux.
269 fcflags.extend(["-fPIC"])
46d67009 » cournape
2011-06-03 ENH: quick hack to make scipy config work on linux.
270 conf.env.FCFLAGS = fcflags
ab4effb4 » cournape
2011-06-03 ENH: scipy.linalg build almost complete.
271
7ef2a104 » cournape
2011-06-12 BUG: fix static lib build on linux.
272 conf.env.CFLAGS_cstlib = ["-fPIC"]
273 conf.env.FCFLAGS_cstlib = ["-fPIC"]
274
ab4effb4 » cournape
2011-06-03 ENH: scipy.linalg build almost complete.
275 if not (conf.env.HAS_FBLAS and conf.env.HAS_FLAPACK):
276 raise waflib.Errors.ConfigurationError("You need blas and lapack")
4c6fa4c7 » cournape
2011-06-01 ENH: create __config__.py file.
277
d2f22a7e » cournape
2011-06-03 ENH: add npymath configuration.
278 npymath_info = get_pkg_info("npymath")
279 conf.parse_flags(npymath_info.cflags() + " " + npymath_info.libs(), "NPYMATH")
280
ee665f4c » cournape
2011-06-15 REF: use new hook format.
281 @hooks.pre_build
4c6fa4c7 » cournape
2011-06-01 ENH: create __config__.py file.
282 def pre_build(context):
283 bld = context.waf_context
284
285 def iregistrer(category, name, nodes, from_node, target_dir):
286 source_dir = op.join("$_srcrootdir", from_node.bldpath())
287 files = [n.path_from(from_node) for n in nodes]
288 return InstalledSection.from_source_target_directories(category, name, source_dir, target_dir, files)
289 context.isection_registry.register_category("gen_pymodule", iregistrer)
290 context.outputs_registry.register_category("gen_pymodule", "pythonfiles")
291 bld(features="gen_pymodule",
292 target="scipy/__config__.py",
293 content="""\
294 def show():
295 pass
296 """,
297 always=True)
5257acbc » cournape
2011-06-12 BUG: adding version.py.
298 bld(features="gen_pymodule",
299 target="scipy/version.py",
300 content="""\
301 version = '0.9.0'
302 short_version = version
303 is_released = True
304 """,
305 always=True)
Something went wrong with that request. Please try again.