#!/bin/sh

# Find directory of the original file, following symlinks.
# The ${parameter%/*} expansion strips the filename portion.
LINK=`readlink "${0}"`
if [ -z "${LINK}" ]; then BASE="${0%/*}"; else BASE="${LINK%/*}"; fi
ROOT=`(cd "${BASE}" 2>/dev/null && pwd)`
echo LINK: ${LINK}
echo BASE: ${BASE}
echo ROOT: ${ROOT}

PYTHON="$ROOT/Contents/MacOS/python"
PYTHONHOME="$ROOT/Contents/Resources"
PYTHONPATH="$ROOT/Contents/Resources"
DYLD_FRAMEWORK_PATH="$ROOT/Contents/Frameworks"
DYLD_LIBRARAY_PATH="$ROOT/Contents/Frameworks"
export PYTHONHOME PYTHONPATH DYLD_FRAMWORK_PATH DYLD_LIBRARY_PATH
DYLD_INSERT_LIBRARIES="$ROOT/Contents/Frameworks/libpython2.7.dylib" \
exec "$PYTHON" -m bumps.cli "$@"
