diff options
Diffstat (limited to 'scripts/template_verifier.py')
-rwxr-xr-x | scripts/template_verifier.py | 32 |
1 files changed, 27 insertions, 5 deletions
diff --git a/scripts/template_verifier.py b/scripts/template_verifier.py index a7dbda9e3b..581f1168ff 100755 --- a/scripts/template_verifier.py +++ b/scripts/template_verifier.py @@ -38,13 +38,35 @@ If [FILE] [FILE] is specified, two local files will be checked against each other. """ -from os.path import realpath, dirname, join, exists -setup_path = join(dirname(realpath(__file__)), "setup-path.py") -if exists(setup_path): - execfile(setup_path) +import sys +import os.path + +# Look for indra/lib/python in all possible parent directories ... +# This is an improvement over the setup-path.py method used previously: +# * the script may blocated anywhere inside the source tree +# * it doesn't depend on the current directory +# * it doesn't depend on another file being present. + +root = os.path.abspath(__file__) +# always insert the directory of the script in the search path +dir = os.path.dirname(root) +if dir not in sys.path: + sys.path.insert(0, dir) + +# Now go look for indra/lib/python in the parent dies +while root != os.path.sep: + root = os.path.dirname(root) + dir = os.path.join(root, 'indra', 'lib', 'python') + if os.path.isdir(dir): + if dir not in sys.path: + sys.path.insert(0, dir) + break +else: + print >>sys.stderr, "This script is not inside a valid installation." + sys.exit(1) + import optparse import os -import sys import urllib from indra.ipc import compatibility |