diff --git a/bindings/python/wscript b/bindings/python/wscript index 974210172..61beae990 100644 --- a/bindings/python/wscript +++ b/bindings/python/wscript @@ -548,6 +548,30 @@ class python_scan_task_collector(Task.TaskBase): return 0 + +class gen_ns3_compat_pymod_task(Task.TaskBase): + """Generates a 'ns3.py' compatibility module.""" + before = 'cc cxx gchx' + color = 'BLUE' + + def __init__(self, bld, output_file): + self.bld = bld + self.output_file = output_file + super(gen_ns3_compat_pymod_task, self).__init__(generator=self) + + def run(self): + outfile = file(self.output_file, "w") + print >> outfile, "import warnings" + print >> outfile, 'warnings.warn("the ns3 module is a compatibility layer '\ + 'and should not be used in newly written code", DeprecationWarning, stacklevel=2)' + print >> outfile + for module in self.bld.env['PYTHON_MODULES_BUILT']: + print >> outfile, "from ns.%s import *" % (module,) + outfile.close() + return 0 + + + def build(bld): if Options.options.python_disable: return @@ -730,3 +754,7 @@ def build(bld): shutil.copy2(src, dst) + + + if env['ENABLE_PYTHON_BINDINGS'] and env['BINDINGS_TYPE'] in ('modular', 'both'): + gen = gen_ns3_compat_pymod_task(bld, bld.path.find_or_declare("ns3.py").bldpath(bld.env)) diff --git a/src/wscript b/src/wscript index b53136876..5176e3153 100644 --- a/src/wscript +++ b/src/wscript @@ -138,6 +138,7 @@ def ns3_python_bindings(bld): # this method is called from a module wscript, so remember bld.path is not bindings/python! module_abs_src_path = bld.path.abspath() module = os.path.basename(module_abs_src_path) + env.append_value('PYTHON_MODULES_BUILT', module) apidefs = env['PYTHON_BINDINGS_APIDEFS'].replace("-", "_") #debug = ('PYBINDGEN_DEBUG' in os.environ)