2020-01-13 20:45:24 +00:00
|
|
|
venvShellHook() {
|
|
|
|
echo "Executing venvHook"
|
|
|
|
runHook preShellHook
|
|
|
|
|
|
|
|
if [ -d "${venvDir}" ]; then
|
|
|
|
echo "Skipping venv creation, '${venvDir}' already exists"
|
2020-05-16 08:34:11 +01:00
|
|
|
source "${venvDir}/bin/activate"
|
2020-01-13 20:45:24 +00:00
|
|
|
else
|
|
|
|
echo "Creating new venv environment in path: '${venvDir}'"
|
|
|
|
@pythonInterpreter@ -m venv "${venvDir}"
|
|
|
|
|
2020-05-16 08:34:11 +01:00
|
|
|
source "${venvDir}/bin/activate"
|
|
|
|
runHook postVenvCreation
|
|
|
|
fi
|
2020-01-13 20:45:24 +00:00
|
|
|
|
|
|
|
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
|