1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
|
#!/bin/sh
# vim:set shiftwidth=4 tabstop=4 expandtab textwidth=79:
set -e
me=$(readlink -f $0)
pidadir=${me%/*}
distdir=$pidadir/build/egg
tmpdir=$pidadir/build/tmp
mkdir -p $pidadir/build/{egg,tmp}
REMOTE= GDB= PROFILE= PDB= UPDATE=
while [ $# -gt 0 ]; do
case "$1" in
-update) UPDATE=1 ;;
-remote) REMOTE=1 ;;
-gdb) GDB=1 ;;
-pdb) PDB=1 ;;
-profile) PROFILE=1 ;;
*) break ;;
esac
shift
done
if [ "$UPDATE" ]; then
echo "Updating pida ..."
svn up $pidadir || true
fi
# build pida
echo "Building pida ..."
if ( cd $pidadir; {
touch data/version
python setup.py rotate --dist-dir=$distdir --match=.egg --keep=3 &&
python setup.py build &&
grep '^Version:' pida.egg-info/PKG-INFO | cut -d' ' -f2- > data/version &&
python setup.py bdist --dist-dir=$distdir --formats=egg
} 2>&1 ) > $pidadir/buildlog.$$; then
rm $pidadir/buildlog.$$
elif zenity --text-info --title="I'm sorry, python setup.py failed :-(" \
--width=400 \
--filename="$pidadir/buildlog.$$" 2> /dev/null; then
true
else
echo "ERROR: python setup.py failed, log will follow"
sed -e 's,^, ,' $pidadir/buildlog.$$
echo "ERROR: END"
fi
if [ -f $pidadir/buildlog.$$ ]; then
mv $pidadir/buildlog.$$ $pidadir/buildlog.log
exit 1
fi
pyver=`python -V 2>&1 | cut -d' ' -f2 | cut -c1-3`
version=`cat $pidadir/data/version`
eggpath=$( echo build/bdist.`uname -s`-`uname -m`/egg | tr A-Z a-z )
egg="$distdir/pida-${version//-/_}-py$pyver.egg"
echo "Adding ${egg#$pidadir/} to '\$PYTHONPATH' ..."
export PYTHONPATH=$egg:$PYTHONPATH
pidacmd=$tmpdir/pida
tmpfile=$pidacmd.$$
if [ "$REMOTE" ]; then
echo "import pida.utils.pidaremote as pidaremote"
echo "pidaremote.main()"
else
echo "from pkg_resources import load_entry_point"
if [ "$PDB" ]; then
echo "import pdb"
echo "pdb.set_trace()"
else
echo "import pida.utils.debug as debug"
echo "debug.configure_tracer( eggpath='$eggpath', pidadir='$pidadir/' )"
fi
echo "entry_point=load_entry_point('pida', 'console_scripts', 'pida')"
if [ "$PROFILE" ]; then
echo "import profile"
echo "profile.run('entry_point()')"
else
echo "import sys"
echo "sys.exit( entry_point() )"
fi
fi > $tmpfile
mv $tmpfile $pidacmd
pidacmd="$pidacmd $*"
echo "Running $pidacmd ..."
if [ "$GDB" ]; then
echo "run $pidacmd" > $tmpfile
gdb python -q -x $tmpfile
wait
errno=$?
rm $tmpfile
exit $errno
else
eval exec "python $pidacmd"
fi
|