[GRASS-SVN] r39209 - in grass/trunk: gui/wxpython gui/wxpython/gui_modules lib/init macosx/app

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Sep 14 19:31:23 EDT 2009


Author: kyngchaos
Date: 2009-09-14 19:31:22 -0400 (Mon, 14 Sep 2009)
New Revision: 39209

Modified:
   grass/trunk/gui/wxpython/gui_modules/menuform.py
   grass/trunk/gui/wxpython/gui_modules/utils.py
   grass/trunk/gui/wxpython/wxgui.py
   grass/trunk/lib/init/functions.sh
   grass/trunk/lib/init/variables.html
   grass/trunk/macosx/app/Makefile
   grass/trunk/macosx/app/grass.sh.in
Log:
use pythonw directly, instead of re-exec'ing
workaround problem when 32bit python needed but 64bit runs default on OSX (from dev6 r39207)

Modified: grass/trunk/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/menuform.py	2009-09-14 22:58:50 UTC (rev 39208)
+++ grass/trunk/gui/wxpython/gui_modules/menuform.py	2009-09-14 23:31:22 UTC (rev 39209)
@@ -103,8 +103,6 @@
 except:
     from compat import subprocess
 
-utils.reexec_with_pythonw()
-
 wxUpdateDialog, EVT_DIALOG_UPDATE = NewEvent()
 
 # From lib/gis/col_str.c, except purple which is mentioned

Modified: grass/trunk/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/trunk/gui/wxpython/gui_modules/utils.py	2009-09-14 22:58:50 UTC (rev 39208)
+++ grass/trunk/gui/wxpython/gui_modules/utils.py	2009-09-14 23:31:22 UTC (rev 39209)
@@ -437,13 +437,6 @@
     
     return path
     
