|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +# Bash Unofficial strict mode (http://redsymbol.net/articles/unofficial-bash-strict-mode/) |
| 4 | +# and (https://disconnected.systems/blog/another-bash-strict-mode/) |
| 5 | +set -o nounset # Any uninitialized variable is an error |
| 6 | +set -o errexit # Exit the script on the failure of any command to execute without error |
| 7 | +set -o pipefail # Fail command pipelines on the failure of any individual step |
| 8 | +IFS=$'\n\t' #set internal field separator to avoid iteration errors |
| 9 | +# Trap all exits and output something helpful |
| 10 | +trap 's=$?; echo "$0: Error on line "$LINENO": $BASH_COMMAND"; exit $s' ERR |
| 11 | + |
| 12 | +# This script should be run by new developers to install this package in |
| 13 | +# editable mode and configure their local environment |
| 14 | + |
| 15 | +echo "Checking virtual environment" |
| 16 | +if [ "${VIRTUAL_ENV:-missing}" = "missing" ] && [ "${CONDA_PREFIX:-missing}" = "missing" ]; then |
| 17 | + echo 'No virtual environment detected: none of $VIRTUAL_ENV or $CONDA_PREFIX is set.' |
| 18 | + echo |
| 19 | + echo "=== This script is going to install the project in the system python environment ===" |
| 20 | + echo "Proceed? [y/N]" |
| 21 | + read -r RESPONCE |
| 22 | + if [ "${RESPONCE}" != "y" ]; then |
| 23 | + echo "See https://lincc-ppt.readthedocs.io/ for details." |
| 24 | + echo "Exiting." |
| 25 | + exit 1 |
| 26 | + fi |
| 27 | + |
| 28 | +fi |
| 29 | + |
| 30 | +echo "Checking pip version" |
| 31 | +MINIMUM_PIP_VERSION=22 |
| 32 | +pipversion=( $(python -m pip --version | awk '{print $2}' | sed 's/\./\n\t/g') ) |
| 33 | +if let "${pipversion[0]}<${MINIMUM_PIP_VERSION}"; then |
| 34 | + echo "Insufficient version of pip found. Requires at least version ${MINIMUM_PIP_VERSION}." |
| 35 | + echo "See https://lincc-ppt.readthedocs.io/ for details." |
| 36 | + exit 1 |
| 37 | +fi |
| 38 | + |
| 39 | +echo "Installing package and runtime dependencies in local environment" |
| 40 | +python -m pip install -e . > /dev/null |
| 41 | + |
| 42 | +echo "Installing developer dependencies in local environment" |
| 43 | +python -m pip install -e .'[dev]' > /dev/null |
| 44 | +if [ -f docs/requirements.txt ]; then python -m pip install -r docs/requirements.txt > /dev/null; fi |
| 45 | + |
| 46 | +echo "Installing pre-commit" |
| 47 | +pre-commit install > /dev/null |
| 48 | + |
| 49 | +####################################################### |
| 50 | +# Include any additional configurations below this line |
| 51 | +####################################################### |
0 commit comments