[GRASS-dev] Re: [GRASS-user] Grass 6.4 & python.

# Set the PYTHONPATH variable
PYTHONPATH="$GISBASE/etc/python:$GISBASE/Python25:$PYTHONPATH"
export PYTHONPATH

I don't know if it matters much for PYTHONPATH, but there is a small
issue with $PATH if set as above. If $PYTHONPATH is previously empty
then the search path becomes:
$GISBASE/etc/python:$GISBASE/Python25:

The final ":" at the end causes the pwd (".") to be added to the path.
that isn't always a problem but it can lead to unexpected results.

if the "$EMPTY:" comes first in the $PATH then it is more of a problem
because the unexpected copy is run not the system copy. e.g. it's a lot
easier for a nasty person to inject a program called "ls" into your home
directory and trick you into running it by mistake.

so longer but better is

if [ -z "$PYTHONPATH" ] ; then
  PYTHONPATH="$GISBASE/etc/python:$GISBASE/Python25"
else
  PYTHONPATH="$GISBASE/etc/python:$GISBASE/Python25:$PYTHONPATH"
fi
export PYTHONPATH

Hamish

I've updated the CompileOnWindows page to reflect this improved
PYTHONPATH, and I'll add it to the native installer in the next
version. Thanks.

-Colin

On Thu, Apr 30, 2009 at 12:03 AM, Hamish <hamish_b@yahoo.com> wrote:

# Set the PYTHONPATH variable
PYTHONPATH="$GISBASE/etc/python:$GISBASE/Python25:$PYTHONPATH"
export PYTHONPATH

I don't know if it matters much for PYTHONPATH, but there is a small
issue with $PATH if set as above. If $PYTHONPATH is previously empty
then the search path becomes:
$GISBASE/etc/python:$GISBASE/Python25:

The final ":" at the end causes the pwd (".") to be added to the path.
that isn't always a problem but it can lead to unexpected results.

if the "$EMPTY:" comes first in the $PATH then it is more of a problem
because the unexpected copy is run not the system copy. e.g. it's a lot
easier for a nasty person to inject a program called "ls" into your home
directory and trick you into running it by mistake.

so longer but better is

if [ -z "$PYTHONPATH" ] ; then
PYTHONPATH="$GISBASE/etc/python:$GISBASE/Python25"
else
PYTHONPATH="$GISBASE/etc/python:$GISBASE/Python25:$PYTHONPATH"
fi
export PYTHONPATH

Hamish