nad0020 OS X "Update Shell Profile" may not update $PATH if run more than once An instance of the shell script "Update Shell Profile.command" is installed in each "/Applications/Python x.x" folder. Clicking on the script allows the user to change the default Python version. If the scripts are run more than once - say first to make 3.0 the default then 2.6 the default then back to 3.0 again - the script will fail to update the user's $PATH, forcing users to manually edit their shell profile. SOLUTION Ensure that $PATH is updated if there are other Python frameworks already on its head. (This is not the most elegant solution since it leaves the previous versions later in the path but it is safer to only append to the user's profile - and a backup copy is made.) APPLIES py3k, 3.0, trunk, 2.6 diff Mac/BuildScript/scripts/postflight.patch-profile diff -r 47f5f4fa6aed Mac/BuildScript/scripts/postflight.patch-profile --- Mac/BuildScript/scripts/postflight.patch-profile Thu Feb 12 01:10:01 2009 -0800 +++ Mac/BuildScript/scripts/postflight.patch-profile Thu Feb 12 01:35:04 2009 -0800 @@ -34,11 +34,14 @@ esac # Now ensure that our bin directory is on $P and before /usr/bin at that +# and that there is not another python framework before it for elem in `echo $P | tr ':' ' '` do if [ "${elem}" == "${PYTHON_ROOT}/bin" ]; then echo "All right, you're a python lover already" exit 0 + elif [ "${elem%%Versions/*}" == "${PYTHON_ROOT%%Versions/*}" ]; then + break elif [ "${elem}" == "/usr/bin" ]; then break fi @@ -56,6 +59,12 @@ if [ -f "${RC}" ]; then cp -fp "${RC}" "${RC}.pysave" fi + grep -q "# Setting PATH for MacPython" "${RC}" && \ + echo "" && \ + echo "It looks like your profile was updated previously to another" && \ + echo "MacPython version. This update should work but you may" && \ + echo "want to edit ${RC} to remove the old version." && \ + echo "" echo "" >> "${RC}" echo "# Setting PATH for MacPython ${PYVER}" >> "${RC}" echo "# The orginal version is saved in .cshrc.pysave" >> "${RC}" @@ -85,6 +94,12 @@ if [ -f "${PR}" ]; then cp -fp "${PR}" "${PR}.pysave" fi +grep -q "# Setting PATH for MacPython" "${PR}" && \ + echo "" && \ + echo "It looks like your profile was updated previously to another" && \ + echo "MacPython version. This update should work but you may" && \ + echo "want to edit ${PR} to remove the old version." && \ + echo "" echo "" >> "${PR}" echo "# Setting PATH for MacPython ${PYVER}" >> "${PR}" echo "# The orginal version is saved in `basename ${PR}`.pysave" >> "${PR}"