Skip to content

Commit 53daa58

Browse files
committed
Trick wrapped container venv
So the expectation if a user creates a venv on top of a wrapped container would be that invoking the venv python which launches shell commands again calling the python interpreter would call the venv python and not the base python
1 parent 9eb457c commit 53daa58

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

generate_wrappers.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,16 @@ printf -- '%s\n' "_tmp_arr=(\$(echo \$SINGULARITYENV_LD_LIBRARY_PATH | /usr/bin/
283283
printf -- '%s\n' "SINGULARITYENV_LD_LIBRARY_PATH=\$(echo \"\${_tmp_arr[@]}\" | /usr/bin/tr ' ' ':')" >> _deploy/common.sh
284284

285285
# Keep Venv path if we wrap a container and create
286+
# So the expectation if a user creates a venv on top of a wrapped container
287+
# would be that invoking the venv python which launches shell commands again
288+
# calling the python interpreter would call the venv python and not the base python
286289
if [[ "$CW_MODE" == "wrapcont" ]];then
287-
echo '[[ ${VIRTUAL_ENV+defined} && "$(readlink -f $_C_DIR)/bin/python" = $(readlink -f $VIRTUAL_ENV/bin/python) ]] && SINGULARITYENV_PATH="$VIRTUAL_ENV/bin:$SINGULARITYENV_PATH"' >> _deploy/common.sh
290+
echo '
291+
_venvd=$(/usr/bin/dirname $_O_SOURCE )
292+
test -e $_venvd/../pyvenv.cfg
293+
_v_in_use=$?
294+
[[ $_v_in_use -eq 0 && "$(dirname $(readlink -f $_venvd/python))" == "$(readlink -f $_C_DIR/bin)" ]] && SINGULARITYENV_PATH="$(readlink -f $_venvd):$SINGULARITYENV_PATH"
295+
' >> _deploy/common.sh
288296
fi
289297

290298
if [[ -f _extra_envs.sh ]];then

0 commit comments

Comments
 (0)