source: vendor/python/2.5/Mac/BuildScript/scripts/postflight.patch-profile

Last change on this file was 3225, checked in by bird, 19 years ago

Python 2.5

File size: 2.3 KB
RevLine 
[3225]1#!/bin/sh
2
3echo "This script will update your shell profile when the 'bin' directory"
4echo "of python is not early enough of the PATH of your shell."
5echo "These changes will be effective only in shell windows that you open"
6echo "after running this script."
7
8PYVER=2.5
9PYTHON_ROOT="/Library/Frameworks/Python.framework/Versions/Current"
10
11if [ `id -ur` = 0 ]; then
12 # Run from the installer, do some trickery to fetch the information
13 # we need.
14 theShell="`finger $USER | grep Shell: | head -1 | awk '{ print $NF }'`"
15
16else
17 theShell="${SHELL}"
18fi
19
20# Make sure the directory ${PYTHON_ROOT}/bin is on the users PATH.
21BSH="`basename "${theShell}"`"
22case "${BSH}" in
23bash|ksh|sh|*csh)
24 if [ `id -ur` = 0 ]; then
25 P=`su - ${USER} -c 'echo A-X-4-X@@$PATH@@X-4-X-A' | grep 'A-X-4-X@@.*@@X-4-X-A' | sed -e 's/^A-X-4-X@@//g' -e 's/@@X-4-X-A$//g'`
26 else
27 P="`(exec -l ${theShell} -c 'echo $PATH')`"
28 fi
29 ;;
30*)
31 echo "Sorry, I don't know how to patch $BSH shells"
32 exit 0
33 ;;
34esac
35
36# Now ensure that our bin directory is on $P and before /usr/bin at that
37for elem in `echo $P | tr ':' ' '`
38do
39 if [ "${elem}" == "${PYTHON_ROOT}/bin" ]; then
40 echo "All right, you're a python lover already"
41 exit 0
42 elif [ "${elem}" == "/usr/bin" ]; then
43 break
44 fi
45done
46
47echo "${PYTHON_ROOT}/bin is not on your PATH or at least not early enough"
48case "${BSH}" in
49*csh)
50 # Create backup copy before patching
51 if [ -f "${HOME}/.cshrc" ]; then
52 cp -fp "${HOME}/.cshrc" "${HOME}/.cshrc.pysave"
53 fi
54 echo "" >> "${HOME}/.cshrc"
55 echo "# Setting PATH for MacPython ${PYVER}" >> "${HOME}/.cshrc"
56 echo "# The orginal version is saved in .cshrc.pysave" >> "${HOME}/.cshrc"
57 echo "set path=(${PYTHON_ROOT}/bin "'$path'")" >> "${HOME}/.cshrc"