Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 230 lines (190 sloc) 6.705 kb
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
1 import sys
1040b16 @pv BLD: generate sources using Cython at setup.py time
pv authored
2 import os
3 import subprocess
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
51755f2 @cournape REF: move f2py into bento itself.
cournape authored
15 from bento.backends.waf_backend \
16 import \
17 WAF_TOOLDIR
0930611 @cournape REF: use bento blas/lapack instead of custom.
cournape authored
18 from bento.backends.waf_tools \
19 import \
20 blas_lapack
51755f2 @cournape REF: move f2py into bento itself.
cournape authored
21 from bento.commands import hooks
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
22
23 import waflib
24 from waflib import Options
25
247160a @rgommers BLD: fix generated version.py in Bento build.
rgommers authored
26 # Importing setup.py needed to get version info
27 import setup
28
29
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
30 # FIXME: add this to numpy so that we can reuse it
31 class CTemplateTask(waflib.Task.Task):
32 color = 'BLUE'
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
33 #ext_out = ['.c', '.pyf']
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
34 def run(self):
35 s = self.inputs[0]
36 cnt = s.read()
37 writestr = process_c_str(cnt)
38 o = self.outputs[0]
39 o.write(writestr)
40
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
41 class FTemplateTask(waflib.Task.Task):
42 color = 'BLUE'
43 ext_out = ['.pyf']
44 def run(self):
45 s = self.inputs[0]
46 lines = resolve_includes(s.abspath())
47 writestr = process_f_str("".join(lines))
48 o = self.outputs[0]
49 o.write(writestr)
50 return 0
51
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
52 @waflib.TaskGen.extension(".src")
53 def c_template(self, node):
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
54 output_name = node.name.rsplit(".", 1)[0]
55 output = node.parent.find_or_declare(output_name)
56 assert output.is_bld()
57
58 ext = output.name.rsplit(".")[1]
59 if ext in ["f", "pyf", "ipyf"]:
60 tsk = self.create_task('FTemplateTask', node, output)
61 if "fc" in self.features:
62 self.source.append(output)
63 else:
de4d4b3 @cournape REF: remove obsolete workarounds in bscript.
cournape authored
64 raise ValueError("FTemplateTask without feature 'fc' (node: %r)?" %
65 (node,))
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
66 elif ext in ["c"]:
67 tsk = self.create_task('CTemplateTask', node, output)
68 if "c" in self.features:
69 self.source.append(output)
70 else:
6907a2b @pv BLD: fix Bento build
pv authored
71 raise ValueError("CTemplateTask without feature 'c': %r" % node)
06ef74c @cournape ENH: scipy.lib is implemented.
cournape authored
72 else:
73 raise ValueError("Unknown extension in templating: %r" % ext)
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
74
ab4effb @cournape ENH: scipy.linalg build almost complete.
cournape authored
75 # FIXME: abstract those module gen tasks...
76 class write_module(waflib.Task.Task):
77 color = "CYAN"
78 vars = ["CONTENT"]
79 def run(self):
80 # FIXME: put actual data here
81 self.outputs[0].write(self.env.CONTENT)
82
83 @waflib.TaskGen.feature("gen_pymodule")
84 def process_write_config(self):
85 if not hasattr(self, "content"):
86 raise ValueError("task gen %r expects a 'content' argument" % self.name)
87 else:
88 self.env.CONTENT = self.content
89 output = self.path.find_or_declare(self.target)
90 name = getattr(self, "name", None) or self.target
91
92 bento_context = self.bld.bento_context
93 b_output = bento_context.build_node.make_node(output.bldpath())
94 bento_context.outputs_registry.register_outputs(
95 "gen_pymodule", name, [b_output], bento_context.build_node, "$sitedir")
96
97 tsk = self.create_task("write_module")
98 tsk.set_outputs(output)
99 return tsk
100
59cc350 @cournape ENH: set fortran mangling cpp macros.
cournape authored
101 def _set_mangling_var(conf, u, du, case, f2pycompat=True):
102 env = conf.env
103 macros = []
104
105 if du == '_':
106 env['F77_UNDERSCORE_G77'] = 1
107 macros.append('F77_UNDERSCORE_G77')
108 if f2pycompat:
109 macros.append('UNDERSCORE_G77')
110 else:
111 env['F77_UNDERSCORE_G77'] = 0
112
113 if u == '_':
114 env['F77_NO_APPEND_FORTRAN'] = 0
115 else:
116 env['F77_NO_APPEND_FORTRAN'] = 1
117 macros.append('F77_NO_APPEND_FORTRAN')
118 if f2pycompat:
119 macros.append('NO_APPEND_FORTRAN')
120
121 if case == 'upper':
122 env['F77_UPPERCASE_FORTRAN'] = 1
123 macros.append('F77_UPPERCASE_FORTRAN')
124 if f2pycompat:
125 macros.append('UPPERCASE_FORTRAN')
126 else:
127 env['F77_UPPERCASE_FORTRAN'] = 0
128
129 env.DEFINES.extend(macros)
ab4effb @cournape ENH: scipy.linalg build almost complete.
cournape authored
130
1040b16 @pv BLD: generate sources using Cython at setup.py time
pv authored
131 def _generate_cython():
eaae6d1 @rgommers BLD: fix Cythonizing sources in Bento build.
rgommers authored
132 print("Cythonizing sources")
8c67a67 @pv BUG: setup.py: pass non-prefixed scipy path to cythonize, but set cwd
pv authored
133 cwd = os.path.abspath(os.path.dirname(__file__))
eaae6d1 @rgommers BLD: fix Cythonizing sources in Bento build.
rgommers authored
134 p = subprocess.call([sys.executable,
135 os.path.join(cwd, 'tools', 'cythonize.py'),
136 'scipy'],
137 cwd=cwd)
138 if p != 0:
139 raise RuntimeError("Running cythonize failed!")
1040b16 @pv BLD: generate sources using Cython at setup.py time
pv authored
140
ee665f4 @cournape REF: use new hook format.
cournape authored
141 @hooks.post_configure
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
142 def post_configure(context):
de4d4b3 @cournape REF: remove obsolete workarounds in bscript.
cournape authored
143 opts = context.waf_options_context
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
144 conf = context.waf_context
145
de4d4b3 @cournape REF: remove obsolete workarounds in bscript.
cournape authored
146 opts.load("compiler_cxx")
147 opts.load("compiler_fc")
51755f2 @cournape REF: move f2py into bento itself.
cournape authored
148 opts.load("f2py", tooldir=[WAF_TOOLDIR])
de4d4b3 @cournape REF: remove obsolete workarounds in bscript.
cournape authored
149 Options.options.check_fc = "gfortran"
150 Options.options.check_cxx_compiler = "g++"
151 if sys.platform == "win32" and conf.env.CC_NAME == "msvc":
152 Options.options.check_fc = "ifort"
153 Options.options.check_cxx_compiler = "msvc"
154
155 conf.load("compiler_cxx")
156 conf.load("compiler_fc")
51755f2 @cournape REF: move f2py into bento itself.
cournape authored
157 conf.load("f2py", tooldir=[WAF_TOOLDIR])
158 conf.load("ordered_c", tooldir=[WAF_TOOLDIR])
ebd9038 @cournape ENH: use new arch tool on mac os x.
cournape authored
159 conf.load("arch", tooldir=[WAF_TOOLDIR])
de4d4b3 @cournape REF: remove obsolete workarounds in bscript.
cournape authored
160
161 if conf.env.CC_NAME == 'gcc':
162 conf.env.append_value('CFLAGS_PYEXT', "-Wfatal-errors")
163 conf.env.append_value('CXXFLAGS_PYEXT', "-Wfatal-errors")
164
165 if sys.platform == "darwin":
d2cdfee @rgommers BLD: some updates to Bento config files and docs. Closes gh-3978.
rgommers authored
166 conf.env["MACOSX_DEPLOYMENT_TARGET"] = "10.6"
de4d4b3 @cournape REF: remove obsolete workarounds in bscript.
cournape authored
167
ebd9038 @cournape ENH: use new arch tool on mac os x.
cournape authored
168 conf.check_cc_default_arch()
169 archs = [conf.env.DEFAULT_CC_ARCH]
170 conf.env.ARCH = archs
171
de4d4b3 @cournape REF: remove obsolete workarounds in bscript.
cournape authored
172 conf.check_fortran_verbose_flag()
173 conf.check_fortran_clib()
174 conf.check_fortran_dummy_main()
175 u, du, c = conf.check_fortran_mangling()
176 _set_mangling_var(conf, u, du, c)
177
4cf2a89 @cournape FEAT: cluster + fftpack build on darwin.
cournape authored
178 conf.env.INCLUDES = get_numpy_include_dirs()
179
0930611 @cournape REF: use bento blas/lapack instead of custom.
cournape authored
180 blas_lapack.check_blas_lapack(context)
1816883 @cournape BUG: fix bento build following recent scipy code changes.
cournape authored
181 if not (conf.env.HAS_BLAS and conf.env.HAS_LAPACK):
ab4effb @cournape ENH: scipy.linalg build almost complete.
cournape authored
182 raise waflib.Errors.ConfigurationError("You need blas and lapack")
4c6fa4c @cournape ENH: create __config__.py file.
cournape authored
183
aa4df0f @rgommers BLD: fix BLAS/LAPACK detection in Bento build.
rgommers authored
184 blas_lapack.check_blas_lapack(context)
1816883 @cournape BUG: fix bento build following recent scipy code changes.
cournape authored
185
d2f22a7 @cournape ENH: add npymath configuration.
cournape authored
186 npymath_info = get_pkg_info("npymath")
187 conf.parse_flags(npymath_info.cflags() + " " + npymath_info.libs(), "NPYMATH")
188
eaae6d1 @rgommers BLD: fix Cythonizing sources in Bento build.
rgommers authored
189 _generate_cython()
190
247160a @rgommers BLD: fix generated version.py in Bento build.
rgommers authored
191
192 FULLVERSION, GIT_REVISION = setup.get_version_info()
193
194 version_file_content = """\
195 # THIS FILE IS GENERATED FROM SCIPY BSCRIPT
196 short_version = '%(version)s'
197 version = '%(version)s'
198 full_version = '%(full_version)s'
199 git_revision = '%(git_revision)s'
200 release = %(isrelease)s
201
202 if not release:
203 version = full_version
204 """ % {'version': setup.VERSION,
205 'full_version' : FULLVERSION,
206 'git_revision' : GIT_REVISION,
207 'isrelease': str(setup.ISRELEASED)}
208
ee665f4 @cournape REF: use new hook format.
cournape authored
209 @hooks.pre_build
4c6fa4c @cournape ENH: create __config__.py file.
cournape authored
210 def pre_build(context):
211 bld = context.waf_context
212
d2ce154 @cournape REF: use higher-level API for output registration.
cournape authored
213 context.register_category("gen_pymodule")
4c6fa4c @cournape ENH: create __config__.py file.
cournape authored
214 bld(features="gen_pymodule",
215 target="scipy/__config__.py",
216 content="""\
217 def show():
218 pass
219 """,
220 always=True)
247160a @rgommers BLD: fix generated version.py in Bento build.
rgommers authored
221
5257acb @cournape BUG: adding version.py.
cournape authored
222 bld(features="gen_pymodule",
223 target="scipy/version.py",
247160a @rgommers BLD: fix generated version.py in Bento build.
rgommers authored
224 content=version_file_content,
5257acb @cournape BUG: adding version.py.
cournape authored
225 always=True)
0930611 @cournape REF: use bento blas/lapack instead of custom.
cournape authored
226
227 @hooks.options
228 def options(global_context):
229 blas_lapack.add_options(global_context)
Something went wrong with that request. Please try again.