-
Notifications
You must be signed in to change notification settings - Fork 9
/
setup_env.sh
executable file
·37 lines (32 loc) · 925 Bytes
/
setup_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
#!/bin/bash
# $1: Python version.
# $2: Virtual environment name.
# $3: Requirements file.
#====================================================
# Metadata
#====================================================
# File name: setup_env.sh
# Author: Gianluca Bianco (biancogianluca9@gmail.com)
# Date: 2022-01-14
# Copyright: (c) 2022 Gianluca Bianco under the MIT license.
# Variables
version=$1
venv=$2
reqs=$3
# Creating the virtualenv
if [[ ! -d ${venv} ]] ; then
if [ "${venv}" != "" ] ; then
if ! virtualenv "${venv}" -p python"${version}" ; then
echo "Error: missing Python ${version} installation."
exit 1
fi
fi
if [ "${reqs}" != "" ] ; then
echo "Installing prerequisites..."
pip install -r "${reqs}"
fi
fi
# Activating virtual environment
echo "Activating the virtual environment..."
source ${venv}/bin/activate
echo "Done."