Commit [fa0eb6] Maximize Restore History

Determine Paths at Runtime

Uses GRAMPS_RESOURCES to override the root location of the Gramps data files (which would normally be $(prefix)/share).
In setup.py install, writes $(prefix)/share to gen/utils/resource-path, installs that file, then deletes it again from the source tree. The presence or absence determines whether Gramps is running from the source directory or from an installation.

Const.py is now a static file; const.py.in is no longer used. Note that because importing const into setup tried to initialize things that we don't want initialized, VERSION is removed, and imported from gramps.version -- a file which will be added in the next change. Consequently, this commit will not run.

svn: r21613

John Ralls John Ralls 2013-03-11

added gramps/gen/utils/resourcepath.py
changed mac/gramps.launcher
changed .gitignore
changed Gramps.py
changed setup.py
copied gramps/gen/const.py.in -> gramps/gen/const.py
gramps/gen/utils/resourcepath.py Diff Switch to side-by-side view
Loading...
mac/gramps.launcher Diff Switch to side-by-side view
Loading...
.gitignore Diff Switch to side-by-side view
Loading...
Gramps.py Diff Switch to side-by-side view
Loading...
setup.py Diff Switch to side-by-side view
Loading...
gramps/gen/const.py.in to gramps/gen/const.py
--- a/gramps/gen/const.py.in
+++ b/gramps/gen/const.py
@@ -4,6 +4,7 @@
 #
 # Copyright (C) 2000-2006  Donald N. Allingham
 # Copyright (C) 2012       Doug Blank
+# Copyright (C) 2013       John Ralls <jralls@ceridwen.us>
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -50,21 +51,7 @@
 #
 #-------------------------------------------------------------------------
 PROGRAM_NAME   = "Gramps"
-VERSION        = "@VERSIONSTRING@"
-if VERSION == "@" + "VERSIONSTRING" + "@":
-    raise Exception("Please run 'python setup.py build'")
-def get_version_tuple(v):
-    """ Get the numeric-dotted part of version number"""
-    retval = ""
-    for c in v:
-        if c.isdigit() or (c == "." and retval.count(".") <= 1):
-            retval += c
-        else:
-            break
-    return tuple(map(int, retval.split(".")))
-VERSION_TUPLE  = get_version_tuple(VERSION)
-major_version = "%s.%s" % (VERSION_TUPLE[0], VERSION_TUPLE[1])
-
+from gramps.version import VERSION, VERSION_TUPLE, major_version
 #-------------------------------------------------------------------------
 #
 # Standard GRAMPS Websites
@@ -135,8 +122,7 @@
 else:
     pass
 
-VERSION_DIR    = os.path.join(
-    HOME_DIR, "gramps%s%s" % (VERSION_TUPLE[0], VERSION_TUPLE[1]))
+VERSION_DIR    = os.path.join(HOME_DIR, "gramps%s" % major_version)
 
 CUSTOM_FILTERS = os.path.join(VERSION_DIR, "custom_filters.xml")
 REPORT_OPTIONS = os.path.join(HOME_DIR, "report_options.xml")
@@ -199,10 +185,11 @@
 # Paths to data files.
 #
 #-------------------------------------------------------------------------
-LOCALE_DIR = "@LOCALE_DIR@"
-DATA_DIR = "@DATA_DIR@"
-IMAGE_DIR = "@IMAGE_DIR@"
-DOC_DIR = "@DOC_DIR@"
+from gramps.gen.utils.resourcepath import ResourcePath
+_resources = ResourcePath()
+LOCALE_DIR = _resources.locale_dir
+DATA_DIR = _resources.data_dir
+IMAGE_DIR = _resources.image_dir
 
 TIP_DATA = os.path.join(DATA_DIR, "tips.xml")
 PAPERSIZE = os.path.join(DATA_DIR, "papersize.xml")
@@ -211,7 +198,7 @@
 LOGO = os.path.join(IMAGE_DIR, "logo.png")
 SPLASH = os.path.join(IMAGE_DIR, "splash.jpg")
 
-LICENSE_FILE = os.path.join(DOC_DIR, 'COPYING')
+LICENSE_FILE = os.path.join(_resources.doc_dir, 'COPYING')
 #-------------------------------------------------------------------------
 #
 # Init Localization
@@ -238,9 +225,10 @@
     "Donald A. Peterson", 
     "Donald N. Allingham", 
     "David Hampton",  
-    "Martin Hawlisch", 
+    "Martin Hawlisch",
     "Richard Taylor", 
-    "Tim Waugh", 
+    "Tim Waugh",
+    "John Ralls"
     ]
     
 AUTHORS_FILE = os.path.join(DATA_DIR, "authors.xml")