123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- #!/usr/bin/env bash
- set -e
- set -u
- set -o pipefail
- prompt_then_exit() {
- local prompt=${1-?}
- local status=${2-?}
- echo $prompt $status
- exit $status
- }
- get_python_version() {
- local firstline=
- read -r firstline < .python-version
- echo ${firstline}
- }
- drek_configure_main() {
- local python_version=$(get_python_version)
- local venv="venv"
- if [[ "Python ${python_version}" != $(python3 --version) ]]; then
- pyenv --version
- if [[ ! -d "${HOME}/.pyenv/versions/${python_version}" ]]; then
- pyenv install ${python_version}
- fi
- pyenv local ${python_version}
- fi
- python3 -m venv ./var/${venv} \
- && ./var/${venv}/bin/pip3 install --upgrade pip \
- && ./var/${venv}/bin/pip3 install ./ \
- || prompt_then_exit "drek configure failed" $?
- echo -e "\nActivate your local development environment:"
- echo -e "\n source ./var/${venv}/bin/activate"
- }
- drek_configure_main $@
|