#!/bin/bash

# this script figures out the location of the system Python
# modules - note that we are using the python in /usr/bin
# for this, and not the one in the users environment

SYSLIB="$1"

if [ "$(uname -s)" == "Darwin" ]; then
    echo "$SYSLIB/pegasus/python"
    exit 0
fi

VERSION=`/usr/bin/python -V 2>&1 | sed -e 's/^.* \([0-9]\.[0-9]\).*$/\1/'`

FINAL_LOCATION="NONE"

for LOCATION in \
    "/usr/$SYSLIB/python$VERSION/dist-packages" \
    "/usr/$SYSLIB/python$VERSION/site-packages" \
    "/Library/Python/$VERSION/site-packages" \
; do
    if [ -e "$LOCATION" ]; then
        FINAL_LOCATION="$LOCATION"
        break
    fi
done

# remote the prefix
FINAL_LOCATION=`echo "$FINAL_LOCATION" | sed -e 's/^\/usr//' | sed -e 's:^/*::'`

echo $FINAL_LOCATION

