python_wrapper 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #! /bin/sh
  2. #############################################################################
  3. #
  4. # MODULE: python wrapper
  5. # AUTHOR(S): William Kyngesburye - kyngchaos@kyngchaos.com
  6. # PURPOSE: handle arch options on OSX for running python.
  7. # COPYRIGHT: (C) 2000-2008 by the GRASS Development Team
  8. #
  9. # This program is free software under the GNU General Public
  10. # License (>=v2). Read the file COPYING that comes with GRASS
  11. # for details.
  12. #
  13. #############################################################################
  14. # wxpython-based scripts must be started from pythonw. And depending on the
  15. # installed wxpython, it may only be available in 32bits, while python may
  16. # at the same time run 64bit by default. Newer systems may also reexec python
  17. # as pythonw automatically as needed, except they don't respond to the arch
  18. # command (and that's an Apple-only thing, and only when /usr/bin/python is
  19. # used, yet /usr/bin/pythonw2.6 DOES respond to arch). The most universal
  20. # and reliable method is probably to not depend on Apple's customizations and
  21. # execute pythonw directly, 32bit if necessary.
  22. if [ -z "$GISBASE" ] ; then
  23. echo "You must be in GRASS GIS to run this program." >&2
  24. exit 1
  25. fi
  26. SYSARCH=`uname -p`
  27. SYSVER=`uname -r | cut -d . -f 1`
  28. if [ ! "$GRASS_PYTHONWX" ] ; then
  29. GRASS_PYTHONWX="pythonw"
  30. fi
  31. # can't run python 64bit if wx not 64bit, assume OSX 10.5+ possible 64bit
  32. if [ $(($SYSVER)) -gt 5 ] && [ "$GRASS_WX64BIT" = "0" ] ; then
  33. case $SYSARCH in
  34. powerpc) pyarch="-ppc" ;;
  35. i386) pyarch="-i386" ;;
  36. *) pyarch="" ;;
  37. esac
  38. exec /usr/bin/arch $pyarch "$GRASS_PYTHONWX" "$@"
  39. else
  40. exec "$GRASS_PYTHONWX" "$@"
  41. fi