Skip to content

Commit af0659f

Browse files
committed
Started on MacPython additions for Tiger.
1 parent ffe31d0 commit af0659f

File tree

5 files changed

+292
-0
lines changed

5 files changed

+292
-0
lines changed

Mac/OSX/Dist/build.tiger

+121
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/bin/sh -e
2+
#----------------------------------------------------------------------
3+
# Build the MacPython 2.3 extensions for an installation to run
4+
# on the pre-installed 2.3.5 framework build on OSX 10.4
5+
6+
# TODO: Parameterize the versions, builddirs, etc...
7+
8+
# Script configs
9+
PYVERSION=2.3.5
10+
PYVER=2.3
11+
BUILDNUM=1
12+
DOCLEANUP=no
13+
14+
PROGDIR="`dirname \"$0\"`"
15+
case x$PROGDIR in
16+
x|x.) PROGDIR=`pwd` ;;
17+
x/*) ;;
18+
*) echo "Please run with a full pathname"
19+
exit 1
20+
;;
21+
esac
22+
23+
if [ ! -e /usr/bin/python ]; then
24+
echo "No /usr/bin/python; this script expects to be run on 10.4 only"
25+
exit 1
26+
fi
27+
vers=`/usr/bin/python -V 2>&1`
28+
if [ "$vers" != "Python 2.3.5" ]; then
29+
echo "/usr/bin/python is not version 2.3.5; this script expects to be run on 10.3 only"
30+
exit 1
31+
fi
32+
33+
TMPDIR=/tmp/_py
34+
#TMPDIR=/projects/_py
35+
36+
INSTALLROOT=$TMPDIR/install
37+
DMGDIR=$TMPDIR/dmg
38+
RESOURCEDIR=$PROGDIR/resources.tiger
39+
DESTDIR=$TMPDIR/dist
40+
PYTHONSRC=$PROGDIR/../../..
41+
PYTHONOSXDIR=$PYTHONSRC/Mac/OSX
42+
WASTEDIR=$PYTHONSRC/../waste
43+
44+
rm -rf $DMGDIR
45+
if [ ! -e $TMPDIR ]; then
46+
mkdir $TMPDIR
47+
fi
48+
chgrp admin $TMPDIR
49+
mkdir -p $DMGDIR/root
50+
51+
52+
# Ask the user whether s/he has edited Welcome.txt
53+
read -p "Have you updated $RESOURCEDIR/Welcome.txt (Y/n)? " welcome
54+
55+
if [ "$welcome" = "n" -o "$welcome" = "N" ]; then
56+
echo "Please do so and retry"
57+
exit
58+
fi
59+
60+
# Make the installation directories
61+
mkdir -p $INSTALLROOT/Applications
62+
mkdir -p $INSTALLROOT/Library/Python/$PYVER
63+
64+
# Make a temporary site-packages symlink
65+
mkdir -p $INSTALLROOT/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/
66+
ln -s $INSTALLROOT/Library/Python/$PYVER $INSTALLROOT/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site-packages
67+
68+
pushd $PYTHONOSXDIR
69+
70+
make -f Makefile.tiger DIRMODE=775 EXEMODE=775 FILEMODE=664 DESTDIR=$INSTALLROOT
71+
72+
# Remove the temporary symlink
73+
rm -r $INSTALLROOT/System
74+
75+
# Unfortunately all the ...MODE arguments above still don't do the trick.
76+
# Cop out, and recursively set everything group-writeable.
77+
chmod -R ug+w $INSTALLROOT
78+
79+
popd
80+
81+
# Make the Installer package:
82+
83+
# Finally, build the package...
84+
rm -rf MacPython-Tiger.pkg
85+
python $PYTHONSRC/Mac/scripts/buildpkg.py \
86+
--Title=MacPython-Tiger \
87+
--Version=$PYVERSION-$BUILDNUM \
88+
--Description="MacPython $PYVERSION tools and additions for Mac OS X 10.4" \
89+
--NeedsAuthorization="YES" \
90+
--Relocatable="NO" \
91+
--InstallOnly="YES" \
92+
--UseUserMask="NO" \
93+
$INSTALLROOT \
94+
$RESOURCEDIR
95+
96+
# --RootVolumeOnly="YES" \
97+
98+
# ...and then make a disk image containing the package.
99+
mv MacPython-Tiger.pkg $DMGDIR/root
100+
cp $RESOURCEDIR/ReadMe.txt $DMGDIR/root/ReadMe.txt
101+
$PROGDIR/makedmg $DMGDIR/root $DMGDIR MacPython-Tiger-$PYVERSION-$BUILDNUM
102+
103+
echo Moving $DMGDIR/MacPython-Tiger-$PYVERSION-$BUILDNUM to $DESTDIR
104+
if [ ! -e $DESTDIR ]; then
105+
mkdir $DESTDIR
106+
fi
107+
mv $DMGDIR/MacPython-Tiger-$PYVERSION-$BUILDNUM.dmg $DESTDIR
108+
109+
110+
# Cleanup build/install dirs
111+
if [ $DOCLEANUP = yes ]; then
112+
echo "Cleaning up..."
113+
rm -rf $INSTALLROOT
114+
rm -rf $DMGDIR
115+
else
116+
echo "Cleanup is disabled. You should remove these dirs when done:"
117+
echo " $INSTALLROOT"
118+
echo " $DMGDIR"
119+
fi
120+
echo "Your installer can be found in $DESTDIR"
121+
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
This package will install the MacPython 2.3.5 additions
2+
for Mac OS X 10.4.
3+
4+
Installation requires approximately 3.3 MB of disk
5+
space, ignore the message that it will take zero bytes.
6+
7+
You must install onto your current boot disk, even
8+
though the installer does not enforce this, otherwise
9+
things will not work.
10+
11+
This installer does not contain a Python engine, as
12+
Apple already includes that in 10.4. It does contain
13+
a set of programs to allow easy access to it for Mac
14+
users (an integrated development environment, a Python
15+
extension package manager) and the waste module.
16+
17+
The installer puts the applications in MacPython-2.3 in
18+
your Applications folder.
19+
20+
The PythonIDE application has a Help command that gets
21+
you started quickly with MacPython and contains
22+
references to other documentation.
23+
24+
More information on MacPython can be found at
25+
http://www.cwi.nl/~jack/macpython, more
26+
information on Python in general at
27+
http://www.python.org.
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{\rtf1\mac\ansicpg10000\cocoartf822
2+
{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fswiss\fcharset77 Helvetica-Bold;}
3+
{\colortbl;\red255\green255\blue255;}
4+
\paperw11900\paperh16840\margl1440\margr1440\vieww9920\viewh10660\viewkind0
5+
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\ql\qnatural
6+
7+
\f0\fs24 \cf0 This package will install the third build of the
8+
\f1\b MacPython 2.3.5
9+
\f0\b0 additions for
10+
\f1\b Mac OS X 10.4
11+
\f0\b0 . \
12+
\
13+
MacPython consists of the programs to allow easy access to Python for Mac users (an integrated development environment, a Python extension package manager), and uses the Python 2.3.5 interpreter core that comes pre-installed on 10.4.\
14+
\
15+
See the ReadMe file for more information.}

Mac/OSX/Makefile.tiger

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# This Makefile is to be used *only* on Tiger.
2+
# It installs the things that are available in MacPython but that are
3+
# ommitted from Apple's installation of Python 2.3.5.
4+
#
5+
all: install_waste install_IDE install_PackageManager \
6+
install_BuildApplet installextras install_PythonLauncher
7+
8+
srcdir=../..
9+
VERSION=2.3
10+
DESTDIR=
11+
PYTHONAPPSDIR=/Applications/MacPython-$(VERSION)
12+
13+
APPLE_prefix=/System/Library/Frameworks/Python.framework/Versions/$(VERSION)
14+
BUILDPYTHON=/usr/bin/python$(VERSION)
15+
APPLE_LIBDEST=$(APPLE_prefix)/lib/python$(VERSION)
16+
INSTALLED_PYTHONW=$(APPLE_prefix)/Resources/Python.app/Contents/MacOS/Python
17+
APPLE_PYTHONLAUNCHER=$(APPLE_prefix)/Resources/PythonLauncher.app
18+
bundlebuilder=$(srcdir)/Lib/plat-mac/bundlebuilder.py
19+
20+
install_waste:
21+
$(BUILDPYTHON) setup.panther.py install \
22+
--prefix=$(APPLE_prefix) --root=/$(DESTDIR)
23+
24+
install_IDE:
25+
$(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \
26+
--python $(INSTALLED_PYTHONW) \
27+
--output $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app --noargv \
28+
$(srcdir)/Mac/Tools/IDE/PythonIDE.py
29+
# # Add the extra files to the resources. This is to work around bugs in
30+
# # them in the original 2.3.
31+
# cp ../Tools/IDE/PythonIDEMain.py $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app/Contents/Resources
32+
# cp ../Tools/IDE/Wapplication.py $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app/Contents/Resources
33+
# cp ../Tools/IDE/Wcontrols.py $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app/Contents/Resources
34+
# cp ../Tools/IDE/PyEdit.py $(DESTDIR)$(PYTHONAPPSDIR)/PythonIDE.app/Contents/Resources
35+
36+
install_PackageManager:
37+
$(BUILDPYTHON) $(bundlebuilder) \
38+
--builddir $(DESTDIR)$(PYTHONAPPSDIR)/ \
39+
--python $(INSTALLED_PYTHONW) \
40+
--resource $(srcdir)/Mac/Tools/IDE/PythonIDE.rsrc \
41+
--mainprogram $(srcdir)/Mac/Tools/IDE/PackageManager.py \
42+
--iconfile $(srcdir)/Mac/Tools/IDE/PackageManager.icns \
43+
--plist $(srcdir)/Mac/Tools/IDE/PackageManager.plist \
44+
--creator Pimp build
45+
46+
install_BuildApplet:
47+
$(BUILDPYTHON) $(srcdir)/Mac/scripts/BuildApplet.py \
48+
--python $(INSTALLED_PYTHONW) \
49+
--output $(DESTDIR)$(PYTHONAPPSDIR)/BuildApplet.app \
50+
$(srcdir)/Mac/scripts/BuildApplet.py
51+
52+
installextras:
53+
$(MAKE) -f Makefile installextras \
54+
BUILDPYTHON=$(BUILDPYTHON) INSTALLED_PYTHONW=$(INSTALLED_PYTHONW) \
55+
DESTDIR=$(DESTDIR) PYTHONAPPSDIR=$(PYTHONAPPSDIR)
56+
57+
install_PythonLauncher:
58+
ln -fsn $(APPLE_PYTHONLAUNCHER) $(DESTDIR)$(PYTHONAPPSDIR)/PythonLauncher
59+
60+
install_pimpupdate:
61+
cp ../../Lib/plat-mac/pimp.py $(DESTDIR)/Library/Python/2.3/pimp_update.py
62+

Mac/OSX/setup.tiger.py

+67
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
from distutils.core import Extension, setup
2+
from distutils import sysconfig
3+
import os
4+
5+
SRCDIR=os.path.realpath(os.path.join(os.getcwd(), "../.."))
6+
7+
def find_file(filename, std_dirs, paths):
8+
"""Searches for the directory where a given file is located,
9+
and returns a possibly-empty list of additional directories, or None
10+
if the file couldn't be found at all.
11+
12+
'filename' is the name of a file, such as readline.h or libcrypto.a.
13+
'std_dirs' is the list of standard system directories; if the
14+
file is found in one of them, no additional directives are needed.
15+
'paths' is a list of additional locations to check; if the file is
16+
found in one of them, the resulting list will contain the directory.
17+
"""
18+
19+
# Check the standard locations
20+
for dir in std_dirs:
21+
f = os.path.join(dir, filename)
22+
if os.path.exists(f): return []
23+
24+
# Check the additional directories
25+
for dir in paths:
26+
f = os.path.join(dir, filename)
27+
if os.path.exists(f):
28+
return [dir]
29+
30+
# Not found anywhere
31+
return None
32+
33+
def find_library_file(compiler, libname, std_dirs, paths):
34+
filename = compiler.library_filename(libname, lib_type='shared')
35+
result = find_file(filename, std_dirs, paths)
36+
if result is not None: return result
37+
38+
filename = compiler.library_filename(libname, lib_type='static')
39+
result = find_file(filename, std_dirs, paths)
40+
return result
41+
42+
def waste_Extension():
43+
waste_incs = find_file("WASTE.h", [],
44+
['../'*n + 'waste/C_C++ Headers' for n in (0,1,2,3,4)])
45+
if waste_incs != None:
46+
waste_libs = [os.path.join(os.path.split(waste_incs[0])[0], "Static Libraries")]
47+
srcdir = SRCDIR
48+
return [ Extension('waste',
49+
[os.path.join(srcdir, d) for d in
50+
'Mac/Modules/waste/wastemodule.c',
51+
'Mac/Wastemods/WEObjectHandlers.c',
52+
'Mac/Wastemods/WETabHooks.c',
53+
'Mac/Wastemods/WETabs.c'
54+
],
55+
include_dirs = waste_incs + [
56+
os.path.join(srcdir, 'Mac/Include'),
57+
os.path.join(srcdir, 'Mac/Wastemods')
58+
],
59+
library_dirs = waste_libs,
60+
libraries = ['WASTE'],
61+
extra_link_args = ['-framework', 'Carbon'],
62+
) ]
63+
return []
64+
65+
setup(name="MacPython for Tiger extensions", version="2.3",
66+
ext_modules=waste_Extension()
67+
)

0 commit comments

Comments
 (0)