Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 286 lines (242 sloc) 9.064 kb
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
1 import os
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
2 import sys
4c6fa4c @cournape ENH: create __config__.py file.
cournape authored
3 import os.path as op
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
4
5 from numpy.distutils.misc_util \
6 import \
d2f22a7 @cournape ENH: add npymath configuration.
cournape authored
7 get_numpy_include_dirs, get_pkg_info
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
8 from numpy.distutils.conv_template \
9 import \
10 process_str as process_c_str
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
11 from numpy.distutils.from_template \
12 import \
13 process_str as process_f_str, resolve_includes
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
14
15 from bento.commands import hooks
16 from bento.commands.extras.waf \
17 import \
18 ConfigureWafContext, BuildWafContext, register_options
4c6fa4c @cournape ENH: create __config__.py file.
cournape authored
19 from bento.installed_package_description \
20 import \
21 InstalledSection
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
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'
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
29 #ext_out = ['.c', '.pyf']
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
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
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
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
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
48 @waflib.TaskGen.extension(".src")
49 def c_template(self, node):
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
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)
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
69
ab4effb @cournape ENH: scipy.linalg build almost complete.
cournape authored
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
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
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
ee665f4 @cournape REF: use new hook format.
cournape authored
105 @hooks.pre_configure
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
106 def pre_configure(context):
107 opts = context.waf_options_context
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
108 opts.load("compiler_cxx")
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
109 opts.load("compiler_fc")
110 opts.load("f2py")
111 Options.options.check_fc = "gfortran"
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
112 Options.options.check_cxx_compiler = "g++"
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
113
114 conf = context.waf_context
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
115 conf.load("compiler_cxx")
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
116 conf.load("compiler_fc")
117 conf.load("f2py")
118
ab4effb @cournape ENH: scipy.linalg build almost complete.
cournape authored
119 conf.check_fortran_verbose_flag()
120 conf.check_fortran_clib()
59cc350 @cournape ENH: set fortran mangling cpp macros.
cournape authored
121 u, du, c = conf.check_fortran_mangling()
122 _set_mangling_var(conf, u, du, c)
123
124 def _set_mangling_var(conf, u, du, case, f2pycompat=True):
125 env = conf.env
126 macros = []
127
128 if du == '_':
129 env['F77_UNDERSCORE_G77'] = 1
130 macros.append('F77_UNDERSCORE_G77')
131 if f2pycompat:
132 macros.append('UNDERSCORE_G77')
133 else:
134 env['F77_UNDERSCORE_G77'] = 0
135
136 if u == '_':
137 env['F77_NO_APPEND_FORTRAN'] = 0
138 else:
139 env['F77_NO_APPEND_FORTRAN'] = 1
140 macros.append('F77_NO_APPEND_FORTRAN')
141 if f2pycompat:
142 macros.append('NO_APPEND_FORTRAN')
143
144 if case == 'upper':
145 env['F77_UPPERCASE_FORTRAN'] = 1
146 macros.append('F77_UPPERCASE_FORTRAN')
147 if f2pycompat:
148 macros.append('UPPERCASE_FORTRAN')
149 else:
150 env['F77_UPPERCASE_FORTRAN'] = 0
151
152 env.DEFINES.extend(macros)
ab4effb @cournape ENH: scipy.linalg build almost complete.
cournape authored
153
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
154 def remove_flag(name, flag):
155 while True:
156 if name in flag:
157 i = flag.index(name)
158 flag.pop(i)
159 else:
160 break
161
162 def remove_flag_postvalue(name, flag):
163 while True:
164 if name in flag:
165 i = flag.index(name)
166 flag.pop(i)
167 flag.pop(i)
168 else:
169 break
170
171 def remove_flag_prevalue(name, flag):
172 while True:
173 if name in flag:
174 i = flag.index(name)
175 flag.pop(i-1)
176 flag.pop(i-1)
177 else:
178 break
179
ee665f4 @cournape REF: use new hook format.
cournape authored
180 @hooks.post_configure
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
181 def post_configure(context):
182 conf = context.waf_context
183
184 conf.env.INCLUDES = get_numpy_include_dirs()
185
186 cflags_pyext = conf.env.CFLAGS_PYEXT
187 cflags_pyext.append("-Wfatal-errors")
188 conf.env.CFLAGS_PYEXT = cflags_pyext
189
190 if sys.platform == "darwin":
191 # FIXME: fix upstream waf tool to work on mac os X
192 conf.env.CC = ["/usr/bin/gcc-4.0"]
193 conf.env.LINK_CC = ["/usr/bin/gcc-4.0"]
194 # FIXME: fix upstream waf tool to avoid linking against libpython2.6.so
195 # (cause crashes when importing the extension)
196 name = "python%s" % ".".join([str(i) for i in sys.version_info[:2]])
197 remove_flag(name, conf.env.LIB_PYEXT)
198 remove_flag_postvalue("-compatibility_version", conf.env.CFLAGS_cshlib)
199 remove_flag_postvalue("-current_version", conf.env.CFLAGS_cshlib)
200 for flag in [conf.env.CFLAGS_PYEXT, conf.env.LINKFLAGS_PYEXT,
201 conf.env.CXXFLAGS_PYEXT, conf.env.FCFLAGS]:
202 remove_flag_prevalue("ppc", flag)
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
203 for f in [conf.env.LINKFLAGS_cxxshlib, conf.env.LINKFLAGS_cshlib]:
204 remove_flag("-dynamiclib", f)
205 f.extend(["-undefined", "dynamic_lookup", "-bundle"])
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
206 conf.env["MACOSX_DEPLOYMENT_TARGET"] = "10.4"
207
ab4effb @cournape ENH: scipy.linalg build almost complete.
cournape authored
208 conf.env.HAS_FBLAS = False
209 conf.env.HAS_CBLAS = False
210 conf.env.HAS_FLAPACK = False
211 conf.env.HAS_CLAPACK = False
180cda7 @cournape BUG: missing atlas_version/calc_work.
cournape authored
212 conf.env.HAS_ATLAS = False
4c6fa4c @cournape ENH: create __config__.py file.
cournape authored
213
ab4effb @cournape ENH: scipy.linalg build almost complete.
cournape authored
214 if sys.platform == "darwin":
215 try:
216 conf.check(framework="Accelerate", msg="Checking for framework Accelerate", uselib_store="CBLAS")
217 conf.env.HAS_CBLAS = True
4c6fa4c @cournape ENH: create __config__.py file.
cournape authored
218
ab4effb @cournape ENH: scipy.linalg build almost complete.
cournape authored
219 conf.check(framework="Accelerate", msg="Checking for framework Accelerate", uselib_store="FLAPACK")
220 conf.env.HAS_FLAPACK = True
4c6fa4c @cournape ENH: create __config__.py file.
cournape authored
221
ab4effb @cournape ENH: scipy.linalg build almost complete.
cournape authored
222 conf.check(framework="Accelerate", msg="Checking for framework Accelerate", uselib_store="FBLAS")
223 conf.env.HAS_FBLAS = True
224
225 except waflib.Errors.ConfigurationError:
226 pass
227 # FIXME: bug in waf ?
228 conf.env.FRAMEWORK_ST = ["-framework"]
46d6700 @cournape ENH: quick hack to make scipy config work on linux.
cournape authored
229 else:
230 try:
231 conf.check_cc(lib=["f77blas", "cblas", "atlas"], uselib_store="FBLAS")
232 conf.env.HAS_FBLAS = True
233
234 conf.check_cc(lib=["cblas", "atlas"], uselib_store="CBLAS")
235 conf.env.HAS_CBLAS = True
236
237 conf.check_cc(lib=["lapack", "f77blas", "cblas", "atlas"], uselib_store="FLAPACK")
238 conf.env.HAS_FLAPACK = True
239
240 conf.check_cc(lib=["lapack", "f77blas", "cblas", "atlas"], uselib_store="CLAPACK")
241
242 conf.env.HAS_CLAPACK = True
243 except waflib.Errors.ConfigurationError:
244 pass
245
246 # FIXME: waf bug ? Did not find a way to compile both fortran and c
247 # files with -fPIC
248 fcflags = conf.env.FCFLAGS
7ef2a10 @cournape BUG: fix static lib build on linux.
cournape authored
249 fcflags.extend(["-fPIC"])
46d6700 @cournape ENH: quick hack to make scipy config work on linux.
cournape authored
250 conf.env.FCFLAGS = fcflags
ab4effb @cournape ENH: scipy.linalg build almost complete.
cournape authored
251
7ef2a10 @cournape BUG: fix static lib build on linux.
cournape authored
252 conf.env.CFLAGS_cstlib = ["-fPIC"]
253 conf.env.FCFLAGS_cstlib = ["-fPIC"]
254
ab4effb @cournape ENH: scipy.linalg build almost complete.
cournape authored
255 if not (conf.env.HAS_FBLAS and conf.env.HAS_FLAPACK):
256 raise waflib.Errors.ConfigurationError("You need blas and lapack")
4c6fa4c @cournape ENH: create __config__.py file.
cournape authored
257
d2f22a7 @cournape ENH: add npymath configuration.
cournape authored
258 npymath_info = get_pkg_info("npymath")
259 conf.parse_flags(npymath_info.cflags() + " " + npymath_info.libs(), "NPYMATH")
260
ee665f4 @cournape REF: use new hook format.
cournape authored
261 @hooks.pre_build
4c6fa4c @cournape ENH: create __config__.py file.
cournape authored
262 def pre_build(context):
263 bld = context.waf_context
264
265 def iregistrer(category, name, nodes, from_node, target_dir):
266 source_dir = op.join("$_srcrootdir", from_node.bldpath())
267 files = [n.path_from(from_node) for n in nodes]
268 return InstalledSection.from_source_target_directories(category, name, source_dir, target_dir, files)
269 context.isection_registry.register_category("gen_pymodule", iregistrer)
270 context.outputs_registry.register_category("gen_pymodule", "pythonfiles")
271 bld(features="gen_pymodule",
272 target="scipy/__config__.py",
273 content="""\
274 def show():
275 pass
276 """,
277 always=True)
5257acb @cournape BUG: adding version.py.
cournape authored
278 bld(features="gen_pymodule",
279 target="scipy/version.py",
280 content="""\
281 version = '0.9.0'
282 short_version = version
283 is_released = True
284 """,
285 always=True)
Something went wrong with that request. Please try again.