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

Hamish hamish_b at yahoo.com
Thu Apr 30 00:03:52 EDT 2009


> # 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



      



More information about the grass-dev mailing list