-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvenv
More file actions
executable file
·51 lines (41 loc) · 834 Bytes
/
venv
File metadata and controls
executable file
·51 lines (41 loc) · 834 Bytes
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
#!/bin/bash
# create venv and .env file for autovenv in current path
# vars
PARAM=$1
CMD="virtualenv venv"
RC=0
# checks
if [[ ${PARAM} != "create" ]]; then
echo "Usage: $(basename $0) create"
RC=1
fi
# create venv
if [[ $RC -eq 0 ]]; then
eval ${CMD}
RC=$?
fi
# update config files
if [[ $RC -eq 0 ]]; then
echo "source venv/bin/activate" > .env
else
echo "==> error creating Python venv. RC: ${RC}"
fi
# update .gitignore
if [[ $RC -eq 0 ]]; then
echo .env >> .gitignore
echo venv >> .gitignore
RC=$?
fi
# print summary and info
if [[ $RC -eq 0 ]]; then
echo
echo "* created Python venv: $(pwd)/venv"
echo "* created autovenv config: $(pwd)/.env"
echo "* updated .gitignore"
echo
echo "Enter \"cd .\" to activate venv"
echo "Enter \"deactivate\" to exit"
echo
fi
cd $(pwd)
exit ${RC}