nmigen-learning/.remoteenv
2023-07-08 02:59:40 +02:00

35 lines
785 B
Bash

#!/usr/bin/env bash
POETRY='exit 99'
if type -P poetry >/dev/null; then
POETRY='poetry'
else
if ! type -P pip3 >/dev/null; then
echo "Neither pip3 nor poetry is available on this host: $(hostname)"
exit 1
fi
if ! test -d '.poetry_pypath/poetry'; then
# NOTE: .poetry_pypath should be ignored during remote-exec [pull]
echo "Poetry not found, downloading it to .poetry_pypath/ ..."
pip3 install -t '.poetry_pypath' poetry || exit $?
fi
export PYTHONPATH=".poetry_pypath:$PYTHONPATH"
POETRY='python3 -m poetry'
fi
if ! test -f "poetry.toml" ; then
$POETRY config --local virtualenvs.in-project true
fi
if ! test -d ".venv" ; then
$POETRY install || exit $?
fi
alias poetry="$POETRY"
exec $POETRY shell