# HG changeset patch # User M. George Hansen # Date 1307741378 36000 # Node ID 2e2d6d9009a342a1a9bc1ff41ff9ac25401c4ff9 # Parent 15107282d9ebbe6ac2704972c94992dfaa8aee63 Added a --fifepath option to the WAF build script. * Use the '--fifepath=' option to override the default search path and directly import the FIFE Python module from . * Modified the parpg.main module to support the new --fifepath option and ensure that the FIFE Python module pointed to by the --fifepath option is imported, regardless of whether multiple FIFE modules are already in the default search path. diff -r 15107282d9eb -r 2e2d6d9009a3 parpg.cfg.in --- a/parpg.cfg.in Thu Jun 09 21:40:51 2011 -1000 +++ b/parpg.cfg.in Fri Jun 10 11:29:38 2011 -1000 @@ -73,6 +73,9 @@ [parpg] +# Directory where the fife python module is located (path). +FifePath = "@FIFEPATH@" + # System directory where all data files are located (path) DataPath = "@DATADIR@" diff -r 15107282d9eb -r 2e2d6d9009a3 src/parpg/main.py --- a/src/parpg/main.py Thu Jun 09 21:40:51 2011 -1000 +++ b/src/parpg/main.py Fri Jun 10 11:29:38 2011 -1000 @@ -53,16 +53,17 @@ logger = logging.getLogger('parpg') try: - sys.path.insert(0, settings.parpg.FifePath) + old_path = sys.path + sys.path = [settings.parpg.FifePath] + import fife except AttributeError: logger.warning('[parpg] section has no FifePath option') - -try: - from fife import fife except ImportError: logger.critical("Could not import fife module. Please install fife or add " - "'FifePath' to the [parpg] section of your settings file") + "'FifePath' to the [parpg] section of your settings file") sys.exit(1) +finally: + sys.path = old_path from parpg.application import PARPGApplication from parpg.common import utils diff -r 15107282d9eb -r 2e2d6d9009a3 wscript --- a/wscript Thu Jun 09 21:40:51 2011 -1000 +++ b/wscript Fri Jun 10 11:29:38 2011 -1000 @@ -8,6 +8,17 @@ def options(opt): opt.load('waf_paths python') + + ext_dep = opt.add_option_group( + 'External dependencies', + '', + ) + ext_dep.add_option( + '--fifepath', + help='Path to where the fife Python package is located', + default='', + dest='fifepath', + ) def configure(cnf): cnf.load('waf_paths python') @@ -16,6 +27,10 @@ else: min_python_version = (2, 6) cnf.check_python_version(min_python_version) + + cnf.env['FIFEPATH'] = \ + os.path.abspath(os.path.expanduser(cnf.options.fifepath)) or \ + cnf.env['PYTHONDIR'] def build(bld): subst_vars = _get_subst_vars(bld) @@ -79,4 +94,5 @@ destdir, os.path.splitdrive(path)[1].lstrip('/\\'), ) + subst_vars['FIFEPATH'] = cnf.env['FIFEPATH'] return subst_vars \ No newline at end of file