-
Notifications
You must be signed in to change notification settings - Fork 4
/
install.sh
executable file
·69 lines (51 loc) · 1.9 KB
/
install.sh
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
#!/bin/bash
# U CAN TOUCH THIS
PYTHON_BIN="`which python2`" # python < 2.6 may not work D:
VIRTUALENV_BIN="`which virtualenv`"
PIP_BIN="`which pip`"
LIBXML2_VER="2.7.3" # <-- will be installed inside the virtualenv
[[ -z "$PYTHON_BIN" ]] && die "Python missing."
[[ -z "$VIRTUALENV_BIN" ]] && die "virtualenv missing."
[[ -z "$PIP_BIN" ]] && die "pip missing."
# U CANT TOUCH THIS
[[ `id -u` == 0 ]] && die "You are root, not nice!"
trap "exit 1;" TERM INT
function die() {
echo "Error! $1" > /dev/stderr
exit 1;
}
HERE_PATH="`dirname $0`"
DEST_PATH="$1"
[[ -z "$DEST_PATH" ]] && die "You need to give me a path for you new virtualenv"
[[ -e "$DEST_PATH" ]] && die "There's something in $1, remove it"
echo "Installing all in $DEST_PATH"
echo "Don't worry, won't touch stuff outside that dir."
echo "Starting in 3 seconds..."
sleep 3
echo "OK GO!"
mkdir -p "$DEST_PATH" || die "Can't write to $DEST_PATH"
# Setup & start virtualenv
$VIRTUALENV_BIN --python="$PYTHON_BIN" --distribute "$DEST_PATH" || die
source "$DEST_PATH/bin/activate"
# Install libxml2
TMPDIR=`mktemp -d --suffix=".libxml2-${LIBXML2_VER}"`
mkdir -p "$TMPDIR" || die "Can't write to $TMPDIR"
pushd $TMPDIR
echo "Building libxml2-${LIBXML2_VER} in $PWD"
wget ftp://ftp.xmlsoft.org/libxml2/libxml2-${LIBXML2_VER}.tar.gz
tar xzf libxml2-${LIBXML2_VER}.tar.gz
cd libxml2-${LIBXML2_VER}
./configure --prefix="$VIRTUAL_ENV" \
--with-threads \
--with-history \
--with-python="$VIRTUAL_ENV/bin/python" || die "configure failed"
make -j2 || die "make failed"
make install
popd
# we do this instead of "pip install -r pip-requirements.txt" cuz the order in
# which the packages are installed is important, and pip seems to ignore it.
for dep in `grep -e "^\w" "$HERE_PATH/pip-requirements.txt"`; do
$PIP_BIN install -E "$VIRTUAL_ENV" "$dep"
done
echo "Done! Your virtualenv and stuff is ready at $VIRTUAL_ENV"
exit 0