setup-virtualenv.sh 1.44 KB
Newer Older
hydrargyrum's avatar
hydrargyrum committed
1
2
#!/bin/sh -e

3
# install woob inside a virtualenv, optionally with an associated woob workdir
hydrargyrum's avatar
hydrargyrum committed
4
5
6
7
8
9
10
11
12
13
14
# can be combined with git-worktree

cd "$(dirname $0)/.."
SRC=$PWD

source=
VDIR=

usage () {
    cat << EOF
Usage: $0 [-s] [-d DIR]
15
  -s            point sources.list to $SRC/modules instead of updates.woob.tech
hydrargyrum's avatar
hydrargyrum committed
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
  -d DIR        install virtualenv in DIR instead of a new dir
EOF
}

while getopts hsd: name
do
    case $name in
    s) source=y;;
    d) VDIR="$OPTARG";;
    h) usage
       exit 0;;
    ?) usage
       exit 2;;
    esac
done
shift $(($OPTIND - 1))

hydrargyrum's avatar
hydrargyrum committed
33
PYTHON=${PYTHON-python3}
hydrargyrum's avatar
hydrargyrum committed
34

35
echo "Using woob source $SRC"
hydrargyrum's avatar
hydrargyrum committed
36
37
38

if [ -z "$VDIR" ]
then
39
    VDIR=$(mktemp -d /tmp/woob.venv.XXXXXX)
hydrargyrum's avatar
hydrargyrum committed
40
41
42
43
44
45
46
47
fi

cd "$VDIR"
echo "Creating env in $VDIR"

virtualenv -p "$(which "$PYTHON")" --system-site-packages "$VDIR"
. ./bin/activate

48
echo "Installing woob in $VDIR"
hydrargyrum's avatar
hydrargyrum committed
49
50
51
"$PYTHON" -m pip install "$SRC"

mkdir workdir
52
export WOOB_WORKDIR=$VDIR/workdir
hydrargyrum's avatar
hydrargyrum committed
53
54
55

if [ "$source" = y ]
then
56
    echo "file://$SRC/modules" > "$WOOB_WORKDIR/sources.list"
hydrargyrum's avatar
hydrargyrum committed
57
58
fi

59
cat > use-woob-local.sh << EOF
hydrargyrum's avatar
hydrargyrum committed
60
61
VDIR="$VDIR"
. "$VDIR/bin/activate"
62
export WOOB_WORKDIR="$VDIR/workdir"
hydrargyrum's avatar
hydrargyrum committed
63
64
65
66
EOF

cat << EOF
Installation complete in $VDIR.
67
Run ". $VDIR/use-woob-local.sh" to start using it.
hydrargyrum's avatar
hydrargyrum committed
68
69
70
71
72
73
74
75
Run "$PYTHON -m pip install -U $SRC" to reinstall the core.
EOF

if [ "$source" != y ]
then
    echo "You can add file://$SRC/modules into $VDIR/workdir/sources.list to use local modules instead of downloading modules."
fi

76
./bin/woob config update