-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvirtenv
executable file
·56 lines (50 loc) · 1.48 KB
/
virtenv
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
#!/bin/bash
#
# Copyright (c) 2018-2020 by Kristoffer Paulsson <[email protected]>.
#
# This software is available under the terms of the MIT license. Parts are licensed under
# different terms if stated. The legal terms are attached to the LICENSE file and are
# made available on:
#
# https://opensource.org/licenses/MIT
#
# SPDX-License-Identifier: MIT
#
# Contributors:
# Kristoffer Paulsson - initial implementation
#
HELP=$(cat << EOF
Use "virtenv" to handle a Python 3.x virtual environment for Angelos.
> virtenv ( setup | start | stop )
SETUP: Creates a new virtual environment and upgrades pip, setuptools
and wheel to latest version, then install requirements and setup
Angelos in development mode.
START: Starts an already existent virtual environment.
STOP: Stops an already running virtual environment.
EOF
)
[ -z ${VIRTUAL_ENV} ] && IN_VENV=1 || IN_VENV=0
case $1 in
setup)
[ $IN_VENV ] && echo "Already inside a virtual environment!" && exit 1
python3 -m virtualenv venv -p /usr/bin/python3
source venv/bin/activate
pip install pip --upgrade
pip install setuptools --upgrade
pip install wheel --upgrade
pip install -r requirements.txt
pip install -e .
;;
start)
[ $IN_VENV ] && echo "Already inside a virtual environment!" && exit 1
source venv/bin/activate
;;
stop)
! [ $IN_VENV ] && echo "No active virtual environment!." && exit 1
deactivate
;;
*)
echo "$HELP"
exit 1
;;
esac