#!/bin/sh
#set -e

. $KUMATUXBIN/kumatux.org-vars

KUMATUX_PYTHONPATH_ESCAPED=`$KUMATUXBIN/kumatux.org-sed-escape $KUMATUX_PYTHONPATH`
if [ "$KUMATUX_PYTHONPATH_ESCAPED" ]
then
    SYSTEM_PYTHONPATH=`echo $PYTHONPATH | sed "s/$KUMATUX_PYTHONPATH_ESCAPED://" | sed "s/$KUMATUX_PYTHONPATH_ESCAPED//"`
else
    SYSTEM_PYTHONPATH=$PYTHONPATH
fi

## Python prints version as an error message, duh!
PYVER=`python --version 2>&1 | sed 's/Python \(...\).*/\1/'`
export KUMATUX_PYTHONPATH=`cat $KUMATUXETC/$KUMATUXETCPYTHON/$PYVER/*.conf 2>/dev/null`/usr/lib/python-site-packages

if [ "$SYSTEM_PYTHONPATH" ]
then
    export PYTHONPATH="$KUMATUX_PYTHONPATH:$SYSTEM_PYTHONPATH"
else
    export PYTHONPATH=$KUMATUX_PYTHONPATH
fi
