Przeglądaj źródła

use python wrapper script so arch command can be used to select OSX architecture and to force pythonw (sync from dev6 https://trac.osgeo.org/grass/changeset/40103)
remove old monitorcap processing

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@40105 15284696-431f-4ddb-bdfa-cd5b030d7da7

William Kyngesburye 15 lat temu
rodzic
commit
b50591aae4
4 zmienionych plików z 58 dodań i 16 usunięć
  1. 0 1
      macosx/Makefile
  2. 5 1
      macosx/app/Makefile
  3. 8 14
      macosx/app/grass.sh.in
  4. 45 0
      macosx/app/python_wrapper

+ 0 - 1
macosx/Makefile

@@ -97,7 +97,6 @@ install-basic-macosx:
 	if [ ${LOCALE} -eq 1 ] ; then cd ${GISBASE} ; tar cBf - locale | (cd ${INST_DIR_TARGET} ; tar xBf - ) 2>/dev/null ; fi
 	-cd ${GISBASE} ; tar cBf - include | (cd ${INST_DIR_TARGET} ; tar xBf - ) 2>/dev/null
 	-cd ${GISBASE} ; tar cBf - lib | (cd ${INST_DIR_TARGET} ; tar xBf - ) 2>/dev/null
-	-sed 's#'${GISBASE}'#'${INST_DIR_TARGET}'#g' ${GISBASE}/etc/monitorcap > ${INST_DIR_TARGET}/etc/monitorcap
 	-chmod -R a+rX ${PREFIX_TARGET}/${MACOSX_APP_NAME} 2>/dev/null
 	@#-cd ${GRASS_HOME} ; tar cBf - gem/skeleton | (cd ${INST_DIR_TARGET}/etc ; tar xBf - ) 2>/dev/null
 	@#-${INSTALL} ${GRASS_HOME}/gem/gem6 ${INST_DIR_TARGET} 2>/dev/null

+ 5 - 1
macosx/app/Makefile

@@ -37,6 +37,7 @@ NIBDST := $(patsubst English.lproj/%,$(APPDIR)/Resources/English.lproj/%,$(NIBSR
 FILES = \
 	$(APPDIR)/MacOS/etc/build_html_user_index.sh \
 	$(APPDIR)/MacOS/etc/build_gui_user_menu.sh \
+	$(APPDIR)/MacOS/bin/python \
 	$(APPDIR)/Resources/app.icns \
 	$(APPDIR)/Info.plist \
 	$(APPDIR)/PkgInfo \
@@ -50,7 +51,7 @@ default: macosxapp
 macosxapp:
 	-$(MAKE_DIR_CMD) $(OBJDIR)
 	-$(MAKE_DIR_CMD) $(APPDIR)/Resources/Scripts
-	-$(MAKE_DIR_CMD) $(APPDIR)/MacOS/scripts
+	-$(MAKE_DIR_CMD) $(APPDIR)/MacOS/bin
 	-$(MAKE_DIR_CMD) $(APPDIR)/MacOS/etc
 	-$(MAKE_DIR_CMD) $(APPDIR)/Resources/English.lproj/MainMenu.nib
 	$(MAKE) $(FILES)
@@ -76,6 +77,9 @@ $(APPDIR)/MacOS/grass.sh: $(OBJDIR)/grass.sh
 $(APPDIR)/MacOS/etc/%.sh: %.sh
 	$(INSTALL) $< $@
 
+$(APPDIR)/MacOS/bin/python: python_wrapper
+	$(INSTALL) $< $@
+
 $(OBJDIR)/main.o: main.m
 	$(MAKE_DIR_CMD) $(OBJDIR)
 	$(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(EXTRA_INC) -o $(OBJDIR)/main.o -c main.m

+ 8 - 14
macosx/app/grass.sh.in

@@ -142,8 +142,10 @@ fi # X11
 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)
@@ -190,23 +192,15 @@ fi
 
 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

+ 45 - 0
macosx/app/python_wrapper

@@ -0,0 +1,45 @@
+#! /bin/sh
+#############################################################################
+#
+# MODULE:   	python wrapper
+# AUTHOR(S):	William Kyngesburye - kyngchaos@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