Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 314 lines (264 sloc) 10.045 kb
06ef74c4 »
2011-06-10 ENH: scipy.lib is implemented.
1 import os
4cf2a890 »
2011-06-01 FEAT: cluster + fftpack build on darwin.
2 import sys
4c6fa4c7 »
2011-06-01 ENH: create __config__.py file.
3 import os.path as op
4cf2a890 »
2011-06-01 FEAT: cluster + fftpack build on darwin.
4
5 from numpy.distutils.misc_util \
6 import \
d2f22a7e »
2011-06-03 ENH: add npymath configuration.
7 get_numpy_include_dirs, get_pkg_info
4cf2a890 »
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 »
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 »
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 »
2011-06-01 ENH: create __config__.py file.
19 from bento.installed_package_description \
20 import \
21 InstalledSection
4cf2a890 »
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 »
2011-06-10 ENH: scipy.lib is implemented.
29 #ext_out = ['.c', '.pyf']
4cf2a890 »
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 »
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 »
2011-06-01 FEAT: cluster + fftpack build on darwin.
48 @waflib.TaskGen.extension(".src")
49 def c_template(self, node):
06ef74c4 »
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:
6907a2bf »
2012-02-05 BLD: fix Bento build
60 raise ValueError("FTemplateTask without feature 'fc': %r" % node)
06ef74c4 »
2011-06-10 ENH: scipy.lib is implemented.
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:
6907a2bf »
2012-02-05 BLD: fix Bento build
66 raise ValueError("CTemplateTask without feature 'c': %r" % node)
06ef74c4 »
2011-06-10 ENH: scipy.lib is implemented.
67 else:
68 raise ValueError("Unknown extension in templating: %r" % ext)
4cf2a890 »
2011-06-01 FEAT: cluster + fftpack build on darwin.
69
ab4effb4 »
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 »
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 »
2011-06-15 REF: use new hook format.
105 @hooks.pre_configure
4cf2a890 »
2011-06-01 FEAT: cluster + fftpack build on darwin.
106 def pre_configure(context):
107 opts = context.waf_options_context
9c06cc5a »
2011-08-27 HACK: temp hack to set up cxx/fortran compilers on windows.
108 conf = context.waf_context
109
06ef74c4 »
2011-06-10 ENH: scipy.lib is implemented.
110 opts.load("compiler_cxx")
4cf2a890 »
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 »
2011-06-10 ENH: scipy.lib is implemented.
114 Options.options.check_cxx_compiler = "g++"
9c06cc5a »
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 »
2011-08-29 BUG: fix various arch-related issues for bento config on darwin.
117 Options.options.check_cxx_compiler = "msvc"
4cf2a890 »
2011-06-01 FEAT: cluster + fftpack build on darwin.
118
06ef74c4 »
2011-06-10 ENH: scipy.lib is implemented.
119 conf.load("compiler_cxx")
4cf2a890 »
2011-06-01 FEAT: cluster + fftpack build on darwin.
120 conf.load("compiler_fc")
121 conf.load("f2py")
122
b28f9e5c »
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":
74d823b3 »
2012-01-05 FIX: bento support for vanilla gfortran under OSX
128 conf.env.stash()
b28f9e5c »
2011-08-29 BUG: fix various arch-related issues for bento config on darwin.
129 # FIXME: fix upstream waf tool to work on mac os X
130 for flag in [conf.env.CFLAGS_PYEXT, conf.env.LINKFLAGS_PYEXT,
131 conf.env.CXXFLAGS_PYEXT, conf.env.FCFLAGS]:
132 remove_flag_prevalue("ppc", flag)
74d823b3 »
2012-01-05 FIX: bento support for vanilla gfortran under OSX
133 try:
134 conf.env.append_value('FCFLAGS', ['-arch', 'i386'])
135 conf.env.append_value('CFLAGS', ['-arch', 'i386'])
136 conf.check_fortran()
137 except waflib.Errors.ConfigurationError:
138 # vanilla gcc (like the one provided by macports) does not
139 # support the -arch flag.
140 conf.env.revert()
141
b28f9e5c »
2011-08-29 BUG: fix various arch-related issues for bento config on darwin.
142 conf.env["MACOSX_DEPLOYMENT_TARGET"] = "10.4"
143
144 conf.check_fortran_verbose_flag()
ab4effb4 »
2011-06-03 ENH: scipy.linalg build almost complete.
145 conf.check_fortran_clib()
b47889d2 »
2011-08-27 REF: no need to explicitly dependencies for check_fortran_clib.
146 conf.check_fortran_dummy_main()
59cc3500 »
2011-08-26 ENH: set fortran mangling cpp macros.
147 u, du, c = conf.check_fortran_mangling()
148 _set_mangling_var(conf, u, du, c)
149
150 def _set_mangling_var(conf, u, du, case, f2pycompat=True):
151 env = conf.env
152 macros = []
153
154 if du == '_':
155 env['F77_UNDERSCORE_G77'] = 1
156 macros.append('F77_UNDERSCORE_G77')
157 if f2pycompat:
158 macros.append('UNDERSCORE_G77')
159 else:
160 env['F77_UNDERSCORE_G77'] = 0
161
162 if u == '_':
163 env['F77_NO_APPEND_FORTRAN'] = 0
164 else:
165 env['F77_NO_APPEND_FORTRAN'] = 1
166 macros.append('F77_NO_APPEND_FORTRAN')
167 if f2pycompat:
168 macros.append('NO_APPEND_FORTRAN')
169
170 if case == 'upper':
171 env['F77_UPPERCASE_FORTRAN'] = 1
172 macros.append('F77_UPPERCASE_FORTRAN')
173 if f2pycompat:
174 macros.append('UPPERCASE_FORTRAN')
175 else:
176 env['F77_UPPERCASE_FORTRAN'] = 0
177
178 env.DEFINES.extend(macros)
ab4effb4 »
2011-06-03 ENH: scipy.linalg build almost complete.
179
4cf2a890 »
2011-06-01 FEAT: cluster + fftpack build on darwin.
180 def remove_flag(name, flag):
181 while True:
182 if name in flag:
183 i = flag.index(name)
184 flag.pop(i)
185 else:
186 break
187
188 def remove_flag_postvalue(name, flag):
189 while True:
190 if name in flag:
191 i = flag.index(name)
192 flag.pop(i)
193 flag.pop(i)
194 else:
195 break
196
197 def remove_flag_prevalue(name, flag):
198 while True:
199 if name in flag:
200 i = flag.index(name)
201 flag.pop(i-1)
202 flag.pop(i-1)
203 else:
204 break
205
ee665f4c »
2011-06-15 REF: use new hook format.
206 @hooks.post_configure
4cf2a890 »
2011-06-01 FEAT: cluster + fftpack build on darwin.
207 def post_configure(context):
208 conf = context.waf_context
209
210 conf.env.INCLUDES = get_numpy_include_dirs()
211
ab4effb4 »
2011-06-03 ENH: scipy.linalg build almost complete.
212 conf.env.HAS_FBLAS = False
213 conf.env.HAS_CBLAS = False
214 conf.env.HAS_FLAPACK = False
215 conf.env.HAS_CLAPACK = False
180cda7d »
2011-06-11 BUG: missing atlas_version/calc_work.
216 conf.env.HAS_ATLAS = False
4c6fa4c7 »
2011-06-01 ENH: create __config__.py file.
217
d011c796 »
2011-08-26 ENH: add example using MKL on win32.
218 if sys.platform == "win32":
219 mkl_libs = "mkl_lapack95,mkl_blas95,mkl_intel_c,mkl_intel_thread,mkl_core,libiomp5md".split(",")
220 mkl_base = r"C:\Program Files\Intel\Compiler\11.1\051"
221 conf.env.INCLUDES.append("%s\mkl\include" % mkl_base)
222 conf.env.LIBPATH.extend(["%s\mkl\ia32\lib" % mkl_base,
223 "%s\lib\ia32" % mkl_base])
224
225 try:
226 conf.check_cc(lib=mkl_libs, msg="Checking for MKL (CBLAS)",
227 uselib_store="CBLAS")
228 conf.env.HAS_CBLAS = True
229
230 conf.check_cc(lib=mkl_libs, msg="Checking for MKL (FLAPACK)",
231 uselib_store="FLAPACK")
232 conf.env.HAS_FLAPACK = True
233
234 conf.check_cc(lib=mkl_libs, msg="Checking for MKL (FBLAS)",
235 uselib_store="FBLAS")
236 conf.env.HAS_FBLAS = True
237
238 except waflib.Errors.ConfigurationError:
239 pass
240 conf.env['FCFLAGS'] = []
241 conf.env['FCFLAGS'].extend(['/MD'])
242 elif sys.platform == "darwin":
ab4effb4 »
2011-06-03 ENH: scipy.linalg build almost complete.
243 try:
244 conf.check(framework="Accelerate", msg="Checking for framework Accelerate", uselib_store="CBLAS")
245 conf.env.HAS_CBLAS = True
4c6fa4c7 »
2011-06-01 ENH: create __config__.py file.
246
ab4effb4 »
2011-06-03 ENH: scipy.linalg build almost complete.
247 conf.check(framework="Accelerate", msg="Checking for framework Accelerate", uselib_store="FLAPACK")
248 conf.env.HAS_FLAPACK = True
4c6fa4c7 »
2011-06-01 ENH: create __config__.py file.
249
ab4effb4 »
2011-06-03 ENH: scipy.linalg build almost complete.
250 conf.check(framework="Accelerate", msg="Checking for framework Accelerate", uselib_store="FBLAS")
251 conf.env.HAS_FBLAS = True
252
253 except waflib.Errors.ConfigurationError:
254 pass
255 # FIXME: bug in waf ?
256 conf.env.FRAMEWORK_ST = ["-framework"]
46d67009 »
2011-06-03 ENH: quick hack to make scipy config work on linux.
257 else:
258 try:
259 conf.check_cc(lib=["f77blas", "cblas", "atlas"], uselib_store="FBLAS")
260 conf.env.HAS_FBLAS = True
261
262 conf.check_cc(lib=["cblas", "atlas"], uselib_store="CBLAS")
263 conf.env.HAS_CBLAS = True
264
265 conf.check_cc(lib=["lapack", "f77blas", "cblas", "atlas"], uselib_store="FLAPACK")
266 conf.env.HAS_FLAPACK = True
267
268 conf.check_cc(lib=["lapack", "f77blas", "cblas", "atlas"], uselib_store="CLAPACK")
269
270 conf.env.HAS_CLAPACK = True
271 except waflib.Errors.ConfigurationError:
272 pass
273
274 # FIXME: waf bug ? Did not find a way to compile both fortran and c
275 # files with -fPIC
276 fcflags = conf.env.FCFLAGS
7ef2a104 »
2011-06-12 BUG: fix static lib build on linux.
277 fcflags.extend(["-fPIC"])
46d67009 »
2011-06-03 ENH: quick hack to make scipy config work on linux.
278 conf.env.FCFLAGS = fcflags
ab4effb4 »
2011-06-03 ENH: scipy.linalg build almost complete.
279
7ef2a104 »
2011-06-12 BUG: fix static lib build on linux.
280 conf.env.CFLAGS_cstlib = ["-fPIC"]
281 conf.env.FCFLAGS_cstlib = ["-fPIC"]
282
ab4effb4 »
2011-06-03 ENH: scipy.linalg build almost complete.
283 if not (conf.env.HAS_FBLAS and conf.env.HAS_FLAPACK):
284 raise waflib.Errors.ConfigurationError("You need blas and lapack")
4c6fa4c7 »
2011-06-01 ENH: create __config__.py file.
285
d2f22a7e »
2011-06-03 ENH: add npymath configuration.
286 npymath_info = get_pkg_info("npymath")
287 conf.parse_flags(npymath_info.cflags() + " " + npymath_info.libs(), "NPYMATH")
288
ee665f4c »
2011-06-15 REF: use new hook format.
289 @hooks.pre_build
4c6fa4c7 »
2011-06-01 ENH: create __config__.py file.
290 def pre_build(context):
291 bld = context.waf_context
292
293 def iregistrer(category, name, nodes, from_node, target_dir):
294 source_dir = op.join("$_srcrootdir", from_node.bldpath())
295 files = [n.path_from(from_node) for n in nodes]
296 return InstalledSection.from_source_target_directories(category, name, source_dir, target_dir, files)
297 context.isection_registry.register_category("gen_pymodule", iregistrer)
298 context.outputs_registry.register_category("gen_pymodule", "pythonfiles")
299 bld(features="gen_pymodule",
300 target="scipy/__config__.py",
301 content="""\
302 def show():
303 pass
304 """,
305 always=True)
5257acbc »
2011-06-12 BUG: adding version.py.
306 bld(features="gen_pymodule",
307 target="scipy/version.py",
308 content="""\
309 version = '0.9.0'
310 short_version = version
311 is_released = True
312 """,
313 always=True)
Something went wrong with that request. Please try again.