check if multiple Python versions are selected and use the first one

This commit is contained in:
Romwierz 2026-09-08 12:05:04 +02:00
parent 2eb849102a
commit fbd0abd3f7

View file

@ -68,7 +68,18 @@ if [ "${PYENV_BIN_PATH#${PYENV_ROOT}}" != "${PYENV_BIN_PATH}" ]; then
export PATH="${PYENV_BIN_PATH}:${PATH}"
fi
if [ -n "$MODIFY_ENV" ]; then
export PYTHONHOME="$(pyenv-prefix)"
# Check if multiple Python versions are selected
VERSIONS=$(pyenv-prefix)
if [[ "$VERSIONS" == *:* ]]; then
echo 'Warning: multiple Python versions are selected'
VERSION="${VERSIONS%%:*}"
echo "Using the first one available (${VERSION##*/})"
else
VERSION="$VERSIONS"
fi
# Assign the correct version of PYTHONHOME
export PYTHONHOME="$VERSION"
export LD_LIBRARY_PATH="${PYTHONHOME}/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}"
fi
exec "$PYENV_COMMAND_PATH" "$@"