Skip to content

Commit

Permalink
ENH: create __config__.py file.
Browse files Browse the repository at this point in the history
  • Loading branch information
cournape committed Jun 1, 2011
1 parent 4cf2a89 commit 4c6fa4c
Showing 1 changed file with 48 additions and 0 deletions.
48 changes: 48 additions & 0 deletions bscript
@@ -1,4 +1,5 @@
import sys import sys
import os.path as op


from numpy.distutils.misc_util \ from numpy.distutils.misc_util \
import \ import \
Expand All @@ -11,6 +12,9 @@ from bento.commands import hooks
from bento.commands.extras.waf \ from bento.commands.extras.waf \
import \ import \
ConfigureWafContext, BuildWafContext, register_options ConfigureWafContext, BuildWafContext, register_options
from bento.installed_package_description \
import \
InstalledSection


import waflib import waflib
from waflib import Options from waflib import Options
Expand Down Expand Up @@ -110,3 +114,47 @@ def post_configure(context):
conf.env["MACOSX_DEPLOYMENT_TARGET"] = "10.4" conf.env["MACOSX_DEPLOYMENT_TARGET"] = "10.4"


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)

0 comments on commit 4c6fa4c

Please sign in to comment.