2013-01-21 23:02:57 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Install it into a nix profile and from there build symlink chains.
|
|
|
|
# The chain will be followed to set the PYTHONPATH
|
|
|
|
# A/bin/foo -> B/bin/bar -> NIXENV/bin/.python-linkme-wrapper.sh
|
|
|
|
#
|
|
|
|
|
|
|
|
if test ! -L "$0"; then
|
|
|
|
echo "Link me!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
PROG=$(basename "$0")
|
|
|
|
SITES=
|
|
|
|
|
|
|
|
pypath() {
|
2013-01-23 00:19:37 +04:00
|
|
|
BIN=$(realpath -s "$(dirname "$BIN")")
|
2013-01-21 23:02:57 +04:00
|
|
|
ENV=$(dirname "$BIN")
|
|
|
|
SITE="$ENV/lib/python2.7/site-packages"
|
|
|
|
SITES="$SITES${SITES:+:}$SITE"
|
|
|
|
|
2013-01-23 00:19:37 +04:00
|
|
|
PRG="$BIN"/$(readlink "$1")
|
2013-01-21 23:02:57 +04:00
|
|
|
|
|
|
|
if test -L "$PRG"; then
|
|
|
|
pypath "$PRG"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
pypath $(realpath -s "$0")
|
|
|
|
|
|
|
|
export PYTHONPATH="$PYTHONPATH${PYTHONPATH:+:}$SITES"
|
|
|
|
|
2013-01-23 00:19:37 +04:00
|
|
|
exec "$BIN/$PROG" "$@"
|