-
Notifications
You must be signed in to change notification settings - Fork 0
/
activate-env.sh
executable file
·96 lines (83 loc) · 1.9 KB
/
activate-env.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
#!/bin/bash
# create and activate python environment for CgP-saarekkeet project
# script follows loosely https://google.github.io/styleguide/shell.xml
# about virtual envs: https://docs.python.org/3/library/venv.html
ENV_NAME=env-saarekkeet
#######################################
# Add created virtual env folder to
# .gitignore file if not already present.
# Globals:
# ENV_NAME
# Arguments:
# None
# Returns:
# None
#######################################
git_ignore_env() {
if ! grep -q ${ENV_NAME} .gitignore; then
echo $ENV_NAME >> .gitignore
fi
}
#######################################
# Activate the virtual env.
# Globals:
# ENV_NAME
# Arguments:
# None
# Returns:
# None
#######################################
activate_env() {
. ${ENV_NAME}/bin/activate
echo "* Virtual environment ${ENV_NAME} activated."
}
#######################################
# Install needed modules to created env.
#
# Installed modules:
# http://biopython.org/
# https://github.com/PyCQA/pycodestyle
# https://pypi.python.org/pypi/autopep8/
# https://www.pylint.org/
#
# Globals:
# ENV_NAME
# Arguments:
# None
# Returns:
# None
#######################################
install_modules() {
echo "* Installing modules for ${ENV_NAME}..."
pip install biopython
pip install pycodestyle
pip install --upgrade autopep8
pip install pylint
}
#######################################
# Create virtual env using python3.
# Globals:
# ENV_NAME
# Arguments:
# None
# Returns:
# None
#######################################
create_env() {
echo "* Creating $ENV_NAME..."
#python3 -m venv ${ENV_NAME}
virtualenv ${ENV_NAME}
}
# the "main"
if [ -d ${ENV_NAME} ]; then
activate_env
else
create_env
if [ -d ${ENV_NAME} ]; then
activate_env
install_modules
git_ignore_env
else
echo "** Failed to create environment!"
fi
fi