-
Notifications
You must be signed in to change notification settings - Fork 2
/
scripts.sh
executable file
·68 lines (53 loc) · 1.43 KB
/
scripts.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
#!/usr/bin/env bash
# Python virtual environment helpers
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
BASE_DIR="${PWD##*/}"
ENV_DIR=".venv"
DIST="${ROOT:?}/dist"
activate_env() {
echo "Activate $BASE_DIR"
deactivate >/dev/null 2>&1
# shellcheck source=src/script.sh
source "${ROOT:?}/$ENV_DIR/$BASE_DIR/bin/activate"
}
create_env() {
echo "create $BASE_DIR Python3 env"
deactivate || true
rm -rf "${ROOT:?}/$ENV_DIR" || true
mkdir -p "${ROOT:?}/$ENV_DIR"
python3 -m venv "${ROOT:?}/$ENV_DIR/$BASE_DIR" &&
activate_env &&
pip install --upgrade pip
}
init() {
create_env &&
pip install -r requirements.dev.txt
}
alias env:new=create_env
alias env:on=activate_env
alias env:reset=init
# Project helpers
test() {
pytest test/
}
backup() {
echo "Backup wheels..."
[[ -d "$wheels" ]] &&
find "${DIST}" -not -path "*$ENV_DIR/*" -name \*.whl -prune -exec cp '{}' "$wheels" \; &&
}
build() {
clean
python setup.py bdist_wheel &&
backup
}
release() {
pip install twine > /dev/null &&
twine upload "${DIST}/*"
}
clean() {
echo "cleaning build files..."
find . -type d -not -path "*$ENV_DIR/*" -name dist -prune -exec rm -r '{}' \; || true
find . -type d -not -path "*$ENV_DIR/*" -name build -prune -exec rm -r '{}' \; || true
find . -type d -not -path "*$ENV_DIR/*" -name "*.egg-info" -prune -exec rm -r '{}' \; || true
}
activate_env || true