-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvenv.sh
executable file
·122 lines (90 loc) · 2.59 KB
/
venv.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
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#! /usr/bin/env bash
VENV="$HOME/.virtualenvs"
GIT_DIR=$(dirname "$0")"/.git/"
BRANCH=$(git --git-dir "$GIT_DIR" symbolic-ref --short -q HEAD 2>/dev/null \
|| echo "unknown-branch")
VDIR="$VENV/sibilant-$BRANCH"
VBIN="$VDIR/bin"
CMD="$1"
shift
SYSPYTHON=$(which python3)
if test ! -x "$SYSPYTHON" ; then
echo "Error: Could not find python3, exiting."
exit 1
fi
# prevent virtualenv from ending up with too deeply nested symlinks
SYSPYTHON=$(readlink -f "$SYSPYTHON")
VIRTUALENV="$SYSPYTHON -m venv"
if test "$CMD" == "help" || test -z "$CMD" ; then
cat <<EOF
Usage: $0 COMMAND [CMD_OPTS]
Builds and deploys into a virtualenv under:
$VDIR
This is based on the current branch of this git repository:
$BRANCH
COMMAND may be one of the following:
help show this message and exit
init setup (and clear if existing) a basic virtualenv
install build and install sibilant wheel into virtualenv
setup run setup.py from the virtualenv (hint: setup install)
python run python from the virtualenv
pip run pip from the virtualenv
pdb-python run python in the virtualenv from pdb
pdb-sibilant run sibilant in the virtualenv from pdb
sibilant run sibilant from the virtualenv
sys-python run system python with PYTHONHOME set (fixes wx issues)
sys-sibilant run sibilant using system python with PYTHONHOME set
CMD_OPTS are passed to the handler for the COMMAND (where applicable)
EOF
exit 1
fi
# echo -e "Current branch is $BRANCH so working in:\n $VDIR"
case "$CMD" in
init)
echo -e "Current branch is $BRANCH so working in:\n $VDIR"
mkdir -p "$VDIR"
$VIRTUALENV "$VDIR" "$@" || exit $?
"$VBIN/pip" install --upgrade pip
"$VBIN/pip" install flake8 mypy flake8-mypy wheel
;;
install)
$VIRTUALENV "$VDIR" || exit $?
rm -rf build dist
"$VBIN/python" setup.py bdist_wheel || exit $?
"$VBIN/pip" install -I dist/*.whl || exit $?
;;
setup|setup.py)
"$VBIN/python" setup.py "$@" || exit $?
;;
sibilant)
"$VBIN/sibilant" "$@"
;;
python)
"$VBIN/python" "$@"
;;
pip)
"$VBIN/pip" "$@"
;;
pdb-python)
"$VBIN/python" -m pdb "$@"
;;
pdb-sibilant)
"$VBIN/python" -m pdb "$@" "$VBIN/sibilant"
;;
sys-python)
# wxPython doesn't like virtualenv very much on macOS. You
# have to run the system version, and get it to operate inside
# the venv by setting the PYTHONHOME parameter.
PYTHONHOME="$VDIR" "$SYSPYTHON" "$@"
;;
sys-sibilant)
PYTHONHOME="$VDIR" "$SYSPYTHON" "$VBIN/sibilant" "$@"
;;
*)
echo -e "Unknown command: $CMD"
echo -e "Try: $0 help"
exit 1
;;
esac
#
# The end.