#! /usr/bin/env python """This file holds some mundane code that CIPRES-dependent modules may want to copy or import. Currently it tries to import from PIPRes.verify_import and issues a helpful message about how to set the PYTHONPATH if the import fails. """ try: import PIPRes.verify_import except ImportError, _x: import sys, os if 'CIPRES_ROOT' in os.environ: _msg = "Make sure that CIPRES_ROOT is set correctly. " \ "$CIPRES_ROOT should contain a "\ "lib/python/site-packages directory!\n" try: _p = os.path.join('$CIPRES_ROOT', 'lib', 'python', 'site-packages') pipresParent = os.path.expandvars(_p) if not os.path.exists(pipresParent): sys.exit(str(_x) + _msg) sys.path.append(pipresParent) import PIPRes.verify_import del _msg del _x except ImportError, _y: sys.exit(str(_y) + _msg) else: _msg = "%s\nMake sure that CIPRES_ROOT and PYTHONPATH variables "\ "and set correctly.\n"\ "You will have to add:\n"\ " $CIPRES_ROOT/lib/python/site-packages\n" \ "to your PYTHONPATH environment and their maybe" % str(_x) sys.exit(_msg)