core/pkgs/by-name/py/python/hooks/venv-shell-hook.sh

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

29 lines
763 B
Bash
Raw Normal View History

2024-05-02 00:46:19 +00:00
venvShellHook() {
echo "Executing venvHook"
runHook preShellHook
if [ -d "${venvDir}" ]; then
echo "Skipping venv creation, '${venvDir}' already exists"
source "${venvDir}/bin/activate"
else
echo "Creating new venv environment in path: '${venvDir}'"
@pythonInterpreter@ -m venv "${venvDir}"
source "${venvDir}/bin/activate"
runHook postVenvCreation
fi
runHook postShellHook
echo "Finished executing venvShellHook"
}
if [ -z "${dontUseVenvShellHook:-}" ] && [ -z "${shellHook-}" ]; then
echo "Using venvShellHook"
if [ -z "${venvDir-}" ]; then
echo "Error: \`venvDir\` should be set when using \`venvShellHook\`."
exit 1
else
shellHook=venvShellHook
fi
fi