From 9af50e6d5bca2238f9f707b38b56b105f3dddd56 Mon Sep 17 00:00:00 2001 From: "Gustavo J. A. M. Carneiro" Date: Wed, 19 Nov 2008 17:32:37 +0000 Subject: [PATCH] Add a --with-pybindgen option, to allow external pybindgen to be used instead of fetching it from the network --- bindings/python/wscript | 35 +++++++++++++++++++++++++++++------ 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/bindings/python/wscript b/bindings/python/wscript index 55616cbd2..0c6a3d55c 100644 --- a/bindings/python/wscript +++ b/bindings/python/wscript @@ -16,16 +16,25 @@ import sys LOCAL_PYBINDGEN_PATH = os.path.join(os.getcwd(), "bindings", "python", "pybindgen") #PYBINDGEN_BRANCH = 'lp:pybindgen' PYBINDGEN_BRANCH = 'https://launchpad.net/pybindgen' -if os.environ.get('PYTHONPATH', ''): - os.environ['PYTHONPATH'] = LOCAL_PYBINDGEN_PATH + os.pathsep + os.environ.get('PYTHONPATH') -else: - os.environ['PYTHONPATH'] = LOCAL_PYBINDGEN_PATH ## https://launchpad.net/pybindgen/ REQUIRED_PYBINDGEN_VERSION = (0, 9, 0, 605) REQUIRED_PYGCCXML_VERSION = (0, 9, 5) +def add_to_python_path(path): + if os.environ.get('PYTHONPATH', ''): + os.environ['PYTHONPATH'] = path + os.pathsep + os.environ.get('PYTHONPATH') + else: + os.environ['PYTHONPATH'] = path + +def set_pybindgen_pythonpath(env): + if env['WITH_PYBINDGEN']: + add_to_python_path(env['WITH_PYBINDGEN']) + else: + add_to_python_path(LOCAL_PYBINDGEN_PATH) + + def set_options(opt): opt.tool_options('python') opt.add_option('--disable-python', @@ -41,6 +50,10 @@ def set_options(opt): "instead of using the system installed version."), action="store_true", default=False, dest='pybindgen_checkout') + opt.add_option('--with-pybindgen', + help=('Path to an existing pybindgen source tree to use.'), + default=None, + dest='with_pybindgen', type="string") def fetch_pybindgen(conf): """ @@ -127,14 +140,22 @@ def configure(conf): conf.env.append_value('CXXFLAGS_PYEXT','-fno-strict-aliasing') ## Check for pybindgen + + no_net = False + if Params.g_options.with_pybindgen: + conf.env['WITH_PYBINDGEN'] = Params.g_options.with_pybindgen + no_net = True + if Params.g_options.pybindgen_checkout: fetch_pybindgen(conf) + set_pybindgen_pythonpath(conf.env) + try: conf.check_python_module('pybindgen') except Configure.ConfigurationError: warning("pybindgen missing") - if not fetch_pybindgen(conf): + if no_net or not fetch_pybindgen(conf): conf.report_optional_feature("python", "Python Bindings", False, "PyBindGen missing and could not be retrieved") return @@ -152,7 +173,7 @@ def configure(conf): warning("pybindgen (found %s) is too old (need %s)" % (pybindgen_version_str, '.'.join([str(x) for x in REQUIRED_PYBINDGEN_VERSION]))) - if not fetch_pybindgen(conf): + if no_net or not fetch_pybindgen(conf): conf.report_optional_feature("python", "Python Bindings", False, "PyBindGen too old and newer version could not be retrieved") return @@ -391,6 +412,8 @@ def build(bld): env = bld.env_of_name('default') curdir = bld.m_curdirnode.abspath() + set_pybindgen_pythonpath(env) + #Object.register('all-ns3-headers', AllNs3Headers) Action.Action('gen-ns3-metaheader', func=gen_ns3_metaheader, color='BLUE')