diff --git a/env.sh b/env.sh new file mode 100644 index 0000000..b763209 --- /dev/null +++ b/env.sh @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: LGPL-2.1-only +# Copyright 2022 Jookia + +activate() { . _build/venv/bin/activate; } + +die() { + rm -r venv + echo "$1" + exit 1 +} + +setup() { + echo "No venv found, creating..." + python -m venv venv || die "Unable to create venv" + echo "Activating venv..." + activate + echo "Updating pip..." + pip -q install -U pip || die "Unable to update pip" + echo "Installing requirements..." + pip -q install -r requirements.txt || die "Unable to install requirements" + touch venv/.stamp + echo "All done!" +} + +if test -e venv/.stamp; then activate; else setup; fi + +dotidy() { black src tests; } +dolint() { flake8 src tests; } +dotest() { pytest -q -n auto --hypothesis-profile=dev; } +dotest_ci() { pytest -q -n auto --hypothesis-profile=ci; } +dotest_long() { pytest -q -n auto --hypothesis-profile=long; } +docheck() { dotidy && dolint && dotest; }