ha-core/script/run-in-env.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

27 lines
545 B
Bash
Raw Normal View History

#!/usr/bin/env sh
set -eu
# Used in venv activate script.
# Would be an error if undefined.
OSTYPE="${OSTYPE-}"
# Activate pyenv and virtualenv if present, then run the specified command
# pyenv, pyenv-virtualenv
if [ -s .python-version ]; then
PYENV_VERSION=$(head -n 1 .python-version)
export PYENV_VERSION
fi
# other common virtualenvs
2020-07-29 19:50:09 +02:00
my_path=$(git rev-parse --show-toplevel)
for venv in venv .venv .; do
2020-07-29 19:50:09 +02:00
if [ -f "${my_path}/${venv}/bin/activate" ]; then
. "${my_path}/${venv}/bin/activate"
break
2020-07-29 19:50:09 +02:00
fi
done
exec "$@"