summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Sverzut Barbieri <barbieri@gmail.com>2009-11-04 10:56:42 +0000
committerGustavo Sverzut Barbieri <barbieri@gmail.com>2009-11-04 10:56:42 +0000
commit07c726c385d876b50c6fcbafc8dc8cd1f888dc72 (patch)
tree90f66988c7649965a38d6799ebdc54ffdc75351c
parentab2db3f4aa84f12da40a73923404e9ca957a87fd (diff)
better python helper scripts, specially for new users.
This new scripts supports: * --help * --home to force installing to $HOME/usr * --system to force installing to /usr * automatically checks for cython * automatically checks for pyrex * checks for write access to $PREFIX * checks for existence of $PYLIBDIR * checks for $HOME/usr in $PYTHONPATH before trying to install to it * log to files for less output during compiles SVN revision: 43447
-rwxr-xr-xbuild.sh92
1 files changed, 87 insertions, 5 deletions
diff --git a/build.sh b/build.sh
index e3cfd7d..9f8e796 100755
--- a/build.sh
+++ b/build.sh
@@ -1,20 +1,102 @@
1#!/bin/sh 1#!/bin/sh
2 2
3PREFIX="$HOME/usr"
4PYX_FILES="ethumb/ethumb.c_ethumb.pyx ethumb/ethumb.client.pyx" 3PYX_FILES="ethumb/ethumb.c_ethumb.pyx ethumb/ethumb.client.pyx"
5 4
5usage() {
6 cat <<EOF
7Usage:
8
9 $0 <options>
10
11where options:
12
13 --force force rebuild of whole tree, will not trust cython
14 dependency checking.
15 --system install to /usr
16 --home install to $HOME/usr
17 --prefix=XXX install to XXX
18
19EOF
20}
21
22die() {
23 echo "ERROR: $*"
24 exit 1
25}
26
27PREFIX=""
6for arg in $@; do 28for arg in $@; do
7 case $arg in 29 case $arg in
8 --force) 30 --force)
9 touch $PYX_FILES 31 touch $PYX_FILES
10 ;; 32 ;;
33 --system)
34 PREFIX="/usr"
35 ;;
36 --home)
37 PREFIX="$HOME/usr"
38 ;;
39 --help)
40 usage
41 exit 0
42 ;;
43 --prefix=*)
44 PREFIX=`echo "$arg" | cut -d= -f2`
45 ;;
11 *) 46 *)
12 PREFIX="$arg" 47 die "unknown option $arg"
13 ;; 48 ;;
14 esac 49 esac
15done 50done
16 51
17PYINCDIR=`python -c "import distutils.sysconfig; print distutils.sysconfig.get_python_inc()" | cut -d/ -f3-` 52if [ -z "$PREFIX" ]; then
18INCDIR="$PREFIX/$PYINCDIR" 53 if [ ! -z "$PYTHONPATH" ] && \
54 echo "$PYTHONPATH" | tr ':' '\n' | grep -e "^$HOME/usr" >/dev/null 2>/dev/null; then
55 PREFIX="$HOME/usr"
56 else
57 PREFIX="/usr"
58 fi
59
60 echo "INFO: no --system, --home or explicit prefix given, using $PREFIX"
61fi
62
63PYINCDIR=`python -c "import distutils.sysconfig; print distutils.sysconfig.get_python_inc(prefix='$PREFIX')"`
64PYLIBDIR=`python -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib(prefix='$PREFIX')"`
65
66if ! touch "$PREFIX" 2>/dev/null; then
67 die "no permission to write to $PREFIX. needs sudo?"
68fi
69if [ ! -d "PYINCDIR" ] && ! mkdir -p $PYINCDIR 2>/dev/null; then
70 die "could not create $PYINCDIR"
71fi
72if [ ! -d "PYLIBDIR" ] && ! mkdir -p $PYLIBDIR 2>/dev/null; then
73 die "could not create $PYLIBDIR"
74fi
75if ! which cython >/dev/null; then
76 die "cython is not installed"
77fi
78if ! which pyrexc >/dev/null; then
79 die "pyrexc (python-pyrex) is not installed"
80fi
81
82if [ -z "$TMPDIR" ]; then
83 TMPDIR="/tmp"
84fi
85DNAME=`dirname $0`
86if [ "$DNAME" = "." ]; then
87 DNAME="$PWD"
88fi
89PRJ=`basename $DNAME`
90LOG="$TMPDIR/$PRJ"
91LOG_OUT="$LOG.out"
92LOG_ERR="$LOG.err"
93
94echo ""
95echo "install: $PRJ prefix=$PREFIX"
96python setup.py build_ext --include-dirs="$PYINCDIR" develop --prefix="$PREFIX" install_headers --install-dir="$PYINCDIR" >"$LOG_OUT" 2>"$LOG_ERR"
97if [ $? -eq 0 ]; then
98 echo "successfully installed, see $LOG_OUT and $LOG_ERR"
99else
100 echo "failed to install, see $LOG_OUT and $LOG_ERR"
101fi
19 102
20python setup.py build_ext --include-dirs="$INCDIR" develop --prefix="$PREFIX" install_headers --install-dir="$INCDIR"