From 017005e0475fed3f49a437c11e63c07f843dbb91 Mon Sep 17 00:00:00 2001 From: Craig Dowell Date: Fri, 16 Apr 2010 14:58:56 -0700 Subject: [PATCH] python path helps when running python programs --- test.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/test.py b/test.py index 0813ea7a2..5f57ae4c1 100755 --- a/test.py +++ b/test.py @@ -575,10 +575,11 @@ def read_waf_config(): # its own shared libraries, so ns-3 doesn't hardcode a shared library search # path -- it is cooked up dynamically, so we do that too. # -def make_library_path(): +def make_paths(): have_DYLD_LIBRARY_PATH = False have_LD_LIBRARY_PATH = False have_PATH = False + have_PYTHONPATH = False keys = os.environ.keys() for key in keys: @@ -588,6 +589,18 @@ def make_library_path(): have_LD_LIBRARY_PATH = True if key == "PATH": have_PATH = True + if key == "PYTHONPATH": + have_PYTHONPATH = True + + pypath = os.environ["PYTHONPATH"] = os.path.join (NS3_BUILDDIR, NS3_ACTIVE_VARIANT, "bindings", "python") + + if not have_PYTHONPATH: + os.environ["PYTHONPATH"] = pypath + else: + os.environ["PYTHONPATH"] += ":" + pypath + + if options.verbose: + print "os.environ[\"PYTHONPATH\"] == %s" % os.environ["PYTHONPATH"] if sys.platform == "darwin": if not have_DYLD_LIBRARY_PATH: @@ -998,7 +1011,7 @@ def run_tests(): # read_waf_active_variant() read_waf_config() - make_library_path() + make_paths() # # If lots of logging is enabled, we can crash Python when it tries to