1venvShellHook() {
2 echo "Executing venvHook"
3 runHook preShellHook
4
5 if [ -d "${venvDir}" ]; then
6 echo "Skipping venv creation, '${venvDir}' already exists"
7 else
8 echo "Creating new venv environment in path: '${venvDir}'"
9 @pythonInterpreter@ -m venv "${venvDir}"
10 fi
11
12 source "${venvDir}/bin/activate"
13
14 runHook postShellHook
15 echo "Finished executing venvShellHook"
16}
17
18if [ -z "${dontUseVenvShellHook:-}" ] && [ -z "${shellHook-}" ]; then
19 echo "Using venvShellHook"
20 if [ -z "${venvDir-}" ]; then
21 echo "Error: \`venvDir\` should be set when using \`venvShellHook\`."
22 exit 1
23 else
24 shellHook=venvShellHook
25 fi
26fi