-def reexec_with_pythonw():
-    """!Re-execute Python on Mac OS"""
-    if sys.platform == 'darwin' and \
-            not sys.executable.endswith('MacOS/Python'):
-        print >> sys.stderr, 're-executing using pythonw'
-        os.execvp('pythonw', ['pythonw', __file__] + sys.argv[1:])
-
 def ReadEpsgCodes(path):
     """!Read EPSG code from the file
 

Modified: grass/trunk/gui/wxpython/wxgui.py
===================================================================
--- grass/trunk/gui/wxpython/wxgui.py	2009-09-14 22:58:50 UTC (rev 39208)
+++ grass/trunk/gui/wxpython/wxgui.py	2009-09-14 23:31:22 UTC (rev 39209)
@@ -1604,11 +1604,6 @@
 
 def main(argv=None):
     #
-    # reexec for MacOS
-    #
-    utils.reexec_with_pythonw()
-
-    #
     # process command-line arguments
     #
     if argv is None:

Modified: grass/trunk/lib/init/functions.sh
===================================================================
--- grass/trunk/lib/init/functions.sh	2009-09-14 22:58:50 UTC (rev 39208)
+++ grass/trunk/lib/init/functions.sh	2009-09-14 23:31:22 UTC (rev 39209)
@@ -163,8 +163,12 @@
 
     # GRASS_PYTHON
     if [ ! "$GRASS_PYTHON" ] ; then
-	GRASS_PYTHON=python
-	export GRASS_PYTHON
+        if [ "$MACOSX" ] ; then
+            GRASS_PYTHON=pythonw
+        else
+            GRASS_PYTHON=python
+        fi
+        export GRASS_PYTHON
     fi
 
     # GRASS_GNUPLOT

Modified: grass/trunk/lib/init/variables.html
===================================================================
--- grass/trunk/lib/init/variables.html	2009-09-14 22:58:50 UTC (rev 39208)
+++ grass/trunk/lib/init/variables.html	2009-09-14 23:31:22 UTC (rev 39209)
@@ -231,7 +231,8 @@
   
   <dt>GRASS_PYTHON</dt>
   <dd>[wxGUI, Python SWIG]<br>
-    set to override Python executable.</dd>
+    set to override Python executable.<br>
+    On Mac OS X this should be the pythonw executable for the wxGUI to work.</dd>
   
   <dt>GRASS_WXBUNDLED</dt>
   <dd>[wxGUI]<br>

Modified: grass/trunk/macosx/app/Makefile
===================================================================
--- grass/trunk/macosx/app/Makefile	2009-09-14 22:58:50 UTC (rev 39208)
+++ grass/trunk/macosx/app/Makefile	2009-09-14 23:31:22 UTC (rev 39209)
@@ -25,6 +25,11 @@
 endif
 # get python version - use python in path, should be config'd python
 PYVER = `python -V 2>&1 | cut -d \  -f 2 | cut -d . -f 1,2`
+ifneq ($(filter ppc64 x86_64,$(MACOSX_ARCHS_WXPYTHON)),)
+WX64BIT = 1
+else
+WX64BIT = 0
+endif
 
 NIBSRC := $(wildcard English.lproj/MainMenu.nib/*)
 NIBDST := $(patsubst English.lproj/%,$(APPDIR)/Resources/English.lproj/%,$(NIBSRC))
@@ -97,6 +102,7 @@
 	-e "s, at PROJ_BIN_PATH@,$(PROJ_BIN)," \
 	-e "s, at X11@,$(USE_X11),g" \
 	-e "s, at PYVER@,$(PYVER),g" \
+	-e "s, at WX64BIT@,$(WX64BIT),g" \
 	grass.sh.in > $(OBJDIR)/grass.sh
 
 clean:

Modified: grass/trunk/macosx/app/grass.sh.in
===================================================================
--- grass/trunk/macosx/app/grass.sh.in	2009-09-14 22:58:50 UTC (rev 39208)
+++ grass/trunk/macosx/app/grass.sh.in	2009-09-14 23:31:22 UTC (rev 39209)
@@ -24,6 +24,9 @@
 GRASS_OS_STARTUP="Mac.app"
 export GRASS_OS_STARTUP
 
+SYSARCH=`uname -p`
+SYSVER=`uname -r | cut -d . -f 1`
+
 GISBASE=`dirname "$0"`
 export GISBASE
 grass_ver=`cut -d . -f 1-2 "$GISBASE/etc/VERSIONNUMBER"`
@@ -133,22 +136,32 @@
 # change GRASS_WXBUNDLED and pyver_want here from bundle.make, or manually
 GRASS_WXBUNDLED=
 export GRASS_WXBUNDLED
+pyexe="pythonw"
 pyver_want="@PYVER@"
-if [ -d "$GISBASE/etc/wxpython" ] && [ "$GRASS_WXBUNDLED" = "1" ] ; then
+wx64bit="@WX64BIT@"
 # make sure python version used matches what wxpython wants
 py=""
-# did user set GRASS_PYTHON already? check it
+# did user set GRASS_PYTHON already? check it (must have pythonw)
 if [ "$GRASS_PYTHON" ] ; then
-	pyver=`$GRASS_PYTHON -V 2>&1 | grep " $pyver_want"`
-	if [ "$pyver" ] ; then
-		py="$GRASS_PYTHON"
+	py=`echo "$GRASS_PYTHON" | grep pythonw`
+	if [ "$py" ] ; then
+		case $GRASS_PYTHON in
+			/*) py="$GRASS_PYTHON" ;;
+			*) py=`type -p $GRASS_PYTHON`
+		esac
+		pyver=`$py -V 2>&1 | grep " $pyver_want"`
+		if [ ! "$pyver" ] ; then
+			py=""
+		fi
+	else
+		py=""
 	fi
 fi # GRASS_PYTHON
 # try in shell path
 if [ ! "$py" ] ; then
-	py=`type -p python`
+	py=`type -p pythonw$pyver_want`
 	if [ "$py" ] ; then
-		pyver=`python -V 2>&1 | grep " $pyver_want"`
+		pyver=`$py -V 2>&1 | grep " $pyver_want"`
 		if [ ! "$pyver" ] ; then
 			py=""
 		fi
@@ -163,7 +176,7 @@
 fi
 # try system (may be the same as in shell path)
 if [ ! "$py" ] ; then
-	py="/usr/bin/python"
+	py="/usr/bin/pythonw$pyver_want"
 	pyver=`$py -V 2>&1 | grep " $pyver_want"`
 	if [ ! "$pyver" ] ; then
 		py=""
@@ -173,11 +186,22 @@
 if [ "$py" ] ; then
 	echo "$pyver found."
 	GRASS_PYTHON="$py"
+	# can't run python 64bit if wx not 64bit, assume OSX 10.6+ 64bit
+	if [ $(($SYSVER)) -gt 9 ] && [ "$wx64bit" = "0" ] ; then
+		case $SYSARCH$wx64bit in
+			powerpc0) pyarch="ppc" ;;
+			i3860) pyarch="i386" ;;
+			*) pyarch="" ;;
+		esac
+		# make copy of pythonw 32bit because g.gui can't spawn multi-arg prog
+		ditto -arch $pyarch "$py" "$GISBASE_USER/Modules/bin/pythonw"
+		GRASS_PYTHON="pythonw"
+	fi
+	export GRASS_PYTHON
 else
 	echo "Warning: No Python $pyver_want found, needed by wxPython."
 	echo "         The wxPython GUI may not work properly."
 fi
-fi # bundled wx
 
 # if grassrc has text startup, switch back to Terminal (gotta duplicate some init.sh stuff)
 # only applies to Tiger - Leopard X11 opens automatically as needed



More information about the grass-commit mailing list