[GRASS-SVN] r40103 - grass/branches/develbranch_6/macosx/app

svn_grass at osgeo.org svn_grass at osgeo.org
Mon Dec 21 21:34:38 EST 2009


Author: kyngchaos
Date: 2009-12-21 21:34:37 -0500 (Mon, 21 Dec 2009)
New Revision: 40103

Added:
   grass/branches/develbranch_6/macosx/app/python_wrapper
Modified:
   grass/branches/develbranch_6/macosx/app/Makefile
   grass/branches/develbranch_6/macosx/app/grass.sh.in
Log:
use python wrapper script so arch command can be used to select OSX architecture and to force pythonw

Modified: grass/branches/develbranch_6/macosx/app/Makefile
===================================================================
--- grass/branches/develbranch_6/macosx/app/Makefile	2009-12-21 12:25:47 UTC (rev 40102)
+++ grass/branches/develbranch_6/macosx/app/Makefile	2009-12-22 02:34:37 UTC (rev 40103)
@@ -37,7 +37,7 @@
 
 default: macosxapp
 
-macosxapp: PkgInfo app.icns English.lproj/MainMenu.nib build_html_user_index.sh build_gui_user_menu.sh $(ARCH_OBJS) $(APPDIR)/MacOS/GRASS
+macosxapp: PkgInfo app.icns English.lproj/MainMenu.nib build_html_user_index.sh build_gui_user_menu.sh python_wrapper $(ARCH_OBJS) $(APPDIR)/MacOS/GRASS
 	-${MAKE_DIR_CMD} ${APPDIR}/Resources/Scripts
 	-${MAKE_DIR_CMD} ${APPDIR}/MacOS/scripts
 	-${MAKE_DIR_CMD} ${APPDIR}/MacOS/etc
@@ -49,6 +49,7 @@
 	-${INSTALL_DATA} $(OBJDIR)/GRASS.scpt ${APPDIR}/Resources/Scripts
 	-${INSTALL} build_html_user_index.sh ${APPDIR}/MacOS/etc
 	-${INSTALL} build_gui_user_menu.sh ${APPDIR}/MacOS/etc
+	-${INSTALL} python_wrapper ${APPDIR}/MacOS/bin/python
 
 $(OBJDIR)/main.o: main.m
 	$(MAKE_DIR_CMD) $(OBJDIR)

Modified: grass/branches/develbranch_6/macosx/app/grass.sh.in
===================================================================
--- grass/branches/develbranch_6/macosx/app/grass.sh.in	2009-12-21 12:25:47 UTC (rev 40102)
+++ grass/branches/develbranch_6/macosx/app/grass.sh.in	2009-12-22 02:34:37 UTC (rev 40103)
@@ -185,8 +185,10 @@
 GRASS_WXBUNDLED=
 export GRASS_WXBUNDLED
 pyexe="pythonw"
+GRASS_PYTHONWX="$pyexe"
 pyver_want="@PYVER@"
-wx64bit="@WX64BIT@"
+GRASS_WX64BIT="@WX64BIT@"
+export GRASS_WX64BIT
 # make sure python version used matches what wxpython wants
 py=""
 # did user set GRASS_PYTHON already? check it (must have pythonw)
@@ -233,23 +235,15 @@
 
 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
+	GRASS_PYTHONWX="$py"
 else
 	echo "Warning: No Python $pyver_want found, needed by wxPython."
 	echo "         The wxPython GUI may not work properly."
 fi
+export GRASS_PYTHONWX
+# we will execute python scripts from the python wrapper script
+GRASS_PYTHON="python"
+export GRASS_PYTHON
 
 # 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

Added: grass/branches/develbranch_6/macosx/app/python_wrapper
===================================================================
--- grass/branches/develbranch_6/macosx/app/python_wrapper	                        (rev 0)
+++ grass/branches/develbranch_6/macosx/app/python_wrapper	2009-12-22 02:34:37 UTC (rev 40103)
@@ -0,0 +1,45 @@
+#! /bin/sh
+#############################################################################
+#
+# MODULE:   	python wrapper
+# AUTHOR(S):	William Kyngesburye - kyngchaos at kyngchaos.com
+# PURPOSE:  	handle arch options on OSX for running python.
+# COPYRIGHT:    (C) 2000-2008 by the GRASS Development Team
+#
+#               This program is free software under the GNU General Public
+#   	    	License (>=v2). Read the file COPYING that comes with GRASS
+#   	    	for details.
+#
+#############################################################################
+
+# wxpython-based scripts must be started from pythonw.  And depending on the
+# installed wxpython, it may only be available in 32bits, while python may
+# at the same time run 64bit by default.  Newer systems may also reexec python
+# as pythonw automatically as needed, except they don't respond to the arch
+# command (and that's an Apple-only thing, and only when /usr/bin/python is
+# used, yet /usr/bin/pythonw2.6 DOES respond to arch).  The most universal
+# and reliable method is probably to not depend on Apple's customizations and
+# execute pythonw directly, 32bit if necessary.
+
+if [ -z "$GISBASE" ] ; then
+    echo "You must be in GRASS GIS to run this program." >&2
+    exit 1
+fi
+
+SYSARCH=`uname -p`
+SYSVER=`uname -r | cut -d . -f 1`
+
+if [ ! "$GRASS_PYTHONWX" ] ; then
+	GRASS_PYTHONWX="pythonw"
+fi
+# can't run python 64bit if wx not 64bit, assume OSX 10.5+  possible 64bit
+if [ $(($SYSVER)) -gt 5 ] && [ "$GRASS_WX64BIT" = "0" ] ; then
+	case $SYSARCH in
+		powerpc) pyarch="-ppc" ;;
+		i386) pyarch="-i386" ;;
+		*) pyarch="" ;;
+	esac
+	exec /usr/bin/arch $pyarch "$GRASS_PYTHONWX" "$@"
+else
+	exec "$GRASS_PYTHONWX" "$@"
+fi


Property changes on: grass/branches/develbranch_6/macosx/app/python_wrapper
___________________________________________________________________
Added: svn:executable
   + *



More information about the grass-commit mailing list