-
Notifications
You must be signed in to change notification settings - Fork 0
/
devenv.sh
executable file
·88 lines (75 loc) · 1.79 KB
/
devenv.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
#!/bin/bash -e
# stolen from https://raw.githubusercontent.com/kokosing/git-gifi/master/devenv.sh
# thanks grzesiek
if [[ "$VIRTUAL_ENV" == "" ]]; then
VIRTUAL_ENV="/Users/losipiuk/workspace/virtualenvs/ircmdbot"
fi
COMMANDS="help init install build release"
SETUP='python setup.py'
function _err() {
echo $*
exit 1
}
function _activate_virtual_env() {
if [ -d $VIRTUAL_ENV ]; then
source $VIRTUAL_ENV/bin/activate
else
_err "Unable to find virtual env at $VIRTUAL_ENV"
fi
}
function init() {
sudo apt-get install python-dev
virtualenv $VIRTUAL_ENV
source $VIRTUAL_ENV/bin/activate
_activate_virtual_env
$SETUP develop
pip install wheel
pip install twine
echo
echo "Remember to 'source $VIRTUAL_ENV/bin/activate', before coding"
}
function build() {
_activate_virtual_env
$SETUP flake8
# $SETUP test
$SETUP install
}
function release() {
VERSION=$(cat setup.py | grep version | sed 's/.*0\.\(.*\)-.*/\1/g')
_change_version 0.$VERSION
rm -rf dist
build
$SETUP register
$SETUP bdist_wheel
$SETUP bdist_wheel --universal
$SETUP sdist
twine upload dist/*
NEXT_VERSION=$(echo $VERSION + 1 | bc)
_change_version 0.$NEXT_VERSION-SNAPSHOT
MESSAGE="Release 0.$VERSION"
git commit -a -m "$MESSAGE"
git tag -a -m "$MESSAGE" 0.$VERSION
git push
git push --tags
}
function _change_version() {
sed 's/\(.*version=.\).*\(.,.*\)/\1'$1'\2/g' setup.py > tmp
mv tmp setup.py
}
function help() {
cat << EOF
$0 COMMAND [command arguments]
Commands:
help - display this window
init - init sandbox (install virtual env and dependencies)
build - build project
EOF
}
if [[ $# = 0 ]]; then
help
exit
fi
COMMAND=$1
shift
echo $COMMANDS | tr ' ' '\n' | grep -q "${COMMAND}" || _err "Invalid command: $COMMAND, try help command first."
$COMMAND $*