gnome-games r7678 - in trunk/gnome-sudoku: . src src/lib



Author: jclinton
Date: Fri May 30 02:09:11 2008
New Revision: 7678
URL: http://svn.gnome.org/viewvc/gnome-games?rev=7678&view=rev

Log:
fix sudoku python sys.path for good

Modified:
   trunk/gnome-sudoku/ChangeLog
   trunk/gnome-sudoku/src/Makefile.am
   trunk/gnome-sudoku/src/gnome-sudoku.in.in
   trunk/gnome-sudoku/src/lib/defaults.py.in

Modified: trunk/gnome-sudoku/src/Makefile.am
==============================================================================
--- trunk/gnome-sudoku/src/Makefile.am	(original)
+++ trunk/gnome-sudoku/src/Makefile.am	Fri May 30 02:09:11 2008
@@ -7,7 +7,5 @@
 CLEANFILES  = gnome-sudoku gnome-sudoku.in
 
 gnome-sudoku: gnome-sudoku.in
-	sed \
-		-e "s|\#pyexecdir\#|$(pyexecdir)|" \
-	    	$< > $@
+	cp gnome-sudoku.in $@
 	if test -f $@; then chmod u+x $@; fi

Modified: trunk/gnome-sudoku/src/gnome-sudoku.in.in
==============================================================================
--- trunk/gnome-sudoku/src/gnome-sudoku.in.in	(original)
+++ trunk/gnome-sudoku/src/gnome-sudoku.in.in	Fri May 30 02:09:11 2008
@@ -18,19 +18,16 @@
   pass 
 
 import sys
-installed_mode = True
 
 try:
     # Import gnome-sudoku module from source distribution.
     import lib;
     sys.modules["gnome_sudoku"] = sys.modules["lib"];
     from gnome_sudoku.gnome_sudoku import start_game
-    installed_mode = False
 
 except ImportError:
     try:
       # Import gnome-sudoku from pyexecdir or system installation.
-      installed_mode = True
       from gnome_sudoku.gnome_sudoku import start_game
 
     except ImportError:
@@ -50,6 +47,4 @@
       dialog.run()
       sys.exit(0)
 
-sys.modules["gnome_sudoku"].installed_mode = installed_mode
-
 start_game()

Modified: trunk/gnome-sudoku/src/lib/defaults.py.in
==============================================================================
--- trunk/gnome-sudoku/src/lib/defaults.py.in	(original)
+++ trunk/gnome-sudoku/src/lib/defaults.py.in	Fri May 30 02:09:11 2008
@@ -9,12 +9,9 @@
 import errno
 import gettext
 
-if (sys.modules.has_key('gnome_sudoku') and
-    hasattr(sys.modules["gnome_sudoku"],'installed_mode') and
-    sys.modules["gnome_sudoku"].installed_mode):
-    # If the installed_mode attribute is not set, then we are
-    # importing from something other than the gnome-sudoku 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') 
     IMAGE_DIR = os.path.join(APP_DATA_DIR, 'pixmaps', 'gnome-sudoku')
     LOCALEDIR = os.path.join(APP_DATA_DIR, 'locale')
@@ -22,12 +19,14 @@
     BASE_DIR = os.path.join(APP_DATA_DIR,'gnome-sudoku')
     PUZZLE_DIR = os.path.join(APP_DATA_DIR,'gnome-sudoku','puzzles')    
 else:
-    APP_DATA_DIR = os.path.join('@abs_top_builddir@', 'gnome-sudoku', 'data') 
-    IMAGE_DIR = os.path.join('@abs_top_builddir@', 'gnome-sudoku', 'images')
-    LOCALEDIR = os.path.join(APP_DATA_DIR, 'locale')
-    GLADE_DIR = os.path.join('@abs_top_builddir@', 'gnome-sudoku', 'glade')
-    BASE_DIR = os.path.join('@abs_top_builddir@', 'gnome-sudoku', 'data')
-    PUZZLE_DIR = BASE_DIR
+    # Running in uninstalled mode
+    sys.path.insert(0, os.path.abspath(root_dir))
+    APP_DATA_DIR = os.path.join(root_dir, '../data') 
+    IMAGE_DIR    = os.path.join(root_dir, '../images')
+    LOCALEDIR    = os.path.join(APP_DATA_DIR, 'locale')
+    GLADE_DIR    = os.path.join(root_dir, '../glade')
+    BASE_DIR     = os.path.join(root_dir, '../data')
+    PUZZLE_DIR   = BASE_DIR
 
 DOMAIN = 'gnome-games'
 gettext.bindtextdomain(DOMAIN, LOCALEDIR)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]