From 4c6fa4c7cd8c43e0b6ca1a40778dfc4c59d8cb69 Mon Sep 17 00:00:00 2001 From: David Cournapeau Date: Wed, 1 Jun 2011 09:27:36 +0900 Subject: [PATCH] ENH: create __config__.py file. --- bscript | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/bscript b/bscript index 7d5930969532..da8303451ed8 100644 --- a/bscript +++ b/bscript @@ -1,4 +1,5 @@ import sys +import os.path as op from numpy.distutils.misc_util \ import \ @@ -11,6 +12,9 @@ from bento.commands import hooks from bento.commands.extras.waf \ import \ ConfigureWafContext, BuildWafContext, register_options +from bento.installed_package_description \ + import \ + InstalledSection import waflib from waflib import Options @@ -110,3 +114,47 @@ def post_configure(context): conf.env["MACOSX_DEPLOYMENT_TARGET"] = "10.4" conf.env.MACOSX_DEPLOYMENT_TARGET = "10.4" + +# FIXME: abstract those module gen tasks... +class write_module(waflib.Task.Task): + color = "CYAN" + vars = ["CONTENT"] + def run(self): + # FIXME: put actual data here + self.outputs[0].write(self.env.CONTENT) + +@waflib.TaskGen.feature("gen_pymodule") +def process_write_config(self): + if not hasattr(self, "content"): + raise ValueError("task gen %r expects a 'content' argument" % self.name) + else: + self.env.CONTENT = self.content + output = self.path.find_or_declare(self.target) + name = getattr(self, "name", None) or self.target + + bento_context = self.bld.bento_context + b_output = bento_context.build_node.make_node(output.bldpath()) + bento_context.outputs_registry.register_outputs( + "gen_pymodule", name, [b_output], bento_context.build_node, "$sitedir") + + tsk = self.create_task("write_module") + tsk.set_outputs(output) + return tsk + +@hooks.pre_build() +def pre_build(context): + bld = context.waf_context + + def iregistrer(category, name, nodes, from_node, target_dir): + source_dir = op.join("$_srcrootdir", from_node.bldpath()) + files = [n.path_from(from_node) for n in nodes] + return InstalledSection.from_source_target_directories(category, name, source_dir, target_dir, files) + context.isection_registry.register_category("gen_pymodule", iregistrer) + context.outputs_registry.register_category("gen_pymodule", "pythonfiles") + bld(features="gen_pymodule", + target="scipy/__config__.py", + content="""\ +def show(): + pass +""", + always=True)