[GRASS-SVN] r39208 - in grass/branches/releasebranch_6_4: gui/wxpython gui/wxpython/gui_modules lib/init macosx/app

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Sep 14 18:58:50 EDT 2009


Author: kyngchaos
Date: 2009-09-14 18:58:50 -0400 (Mon, 14 Sep 2009)
New Revision: 39208

Modified:
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py
   grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py
   grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py
   grass/branches/releasebranch_6_4/lib/init/init.sh
   grass/branches/releasebranch_6_4/lib/init/variables.html
   grass/branches/releasebranch_6_4/macosx/app/Makefile
   grass/branches/releasebranch_6_4/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/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py	2009-09-14 22:47:41 UTC (rev 39207)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/menuform.py	2009-09-14 22:58:50 UTC (rev 39208)
@@ -104,8 +104,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/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py	2009-09-14 22:47:41 UTC (rev 39207)
+++ grass/branches/releasebranch_6_4/gui/wxpython/gui_modules/utils.py	2009-09-14 22:58:50 UTC (rev 39208)
@@ -331,10 +331,3 @@
         return path[1].upper() + ':\\' + path[3:].replace('/', '\\')
     
     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:])

Modified: grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py
===================================================================
--- grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py	2009-09-14 22:47:41 UTC (rev 39207)
+++ grass/branches/releasebranch_6_4/gui/wxpython/wxgui.py	2009-09-14 22:58:50 UTC (rev 39208)
@@ -1647,11 +1647,6 @@
 
 def main(argv=None):
     #
-    # reexec for MacOS
-    #
-    utils.reexec_with_pythonw()
-
-    #
     # process command-line arguments
     #
     if argv is None:

Modified: grass/branches/releasebranch_6_4/lib/init/init.sh
===================================================================
--- grass/branches/releasebranch_6_4/lib/init/init.sh	2009-09-14 22:47:41 UTC (rev 39207)
+++ grass/branches/releasebranch_6_4/lib/init/init.sh	2009-09-14 22:58:50 UTC (rev 39208)
@@ -301,7 +301,11 @@
 fi
 
 if [ ! "$GRASS_PYTHON" ] ; then
-      GRASS_PYTHON=python
+    if [ "$MACOSX" ] ; then
+        GRASS_PYTHON=pythonw
+    else
+        GRASS_PYTHON=python
+    fi
 fi
 export GRASS_PYTHON
 

Modified: grass/branches/releasebranch_6_4/lib/init/variables.html
===================================================================
--- grass/branches/releasebranch_6_4/lib/init/variables.html	2009-09-14 22:47:41 UTC (rev 39207)
+++ grass/branches/releasebranch_6_4/lib/init/variables.html	2009-09-14 22:58:50 UTC (rev 39208)
@@ -257,7 +257,8 @@
   <br>
   <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>
   
   <br>
   <dt>GRASS_WXBUNDLED</dt>

Modified: grass/branches/releasebranch_6_4/macosx/app/Makefile
===================================================================
--- grass/branches/releasebranch_6_4/macosx/app/Makefile	2009-09-14 22:47:41 UTC (rev 39207)
+++ grass/branches/releasebranch_6_4/macosx/app/Makefile	2009-09-14 22:58:50 UTC (rev 39208)
@@ -29,6 +29,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
 
 default: macosxapp
 
@@ -71,6 +76,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/branches/releasebranch_6_4/macosx/app/grass.sh.in
===================================================================
--- grass/branches/releasebranch_6_4/macosx/app/grass.sh.in	2009-09-14 22:47:41 UTC (rev 39207)
+++ grass/branches/releasebranch_6_4/macosx/app/grass.sh.in	2009-09-14 22:58:50 UTC (rev 39208)
@@ -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"`
@@ -181,22 +184,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
@@ -211,7 +224,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=""
@@ -221,18 +234,29 @@
 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 gisrc has text startup, switch back to Terminal (gotta duplicate some init.sh stuff)
-# eventually, when TclTk optional, can run appropriate apps per GUI here (ie X11)
-GISRCRC="$HOME/.grassrc6"
+# 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
+GRASSRC="$HOME/.grassrc6"
 if [ ! "$GRASS_GUI" ] ; then
-	if [ -f "$GISRCRC" ] ; then
-		GRASS_GUI=`awk '/GRASS_GUI/ {print $2}' "$GISRCRC"`
+	if [ -f "$GRASSRC" ] ; then
+		GRASS_GUI=`awk '/GRASS_GUI/ {print $2}' "$GRASSRC"`
 	fi
 	if [ ! "$GRASS_GUI" ] ; then
 		GRASS_GUI="tcltk"



More information about the grass-commit mailing list