-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpython-venv-create.sh
More file actions
executable file
·91 lines (75 loc) · 1.81 KB
/
python-venv-create.sh
File metadata and controls
executable file
·91 lines (75 loc) · 1.81 KB
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
#!/usr/bin/env sh
set -e -u
_required_major_version=3
_required_minor_version=6
HOST=`uname -n`
ME=`basename $0`
OS=`uname`
# tmpfile=`mktemp -t $ME.XXXXX`
# Echo our args to standard error.
errecho()
{
echo "$*" >&2
}
die() {
errcode=$1
shift
errecho "$*"
exit $errcode
}
# The infamous usage function.
usage()
{
errecho "usage:${ME} [ -hnx ]"
exit 1
}
N=" "
####################
### Process command line arguments
while getopts hnx opt
do
case $opt in
# Look for signs for help...
h) # help
cat <<EOF
-h You're soaking in it.
-n noop / dryrun
-x set -x
EOF
exit 1
;;
n) N=echo;;
x) set -x;;
*) usage ;;
esac
done
# This gets rid off all the command line flags and their args, so that
# only the file or dir. name(s) remain.
shift `expr $OPTIND - 1`
####################
# rm $tmpfile
if [ $# -ne 2 ] ; then
die 11 "Please supply two arguments: the python interpreter AND the destination directory where the venv will be created"
fi
_python="${1}"
_venv_dir="${2}"
_python_release=`"${_python}" --version | sed 's/^Python //'`
_python_major_version=`echo $_python_release | awk -F. '{print $1}'`
_python_minor_version=`echo $_python_release | awk -F. '{print $2}'`
_python_series="${_python_major_version}.${_python_minor_version}"
_old_version_mess="The RIPE Atlas packages require version ${_required_major_version}.${_required_minor_version} or later for proper SSL support."
if [ "${_python_major_version}" -lt $_required_major_version ] ; then
die 12 "${_old_version_mess}"
elif [ $_python_minor_version -lt $_required_minor_version ] ; then
die 13 "${_old_version_mess}"
fi
_pip3="pip-${_python_series}"
"${_python}" -m venv "${_venv_dir}"
#env
. "${_venv_dir}/bin/activate"
#echo "------"
#env
type pip
set -x
pip install --upgrade pip
pip install -r requirements.txt