Maintain backwards compatibility with python < 2.3 by dynamically
[python/dscho.git] / Mac / OSX / Dist / resources / postflight
blobe5c7f9de22b0dc1fb7ad75bf1794bab69d0b54a1
1 #!/bin/sh
2 #----------------------------------------------------------------------
3 # Create the unix tools and compile the .py files after Python has been
4 # installed.
5 #----------------------------------------------------------------------
7 PYVER=2.3
9 PKG=$1
10 DEST=$2
12 # Make sure things are group-writeable
13 umask 2
15 # if destination is / then use usr/local/bin, otherwise just bin
16 if [ "$DEST" = "/" ]; then
17 TOOLDIR=/usr/local/bin
18 DEST=
19 else
20 TOOLDIR=$DEST/bin
23 # Make sure the dir exists
24 mkdir -p $TOOLDIR
26 # Make some links to the python executable
27 ln -fsh $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/bin/python $TOOLDIR/python$PYVER
28 ln -fsh python$PYVER $TOOLDIR/python
31 # make the pythonw script
32 rm -f $TOOLDIR/pythonw$PYVER
33 cat > $TOOLDIR/pythonw$PYVER <<EOF
34 #!/bin/sh
35 exec "$DEST/Library/Frameworks/Python.framework/Versions/$PYVER/Resources/Python.app/Contents/MacOS/Python" "\$@"
36 EOF
37 chmod +x $TOOLDIR/pythonw$PYVER
38 ln -fsh pythonw$PYVER $TOOLDIR/pythonw
41 # Compile the .py files in the Python library to .pyc's and then .pyo's
42 $TOOLDIR/python -Wi -tt \
43 $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER/compileall.py \
44 -x badsyntax -x site-packages $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER
46 $TOOLDIR/python -Wi -tt -O \
47 $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER/compileall.py \
48 -x badsyntax -x site-packages $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER
50 $TOOLDIR/python -Wi -tt \
51 $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER/compileall.py \
52 $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/Mac/Tools
54 $TOOLDIR/python -Wi -tt -O \
55 $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER/compileall.py \
56 $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/Mac/Tools
59 # Make the site-packages and other dirs writable by the admin if destination is /
61 if [ "$DEST" = "/" ]; then
62 for d in $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/lib/python$PYVER/site-packages \
63 $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/bin \
64 $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/Resources/Python.app/Contents/Resources \
65 $DEST/Applications/MacPython-$PYVER; do
66 chgrp -R admin $d
67 chmod -R g+w $d
68 done
71 if [ "$DEST" != "/" ]; then
72 # The link in the app bundles and in pydoc need updating.
73 installed_python=$DEST/Library/Frameworks/Python.framework/Versions/$PYVER/Resources/Python.app/Contents/MacOS/python
74 for app in BuildApplet IDLE PackageManager PythonIDE; do
75 ln -fsh $installed_python \
76 $DEST/Applications/MacPython-$PYVER/$app.app/Contents/MacOS
77 ed -s $DEST/Applications/MacPython-$PYVER/$app.app/Contents/MacOS/$app << xyzzy
79 #!$installed_python
83 xyzzy
84 ed -s $DEST/Library/Frameworks/Python.framework/Versions/$PYVER/bin/pydoc << xyzzy
86 #!$installed_python
90 xyzzy
91 done