diff --git a/import/bin/_load-venv b/import/bin/_load-venv new file mode 100644 index 0000000..cdf646c --- /dev/null +++ b/import/bin/_load-venv @@ -0,0 +1,28 @@ +#!/usr/bin/env bash +set -euo pipefail + +upfind () { + if [ "$(realpath `dirname $1`)" == "/" ]; then + echo "ERROR: no $(basename $1) found in any parent directory." + exit 1 + fi + ls -d $1 2>/dev/null || upfind ../$1 +} + +if [ "${DISABLE_PROJECT_VENV_AUTO_CREATION:-}" == "" ]; then + if [ ! -x ./venv/bin/python ]; then + if hash pyenv 2>/dev/null; then + pyenv exec python -m venv venv + else + pythonVersion=$(cat $(upfind .python-version)) + pythonExecutable=python$pythonVersion + if ! hash $pythonExecutable 2>/dev/null; then + echo "ERROR: missing pyenv or $pythonExecutable" + exit 1 + fi + $pythonExecutable -m venv venv + fi + ./venv/bin/pip install -U pip + fi + source ./venv/bin/activate +fi diff --git a/import/bin/setup b/import/bin/setup new file mode 100755 index 0000000..fea1a4e --- /dev/null +++ b/import/bin/setup @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +set -euo pipefail +cd "$(dirname "$0")/.." +. bin/_load-venv + +pip install -U pip +pip install poetry +poetry install