Index: src/glchess.in.in
===================================================================
--- src/glchess.in.in	(revision 7675)
+++ src/glchess.in.in	(working copy)
@@ -28,12 +28,10 @@
     import lib;
     sys.modules["glchess"] = sys.modules["lib"];
     from glchess.glchess import start_game
-    installed_mode = False
 
 except ImportError:
     try:
       # Import glChess from pyexecdir or system installation.
-      installed_mode = True
       from glchess.glchess import start_game
 
     except ImportError:
@@ -53,6 +51,4 @@
       dialog.run()
       sys.exit(0)
 
-sys.modules["glchess"].installed_mode = installed_mode
-
 start_game()
Index: src/lib/glchess.py
===================================================================
--- src/lib/glchess.py	(revision 7675)
+++ src/lib/glchess.py	(working copy)
@@ -16,7 +16,7 @@
 
 sys.stdout = SafeStdout()
 
-import main
 def start_game ():
+    import main
     app = main.Application()
     app.start()
Index: src/lib/defaults.py.in
===================================================================
--- src/lib/defaults.py.in	(revision 7675)
+++ src/lib/defaults.py.in	(working copy)
@@ -9,12 +9,9 @@
 import errno
 import gettext 
 
-if (sys.modules.has_key('glchess') and
-    hasattr(sys.modules["glchess"],'installed_mode') and
-    sys.modules["glchess"].installed_mode):
-    # If the installed_mode attribute is not set, then we are
-    # importing from something other than the glchess script; we
-    # assume anyone importing in this way is doing testing etc.
+root_dir = os.path.dirname(os.path.dirname(__file__))
+if not os.path.exists(os.path.join(root_dir, "Makefile.am")):
+    # Running in installed mode
     APP_DATA_DIR     = os.path.join('@prefix@', 'share') 
     ICON_DIR         = os.path.join(APP_DATA_DIR, 'pixmaps')
     TEXTURE_DIR      = os.path.join(ICON_DIR, 'glchess')
@@ -28,11 +25,13 @@
     UNFINISHED_FILE  = os.path.join(HISTORY_DIR, 'unfinished')
     LOCAL_AI_CONFIG  = os.path.join(DATA_DIR, 'ai.xml')
 else:
-    APP_DATA_DIR     = os.path.join('@abs_top_builddir@', 'glchess', 'data')
-    ICON_DIR         = os.path.join('@abs_top_builddir@', 'glchess', 'textures')
-    TEXTURE_DIR      = os.path.join('@abs_top_builddir@', 'glchess', 'textures')
-    GLADE_DIR        = os.path.join('@abs_top_builddir@', 'glchess', 'glade')
-    BASE_DIR         = os.path.join('@abs_top_builddir@', 'glchess', 'data')
+    # Running in uninstalled mode
+    sys.path.insert(0, os.path.abspath(root_dir))
+    APP_DATA_DIR     = os.path.join(root_dir, '../data')
+    ICON_DIR         = os.path.join(root_dir, '../textures')
+    TEXTURE_DIR      = os.path.join(root_dir, '../textures')
+    GLADE_DIR        = os.path.join(root_dir, '../glade')
+    BASE_DIR         = os.path.join(root_dir, '../data')
     LOCALEDIR        = os.path.join(APP_DATA_DIR, 'locale')
     DATA_DIR         = os.path.expanduser('~/.gnome2/glchess/')
     LOG_DIR          = os.path.join(DATA_DIR, 'logs')
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 7675)
+++ src/Makefile.am	(working copy)
@@ -8,7 +8,5 @@
 CLEANFILES  = glchess
 
 glchess: $(top_builddir)/glchess/src/glchess.in
-	sed \
-		-e "s|\#pyexecdir\#|$(pyexecdir)|" \
-	    	$< > $@
+	cp $(top_builddir)/glchess/src/glchess.in $@
 	if test -f $@; then chmod u+x $@; fi
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 7675)
+++ ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2008-05-29  Jason D. Clinton  <me@jasonclinton.com>
+
+	* src/glchess.in.in:
+	* src/Makefile.am:
+	* src/lib/defaults.py.in:
+	* src/lib/glchess.py: make everyone happy with sys.path shenanigans (Bug #524665, Bug #528953)
+
 2008-05-14  Robert Ancell  <robert.ancell@gmail.com>
 
 	* src/glchess.in.in: Don't modify sys.path as this can cause modules to be loaded that
