@@ -340,17 +340,24 @@ add_user_jupyter_config() {
340340install_python () {
341341 version=$1
342342 # If the os-provided versions are "good enough", detect that and bail out.
343- if [ ${PYTHON_VERSION } = " os-provided" ] || [ ${PYTHON_VERSION } = " system" ]; then
343+ if [ ${version } = " os-provided" ] || [ ${version } = " system" ]; then
344344 check_packages python3 python3-doc python3-pip python3-venv python3-dev python3-tk
345345 INSTALL_PATH=" /usr"
346346
347- ln -s " ${INSTALL_PATH} /bin/python3" " ${INSTALL_PATH} /bin/python"
348- ln -s " ${INSTALL_PATH} /bin/pydoc3" " ${INSTALL_PATH} /bin/pydoc"
349- ln -s " ${INSTALL_PATH} /bin/python3-config" " ${INSTALL_PATH} /bin/python-config"
350-
351- # Add the current symlink but point it to "/usr" since python is at /usr/bin/python
352- mkdir -p " ${PYTHON_INSTALL_PATH} "
353- add_symlink
347+ local current_bin_path=" ${CURRENT_PATH} /bin"
348+ if [ " ${OVERRIDE_DEFAULT_VERSION} " = " true" ]; then
349+ rm -rf " ${current_bin_path} "
350+ fi
351+ if [ ! -d " ${current_bin_path} " ] ; then
352+ mkdir -p " ${current_bin_path} "
353+ # Add an interpreter symlink but point it to "/usr" since python is at /usr/bin/python, add other alises
354+ ln -s " ${INSTALL_PATH} /bin/python3" " ${current_bin_path} /python3"
355+ ln -s " ${INSTALL_PATH} /bin/python3" " ${current_bin_path} /python"
356+ ln -s " ${INSTALL_PATH} /bin/pydoc3" " ${current_bin_path} /pydoc3"
357+ ln -s " ${INSTALL_PATH} /bin/pydoc3" " ${current_bin_path} /pydoc"
358+ ln -s " ${INSTALL_PATH} /bin/python3-config" " ${current_bin_path} /python3-config"
359+ ln -s " ${INSTALL_PATH} /bin/python3-config" " ${current_bin_path} /python-config"
360+ fi
354361
355362 should_install_from_source=false
356363 elif [ " $( dpkg --print-architecture) " = " amd64" ] && [ " ${USE_ORYX_IF_AVAILABLE} " = " true" ] && type oryx > /dev/null 2>&1 ; then
@@ -399,12 +406,13 @@ if [ "${PYTHON_VERSION}" != "none" ]; then
399406
400407 if [ ${PYTHON_VERSION} != " os-provided" ] && [ ${PYTHON_VERSION} != " system" ]; then
401408 updaterc " if [[ \"\$ {PATH}\" != *\" ${CURRENT_PATH} /bin\" * ]]; then export PATH=${CURRENT_PATH} /bin:\$ {PATH}; fi"
402- chown -R " ${USERNAME} :python" " ${PYTHON_INSTALL_PATH} "
403- chmod -R g+r+w " ${PYTHON_INSTALL_PATH} "
404- find " ${PYTHON_INSTALL_PATH} " -type d -print0 | xargs -0 -n 1 chmod g+s
405-
406409 PATH=" ${INSTALL_PATH} /bin:${PATH} "
407410 fi
411+
412+ # Updates the symlinks for os-provided, or the installed python version in other cases
413+ chown -R " ${USERNAME} :python" " ${PYTHON_INSTALL_PATH} "
414+ chmod -R g+r+w " ${PYTHON_INSTALL_PATH} "
415+ find " ${PYTHON_INSTALL_PATH} " -type d -print0 | xargs -0 -n 1 chmod g+s
408416fi
409417
410418# Install Python tools if needed
0 commit comments