Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 199 lines (169 sloc) 5.866 kB
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
1 import sys
4c6fa4c @cournape ENH: create __config__.py file.
cournape authored
2 import os.path as op
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
3
4 from numpy.distutils.misc_util \
5 import \
d2f22a7 @cournape ENH: add npymath configuration.
cournape authored
6 get_numpy_include_dirs, get_pkg_info
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
7 from numpy.distutils.conv_template \
8 import \
9 process_str as process_c_str
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
10 from numpy.distutils.from_template \
11 import \
12 process_str as process_f_str, resolve_includes
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
13
51755f2 @cournape REF: move f2py into bento itself.
cournape authored
14 from bento.backends.waf_backend \
15 import \
16 WAF_TOOLDIR
0930611 @cournape REF: use bento blas/lapack instead of custom.
cournape authored
17 from bento.backends.waf_tools \
18 import \
19 blas_lapack
4c6fa4c @cournape ENH: create __config__.py file.
cournape authored
20 from bento.installed_package_description \
21 import \
22 InstalledSection
51755f2 @cournape REF: move f2py into bento itself.
cournape authored
23 from bento.commands import hooks
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
24
25 import waflib
26 from waflib import Options
27
28 # FIXME: add this to numpy so that we can reuse it
29 class CTemplateTask(waflib.Task.Task):
30 color = 'BLUE'
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
31 #ext_out = ['.c', '.pyf']
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
32 def run(self):
33 s = self.inputs[0]
34 cnt = s.read()
35 writestr = process_c_str(cnt)
36 o = self.outputs[0]
37 o.write(writestr)
38
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
39 class FTemplateTask(waflib.Task.Task):
40 color = 'BLUE'
41 ext_out = ['.pyf']
42 def run(self):
43 s = self.inputs[0]
44 lines = resolve_includes(s.abspath())
45 writestr = process_f_str("".join(lines))
46 o = self.outputs[0]
47 o.write(writestr)
48 return 0
49
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
50 @waflib.TaskGen.extension(".src")
51 def c_template(self, node):
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
52 output_name = node.name.rsplit(".", 1)[0]
53 output = node.parent.find_or_declare(output_name)
54 assert output.is_bld()
55
56 ext = output.name.rsplit(".")[1]
57 if ext in ["f", "pyf", "ipyf"]:
58 tsk = self.create_task('FTemplateTask', node, output)
59 if "fc" in self.features:
60 self.source.append(output)
61 else:
de4d4b3 @cournape REF: remove obsolete workarounds in bscript.
cournape authored
62 raise ValueError("FTemplateTask without feature 'fc' (node: %r)?" %
63 (node,))
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
64 elif ext in ["c"]:
65 tsk = self.create_task('CTemplateTask', node, output)
66 if "c" in self.features:
67 self.source.append(output)
68 else:
6907a2b @pv BLD: fix Bento build
pv authored
69 raise ValueError("CTemplateTask without feature 'c': %r" % node)
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
70 else:
71 raise ValueError("Unknown extension in templating: %r" % ext)
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
72
ab4effb @cournape ENH: scipy.linalg build almost complete.
cournape authored
73 # FIXME: abstract those module gen tasks...
74 class write_module(waflib.Task.Task):
75 color = "CYAN"
76 vars = ["CONTENT"]
77 def run(self):
78 # FIXME: put actual data here
79 self.outputs[0].write(self.env.CONTENT)
80
81 @waflib.TaskGen.feature("gen_pymodule")
82 def process_write_config(self):
83 if not hasattr(self, "content"):
84 raise ValueError("task gen %r expects a 'content' argument" % self.name)
85 else:
86 self.env.CONTENT = self.content
87 output = self.path.find_or_declare(self.target)
88 name = getattr(self, "name", None) or self.target
89
90 bento_context = self.bld.bento_context
91 b_output = bento_context.build_node.make_node(output.bldpath())
92 bento_context.outputs_registry.register_outputs(
93 "gen_pymodule", name, [b_output], bento_context.build_node, "$sitedir")
94
95 tsk = self.create_task("write_module")
96 tsk.set_outputs(output)
97 return tsk
98
59cc350 @cournape ENH: set fortran mangling cpp macros.
cournape authored
99 def _set_mangling_var(conf, u, du, case, f2pycompat=True):
100 env = conf.env
101 macros = []
102
103 if du == '_':
104 env['F77_UNDERSCORE_G77'] = 1
105 macros.append('F77_UNDERSCORE_G77')
106 if f2pycompat:
107 macros.append('UNDERSCORE_G77')
108 else:
109 env['F77_UNDERSCORE_G77'] = 0
110
111 if u == '_':
112 env['F77_NO_APPEND_FORTRAN'] = 0
113 else:
114 env['F77_NO_APPEND_FORTRAN'] = 1
115 macros.append('F77_NO_APPEND_FORTRAN')
116 if f2pycompat:
117 macros.append('NO_APPEND_FORTRAN')
118
119 if case == 'upper':
120 env['F77_UPPERCASE_FORTRAN'] = 1
121 macros.append('F77_UPPERCASE_FORTRAN')
122 if f2pycompat:
123 macros.append('UPPERCASE_FORTRAN')
124 else:
125 env['F77_UPPERCASE_FORTRAN'] = 0
126
127 env.DEFINES.extend(macros)
ab4effb @cournape ENH: scipy.linalg build almost complete.
cournape authored
128
ee665f4 @cournape REF: use new hook format.
cournape authored
129 @hooks.post_configure
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
130 def post_configure(context):
de4d4b3 @cournape REF: remove obsolete workarounds in bscript.
cournape authored
131 opts = context.waf_options_context
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
132 conf = context.waf_context
133
de4d4b3 @cournape REF: remove obsolete workarounds in bscript.
cournape authored
134 opts.load("compiler_cxx")
135 opts.load("compiler_fc")
51755f2 @cournape REF: move f2py into bento itself.
cournape authored
136 opts.load("f2py", tooldir=[WAF_TOOLDIR])
de4d4b3 @cournape REF: remove obsolete workarounds in bscript.
cournape authored
137 Options.options.check_fc = "gfortran"
138 Options.options.check_cxx_compiler = "g++"
139 if sys.platform == "win32" and conf.env.CC_NAME == "msvc":
140 Options.options.check_fc = "ifort"
141 Options.options.check_cxx_compiler = "msvc"
142
143 conf.load("compiler_cxx")
144 conf.load("compiler_fc")
51755f2 @cournape REF: move f2py into bento itself.
cournape authored
145 conf.load("f2py", tooldir=[WAF_TOOLDIR])
146 conf.load("ordered_c", tooldir=[WAF_TOOLDIR])
ebd9038 @cournape ENH: use new arch tool on mac os x.
cournape authored
147 conf.load("arch", tooldir=[WAF_TOOLDIR])
de4d4b3 @cournape REF: remove obsolete workarounds in bscript.
cournape authored
148
149 if conf.env.CC_NAME == 'gcc':
150 conf.env.append_value('CFLAGS_PYEXT', "-Wfatal-errors")
151 conf.env.append_value('CXXFLAGS_PYEXT', "-Wfatal-errors")
152
153 if sys.platform == "darwin":
154 conf.env["MACOSX_DEPLOYMENT_TARGET"] = "10.4"
155
ebd9038 @cournape ENH: use new arch tool on mac os x.
cournape authored
156 conf.check_cc_default_arch()
157 archs = [conf.env.DEFAULT_CC_ARCH]
158 conf.env.ARCH = archs
159
de4d4b3 @cournape REF: remove obsolete workarounds in bscript.
cournape authored
160 conf.check_fortran_verbose_flag()
161 conf.check_fortran_clib()
162 conf.check_fortran_dummy_main()
163 u, du, c = conf.check_fortran_mangling()
164 _set_mangling_var(conf, u, du, c)
165
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
166 conf.env.INCLUDES = get_numpy_include_dirs()
167
0930611 @cournape REF: use bento blas/lapack instead of custom.
cournape authored
168 blas_lapack.check_blas_lapack(context)
ab4effb @cournape ENH: scipy.linalg build almost complete.
cournape authored
169 if not (conf.env.HAS_FBLAS and conf.env.HAS_FLAPACK):
170 raise waflib.Errors.ConfigurationError("You need blas and lapack")
4c6fa4c @cournape ENH: create __config__.py file.
cournape authored
171
d2f22a7 @cournape ENH: add npymath configuration.
cournape authored
172 npymath_info = get_pkg_info("npymath")
173 conf.parse_flags(npymath_info.cflags() + " " + npymath_info.libs(), "NPYMATH")
174
ee665f4 @cournape REF: use new hook format.
cournape authored
175 @hooks.pre_build
4c6fa4c @cournape ENH: create __config__.py file.
cournape authored
176 def pre_build(context):
177 bld = context.waf_context
178
d2ce154 @cournape REF: use higher-level API for output registration.
cournape authored
179 context.register_category("gen_pymodule")
4c6fa4c @cournape ENH: create __config__.py file.
cournape authored
180 bld(features="gen_pymodule",
181 target="scipy/__config__.py",
182 content="""\
183 def show():
184 pass
185 """,
186 always=True)
5257acb @cournape BUG: adding version.py.
cournape authored
187 bld(features="gen_pymodule",
188 target="scipy/version.py",
189 content="""\
190 version = '0.9.0'
191 short_version = version
192 is_released = True
193 """,
194 always=True)
0930611 @cournape REF: use bento blas/lapack instead of custom.
cournape authored
195
196 @hooks.options
197 def options(global_context):
198 blas_lapack.add_options(global_context)
Something went wrong with that request. Please try again.