blob: 556eddd79546b14364b85ea3c22e7ae00dfea82d [file] [log] [blame]
Jack Jansen8f2d8021996-08-05 15:34:45 +00001<HTML>
2<HEAD>
3<TITLE>Building Mac Python from source</TITLE>
4</HEAD>
5<BODY>
6<H1>Building Mac Python from source</H1>
7<HR>
Jack Jansen8f2d8021996-08-05 15:34:45 +00008
Jack Jansenc1218bc2001-04-25 22:11:24 +00009<B>Note</B>: This document is mostly still for Python 2.0, so
10it is not correct. See the <a href="http://www.cwi.nl/~jack/macpython.html">
11MacPython homepage</a> for an updated version, and if none is available
12complain bitterly to me and work on it should progress faster.
Jack Jansen0eb5f2d2001-02-17 22:04:13 +000013<p>
14
Jack Jansen4c1e56c1996-08-06 16:16:20 +000015This document explains how to build MacPython from source. This is
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000016necessary if you want to make modifications to the Python core. Building
17Python is not something to be undertaken lightly, you need a reasonable
18working knowledge of the CodeWarrior development environment, a good net
Jack Jansen4c1e56c1996-08-06 16:16:20 +000019connection and probably quite some time too. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +000020
Jack Jansen4c1e56c1996-08-06 16:16:20 +000021The information density in this file is high, so you should probably
22print it and read it at your leasure. Most things are explained only
23once (and probably in the wrong place:-). <p>
24
Jack Jansen90cf4912000-02-11 23:14:46 +000025<blockquote>
26First a warning: this information may become outdated if a new CodeWarrior is
27released after MacPython. The
28<a href="http://www.cwi.nl/~jack/macpython.html">MacPython homepage</a> will
29hopefully have updated instructions in that case.
30</blockquote>
31
Jack Jansenc256ece1999-02-03 13:09:27 +000032I am very interested in feedback on this document, send your
Jack Jansen4c1e56c1996-08-06 16:16:20 +000033comments to the <A
34HREF="http://www.python.org/sigs/pythonmac-sig/">Mac Python Special
35Interest Group</A>.
Jack Jansen8f2d8021996-08-05 15:34:45 +000036
37<H2>What you need.</H2>
38
39The following things you definitely need:
40
41<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000042
Jack Jansen4c1e56c1996-08-06 16:16:20 +000043<LI> You need a MacPython source distribution, of course. You can
Jack Jansen95375861999-03-10 15:51:56 +000044obtain one from <A HREF="ftp://ftp.cwi.nl/pub/jack/python/mac">
45ftp://ftp.cwi.nl/pub/jack/python/mac</A> or from the companion webpage
46at <A HREF="http://www.cwi.nl/~jack/macpython.html">
47http://www.cwi.nl/~jack/macpython.html</A> (which has up-to-date links
48to the other packages needed too) and possibly also from the standard
49<A HREF="ftp://ftp.python.org/pub/python/mac">python.org ftp
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000050site</A>. <BR>
Jack Jansenc256ece1999-02-03 13:09:27 +000051
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000052A better alternative is to check the sources straight out of the CVS
Jack Jansen95375861999-03-10 15:51:56 +000053repository, see below. Most of the packages mentioned here are also
54available through CVS. Check the section on <a href="#cvs">CVS
55repository use</a> below.
Jack Jansen8f2d8021996-08-05 15:34:45 +000056
Jack Jansen4c1e56c1996-08-06 16:16:20 +000057<LI> You need MetroWerks CodeWarrior. The current distribution has
Jack Jansenc1218bc2001-04-25 22:11:24 +000058been built with CodeWarrior Pro 6.1. Ordering information is
Jack Jansen4c1e56c1996-08-06 16:16:20 +000059available on the <A HREF="http://www.metrowerks.com/">MetroWerks
Jack Jansena2139fe1998-02-25 15:40:35 +000060homepage</A>. Building Python with MPW or Think/Symantec C is
61probably impossible without major surgery.
Jack Jansen4c1e56c1996-08-06 16:16:20 +000062
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000063<LI> You need GUSI version 2, the Grand Unified Socket Interface, by
64Matthias Neeracher. The original GUSI is obtainable from <A
Jack Jansen5f884c02000-12-12 22:14:14 +000065HREF="ftp://gusi.sourceforge.net/pub/gusi/">
66ftp://gusi.sourceforge.net/pub/gusi/</A>. At
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000067the moment Python is built with a slightly modified version of GUSI
682.1.1, so it may be better to check the <A
69HREF="http://www.cwi.nl/~jack/macpython.html">MacPython homepage</A>
70for a GUSI that is most easily used for building Python.
71<br>
Jack Jansena598bc41999-02-10 23:08:24 +000072
Jack Jansenc1218bc2001-04-25 22:11:24 +000073If nothing is listed there (yet) you will have problems building a
74Carbon Python. Complaining loudly on the pythonmac-sig@python.org mailing
75list will make me work faster towards distributing Carbon-GUSI:-).
Jack Jansen8f2d8021996-08-05 15:34:45 +000076</UL>
77
Jack Jansen4c1e56c1996-08-06 16:16:20 +000078<A NAME="optional">The MacPython project files are configured to
79include a plethora of optional modules</A>, and these modules need a
Jack Jansena2139fe1998-02-25 15:40:35 +000080number of extra packages. To use the project files as-is you have to
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000081download these packages too. Python has all such modules as
Jack Jansen4c1e56c1996-08-06 16:16:20 +000082dynamically loaded modules, so if you don't need a certain package it
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000083suffices to just refrain from builing the extension module.
84Here are the locations for the various things
Jack Jansen4c1e56c1996-08-06 16:16:20 +000085you need:
Jack Jansen8f2d8021996-08-05 15:34:45 +000086
87<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000088
Jack Jansen8b41d532000-05-07 22:08:42 +000089<LI> Tcl and Tk are in a sad state on the Mac, the standard source distributions
90simply don't compile, so I have created a distribution especially for use
91with MacPython.
92See the section on <A HREF="#tcltk">building Tcl/Tk Python</A>
93below.
Jack Jansen8f2d8021996-08-05 15:34:45 +000094
Jack Jansen4c1e56c1996-08-06 16:16:20 +000095<LI> Waste, a TextEdit replacement written by Marco Piovanelli, <A
96HREF="mailto:piovanel@kagi.com">&lt;piovanel@kagi.com&gt;</A>. Python
Jack Jansenc1218bc2001-04-25 22:11:24 +000097was built using version 2.0, which is included in the CodeWarrior
98package. You can also obtain it from <A
Jack Jansena2139fe1998-02-25 15:40:35 +000099HREF="http://www.boingo.com/waste">&lt;http://www.boingo.com/waste&gt;</A>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000100and various other places.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000101
Jack Jansen1473af71997-05-07 15:43:38 +0000102<LI> Gdbm library for the Mac. Available from Jack's Mac software page at
103<A HREF="http://www.cwi.nl/~jack/macsoftware.html">
104http://www.cwi.nl/~jack/macsoftware.html</A> and <A HREF="ftp://ftp.cwi.nl/pub/jack/mac">
Jack Jansena598bc41999-02-10 23:08:24 +0000105ftp://ftp.cwi.nl/pub/jack/mac</A>. Also in the MacPython cvs repository at
106<code>lib-src/gdbm</code>.
Jack Jansen1473af71997-05-07 15:43:38 +0000107
108<LI> JPEG library by the Independent JPEG Group. A version including
109Mac projects can be found at Jack's page mentioned above.
110The most recent JPEG library can always be obtained from <A
Jack Jansena598bc41999-02-10 23:08:24 +0000111HREF="ftp://ftp.uu.net/graphics/jpeg/">ftp://ftp.uu.net/graphics/jpeg/</A>. Again,
112also in the MacPython cvs repository at <code>lib-src/jpeg</code>.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000113
Jack Jansen1473af71997-05-07 15:43:38 +0000114<LI> The netpbm/pbmplus, libtiff, zlib and png libraries. The netpbm distribution
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000115(which includes libtiff) is generally available on Internet ftp
116servers. For Python pbmplus, an older incarnation of netpbm, is
117functionally identical to netpbm, since Python only uses the library
118and not the complete applications. A distribution with correct
Jack Jansen1473af71997-05-07 15:43:38 +0000119projects and library source only is available from, you guessed it, Jack's Mac software
Jack Jansena598bc41999-02-10 23:08:24 +0000120page mentioned above. And, guessed it again, in the MacPython cvs repository
121at <code>lib-src/netpbm</code>, etc. The only gotcha is that libtiff lives in
122<code>lib-src/netpbm/libtiff</code>, for historical reasons.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000123
Jack Jansen8f2d8021996-08-05 15:34:45 +0000124</UL>
125
126<H2>Setting Up</H2>
127
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000128Now that you have collected everything you should start with building
Jack Jansen1473af71997-05-07 15:43:38 +0000129the various parts. If you don't want to fix
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000130access paths try to set things up as follows:
131
Jack Jansen8f2d8021996-08-05 15:34:45 +0000132<PRE>
133Top-level-folder:
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000134 GUSI2
Jack Jansenc1218bc2001-04-25 22:11:24 +0000135 GUSI2Carbon
Jack Jansen8f2d8021996-08-05 15:34:45 +0000136 imglibs
Jack Jansende570301998-08-27 13:39:01 +0000137 jpeg
138 netpbm
139 libtiff
Jack Jansen1473af71997-05-07 15:43:38 +0000140 zlib
Jack Jansende570301998-08-27 13:39:01 +0000141 png
Jack Jansen1473af71997-05-07 15:43:38 +0000142 gdbm
Jack Jansen8f2d8021996-08-05 15:34:45 +0000143 Python
Jack Jansen90cf4912000-02-11 23:14:46 +0000144 Modules
145 ...
146 Mac
147 Modules
148 Build
149 ...
Jack Jansen32617191997-08-19 14:01:16 +0000150 Tcl/Tk Folder
151 tcl8.0
152 tk8.0
Jack Jansena2139fe1998-02-25 15:40:35 +0000153 MoreFiles 1.4.3
Jack Jansen8f2d8021996-08-05 15:34:45 +0000154</PRE>
155
Jack Jansende570301998-08-27 13:39:01 +0000156If your setup of the libraries is exactly the same as mine (which is
157not very likely, unless you happen to work from the same CVS
158repository) you can use the project <code>buildlibs.prj</code> in the
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000159<code>:Mac:Build</code> folder to build all needed libraries in one
Jack Jansende570301998-08-27 13:39:01 +0000160fell swoop, otherwise you will have to build the libraries one by
161one. <p>
162
Jack Jansenc1218bc2001-04-25 22:11:24 +0000163First build GUSI, both the norla one and the Carbon variant.
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000164 <p>
Jack Jansen95375861999-03-10 15:51:56 +0000165
Jack Jansen16e99c01996-09-07 17:11:26 +0000166Next, in
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000167<code>libjpeg</code>, <code>pbmplus</code>,
Jack Jansen1473af71997-05-07 15:43:38 +0000168<code>zlib</code>, <code>libpng</code>, <code>gdbm</code>,
Jack Jansena2139fe1998-02-25 15:40:35 +0000169and<code>libtiff</code> you build all projects. Usually the projects are in "mac"
Jack Jansen1473af71997-05-07 15:43:38 +0000170subfolders, sometimes they are in the main folder. Tcl/tk is a special
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000171case, see below.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000172
173<H2><A NAME="tcltk">Building Tcl/Tk</H2>
174
Jack Jansen8b41d532000-05-07 22:08:42 +0000175The Tcl/Tk 8.3.0 source distribution does not work on the Mac. I have created
176an archive of the sources that I used to build _tkinter for MacPython,
177you can obtain this from <a
178href="ftp://ftp.cwi.nl/pub/jack/python/mac/tcltk830src-for-python.sit">
179ftp://ftp.cwi.nl/pub/jack/python/mac/tcltk830src-for-python.sit</a>. Only the
180libraries needed to build _tkinter for PPC have been fixed. <P>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000181
Jack Jansen8b41d532000-05-07 22:08:42 +0000182Note that if you use a different release of Tcl and Tk than the ones
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000183I have used you may have to adapt the Python <code>tkresources.rsrc</code> file.
184This is easiest done by building <code>SimpleTk</code> and copying the TEXT, ICON
185and CRSR resources from it to <code>tkresources.rsrc</code>. This allows
186the <code>_tkinter</code> module to work without an installed Tk/Tcl on your
Jack Jansen8b41d532000-05-07 22:08:42 +0000187machine. <P>
188
189Also note that the <code>_tkinter.ppc.slb</code> that is normally distributed
190in the <code>PlugIns</code> folder is the one from the Imaging extension,
191which has some extra features needed by PIL (and which features should not
192hinder normal operation).
Jack Jansen27b10ec1996-08-23 15:44:18 +0000193
Jack Jansen8f2d8021996-08-05 15:34:45 +0000194</UL>
195
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000196Build first the Tcl library, then
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000197SimpleTcl (test it by typing <code>ls -l</code> in the window you get)
198then the Tk library, then SimpleTk (which can again be tested with
199<code>ls -l</code>). If this all worked you are all set to try
Jack Jansen8f2d8021996-08-05 15:34:45 +0000200building Python.
201
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000202<H2>Building Waste</H2>
203
204You do not need to build the Waste libraries, as Python includes the
Jack Jansena2139fe1998-02-25 15:40:35 +0000205source modules themselves.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000206
Jack Jansen8f2d8021996-08-05 15:34:45 +0000207<H2>The organization of the Python source tree</H2>
208
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000209Time for a short break, while we have a look at the organization of
210the Python source tree. At the top level, we find the following
211folders:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000212
213<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000214<DT> Demo
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000215<DD> Demo programs that are not Mac-specific. Some of these may not
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000216work.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000217
218<DT> Extensions
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000219<DD> Extensions to the interpreter that are not Mac-specific. Contains
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000220the <code>img</code>, <code>Imaging</code> and <code>Numerical</code> extensions
221in this distribution.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000222
223<DT> Grammar
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000224<DD> The Python grammar. Included for reference only, you cannot build
225the parser on a Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000226
227<DT> Include
228<DD> Machine-independent header files.
229
230<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000231<DD> Machine-independent optional modules. Not all of these will work
232on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000233
234<DT> Objects
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000235<DD> Machine-independent code for various object types. Most of these are
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000236not really optional: the interpreter will not function without them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000237
238<DT> Parser
239<DD> The Python parser (machine-independent).
240
Jack Jansen8f2d8021996-08-05 15:34:45 +0000241<DT> Python
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000242<DD> The core interpreter. Most files are machine-independent, some
243are unix-specific and not used on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000244
245<DT> Tools
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000246<DD> Tools for python developers. Contains <code>modulator</code> which
247builds skeleton C extension modules, <code>bgen</code> which generates
248complete interface modules from information in C header files and
249<code>freeze</code> which is used to turn Python scripts into real
250applications (used by MacFreeze and BuildApplication) There are some
251readme files, but more documentation is sorely needed.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000252
Jack Jansen8f2d8021996-08-05 15:34:45 +0000253</DL>
254
255All the mac-specific stuff lives in the <code>Mac</code> folder:
256<DL>
Jack Jansenc256ece1999-02-03 13:09:27 +0000257<DT> Build
258<DD> This is where the project files live and where you build the
259libraries, shared libraries, executables and plugin modules. All the
260resulting binaries, except for intermedeate results, are deposited in
Jack Jansena598bc41999-02-10 23:08:24 +0000261the toplevel folder or the Mac:PlugIns folder (for plugin modules).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000262
263<DT> Compat
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000264<DD> Unix-compatability routines. Most of these are not used anymore,
265since GUSI provides a rather complete emulation, but you may need
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000266these if you are trying to build a non-GUSI python.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000267
268<DT> Demo
269<DD> Mac-specific demo programs, some of them annotated.
270
271<DT> Include
272<DD> Mac-specific but compiler-independent include files.
273
274<DT> Lib
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000275<DD> Mac-specific standard modules. The <code>toolbox</code> folder
276contains modules specifically needed with various MacOS toolbox
277interface modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000278
279<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000280<DD> Mac-specific builtin modules. Theoretically these are all
281optional, but some are rather essential (like
282<code>macmodule</code>). A lot of these modules are generated with
283<code>bgen</code>, in which case the bgen input files are included so
284you can attempt to regenerate them or extend them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000285
286<DT> MPW
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000287<DD> MPW-specific files. These have not been used or kept up-to-date
288for a long time, so use at your own risk.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000289
290<DT> mwerks
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000291<DD> Mwerks-specific sources and headers. Contains glue code for
292Pythons shared-library architecture, a replacement for
293<code>malloc</code> and a directory with various projects for building
294variations on the Python interpreter. The <code>mwerks_*.h</code>
295files here are the option-setting files for the various interpreters
296and such, comparable to the unix command-line <code>-D</code> options
297to the compiler. Each project uses the correct option file as its
298"prefix file" in the "C/C++ language" settings. Disabling optional
299modules (for the 68K interpreter), building non-GUSI interpreters and
300various other things are accomplished by modifying these files (and
301possibly changing the list of files included in the project window, of
302course).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000303
Jack Jansenc256ece1999-02-03 13:09:27 +0000304<DT> PlugIns
Jack Jansenc1218bc2001-04-25 22:11:24 +0000305<DD> This is where the Classic and Carbon dynamically-loaded plugin modules live.
Jack Jansenc256ece1999-02-03 13:09:27 +0000306
Jack Jansen8f2d8021996-08-05 15:34:45 +0000307<DT> Python
308<DD> Mac-specific parts of the core interpreter.
309
310<DT> Resources
311<DD> Resource files needed to build the interpreter.
312
313<DT> Scripts
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000314<DD> A collection of various mac-specific Python scripts. Some are
315essential, some are useful but few are documented, so you will have to
316use your imagination to work them out.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000317
Jack Jansenc256ece1999-02-03 13:09:27 +0000318<DT> Tools
319<DD> A collection of tools, usually bigger than those in the scripts
320folder. The important ones here are the IDE and macfreeze. The IDE is built
321with the buildIDE.py script, which puts the resulting applet in the toplevel
322folder. Macfreeze is usually invoked through the BuildApplication script,
323but for more control over the freezing process you can run the main script here.
324
325
Jack Jansen8f2d8021996-08-05 15:34:45 +0000326<DT> Unsupported
327<DD> Modules that are not supported any longer but may still work with a little effort.
328</DL>
329
330<H2>Building the 68K interpreter</H2>
331
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000033268K Python is no longer supported, and the projects are not included in the
Jack Jansenc1218bc2001-04-25 22:11:24 +0000333source distribution anymore. If you really want to build Python for the 68K
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000334your best bet is to check the sources out of the CVS repository. The latest
335projects (in :Mac:build:) that support 68K development are tagged as such,
336and are dated around August 2000. If you plan on doing this announce it on
337the SIG, please. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000338
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000339<H2>Building the PPC interpreter</H2>
Jack Jansenc1218bc2001-04-25 22:11:24 +0000340<em>This is different under 2.1. You are best off using the fullbuild.py
341script. </em><p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000342First you optionally build the external libraries with buildlibs.prj. Next,
343the projects for
344interpreter, core library and applet skeleton are all linked together, so
Jack Jansenc1218bc2001-04-25 22:11:24 +0000345building the PythonInterpreter target in <code>PythonEngine.prj</code>
Jack Jansen3b805261999-02-14 23:12:06 +0000346will result in everything being built. The
Jack Jansen3412c5d1997-08-27 14:08:22 +0000347resulting applications and fat shared library are deposited in the main
Jack Jansenc256ece1999-02-03 13:09:27 +0000348Python folder. Finally, you build all the plugins with the plugins.prj project.
349
350For completeness sake here is a breakdown of the projects:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000351
352<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000353
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000354<DT> PythonCore (with subproject PythonCorePPC)
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000355<DD> The shared library that contains the bulk of the interpreter and
356its resources. It is a good idea to immedeately put an alias to this
357shared library in the <code>Extensions</code> folder of your system
358folder. Do exactly that: put an <em>alias</em> there, copying or
Jack Jansen3412c5d1997-08-27 14:08:22 +0000359moving the file will cause you grief later if you rebuild the library and
Jack Jansenc256ece1999-02-03 13:09:27 +0000360forget to copy it to the extensions folder again. The InstallPython applet
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000361will also do this, along with creating the plugin aliases. <br>
362Note that the subproject looks a bit silly nowadays (with no more CFM68K
363support) but you will have to live with that for this release.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000364
Jack Jansen3b805261999-02-14 23:12:06 +0000365<DT> PythonInterpeter
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000366<DD> The interpreter. This is basically a routine to call out to the
Jack Jansen3b805261999-02-14 23:12:06 +0000367shared library. Unlike in previous releases the same program is used for
368creating applets (for which formerly PythonApplet was used). <p>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000369
Jack Jansenc256ece1999-02-03 13:09:27 +0000370<DT> Plugin projects
Jack Jansena598bc41999-02-10 23:08:24 +0000371<DD> Each plugin module has a separate project. The <code>Plugins.prj</code>
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000372project tries to build them all, but is known to be flakey. See <code>fullbuild</code>
373below for a better way to build everything.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000374</DL>
375
Jack Jansen3412c5d1997-08-27 14:08:22 +0000376After creating the alias to <code>PythonCore</code> you remove any old
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000377<code>Python 2.0b1 Preferences</code> file from the <code>Preferences</code> folder
Jack Jansen061ac501996-10-22 15:27:56 +0000378(if you had python installed on your system before) and run the interpreter once
Jack Jansen3412c5d1997-08-27 14:08:22 +0000379to create the correct preferences file. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000380
Jack Jansenc256ece1999-02-03 13:09:27 +0000381Next, you have to build the extension modules.
382The <code>PlugIns.ppc</code> project has all the
Jack Jansena598bc41999-02-10 23:08:24 +0000383other projects as subprojects and builds everything (but see the gotcha above).
384<p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000385
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000386Finally, you must build the standard applets:
Jack Jansen3412c5d1997-08-27 14:08:22 +0000387<code>EditPythonPrefs</code>, <code>BuildApplet</code>, etc. This is
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000388easiest done with the <code>fullbuild</code> script from
Jack Jansen3412c5d1997-08-27 14:08:22 +0000389<code>Mac:scripts</code>. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000390
391<BLOCKQUOTE>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000392Actually, the <code>fullbuild</code> script can be used to build
393everything, but you need a fully-functional interpreter before you can
394use it (and one that isn't rebuilt in the process: you cannot rebuild
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000395a running program). You could copy the interpreter to a different
396place and use that to run fullbuild. The <code>PythonStandSmall.prj</code>
397project builds an interpreter that is suited to this, and it can also come
398in handy if you need to debug things (which is easier in a static program). <p>
Jack Jansene66b8c81997-05-29 14:57:07 +0000399
Jack Jansen8f2d8021996-08-05 15:34:45 +0000400</BLOCKQUOTE>
401
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000402You are all set now, and should read the release notes and
Jack Jansen3412c5d1997-08-27 14:08:22 +0000403<code>ReadMe</code> file from the <code>Mac</code> folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000404
Jack Jansenc1218bc2001-04-25 22:11:24 +0000405<H2>Rebuilding <code>.exp</code> files</H2>
Jack Jansen27b10ec1996-08-23 15:44:18 +0000406
407Occasionally it may be necessary to rebuild your PythonCore <code>.exp</code>
408file, a file that controls which symbols are exported by your PythonCore
409shared library. Rebuild it if you get unexpected undefined symbols when you
410are building a plugin module. <p>
411
412Rebuilding the .exp file is done by first removing the file and removing the
413reference to it in the project (in the "config" section). Next, build PythonCore.
414This will create a new .exp file. Edit this file to remove the references to
415the symbols <code>__initialize</code>, <code>__terminate</code>, <code>setjmp</code>,
Jack Jansen2afc2c71999-09-30 19:48:49 +0000416<code>longjmp</code>, <code>vec_longjmp</code>, <code>main</code> and (for PPC) <code>__ptmf_null</code> or (for
Jack Jansen1473af71997-05-07 15:43:38 +0000417CFM68K) <code>__start</code> and <code>dummy_init_routine</code>.
418Next, add the .exp file to the project
Jack Jansen27b10ec1996-08-23 15:44:18 +0000419again and rebuild PythonCore. <p>
420
421This rather convoluted procedure is needed to ensure that plugin modules don't
422accidentally link with those entrypoints from PythonCore, which will not work because
423those routines have to be in the same code fragment as they are used from.
424
Jack Jansen95375861999-03-10 15:51:56 +0000425<H2><a name="cvs">Using the CVS source archive</a></H2>
Jack Jansenc256ece1999-02-03 13:09:27 +0000426
Jack Jansenc1218bc2001-04-25 22:11:24 +0000427<em>Please check the MacPython homepage to see whether this information is
428still current: MacPython should move to sourceforge shortly. </em><p>
429
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000430It is possible (and probably best) to access the Python sources through remote CVS. The
Jack Jansen65f685b1999-04-12 09:25:23 +0000431advantage of this is that you get the very latest sources, so any bug
432fixed or new features will be immedeately available. This is also the
433disadvantage, of course: as this is the same tree as is used for
434development it may sometimes be a little less stable. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000435
436The CVS client of choice is Alexandre Parenteau's MacCVS. It can be
Jack Jansen65f685b1999-04-12 09:25:23 +0000437obtained through the <a href="http://www.wincvs.org">WinCVS
438homepage</a>. MacCVS uses Internet Config to set file types correctly
439based on the filename extension. In the maccvs preferences you should
440also set (in the "binary files" section) "use mac encoding:
441applesingle" and (in the "text files" section) "use ISO latin 1
Jack Jansenc256ece1999-02-03 13:09:27 +0000442conversion". <p>
443
Jack Jansen8b41d532000-05-07 22:08:42 +0000444It is also a good idea to disable Quicktime Exchange in the Quicktime
445control panel. Quicktime Exchange will magically map some extensions to
446filetypes, and this can seriously hinder you if, for instance, <code>.bmp</code>
447is not a Windows bitmap file. <p>
448
Jack Jansen95375861999-03-10 15:51:56 +0000449The machine-independent Python sources are checked out from the main
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000450Python CVS archive on sourceforge.net, see the <a
Jack Jansen65f685b1999-04-12 09:25:23 +0000451href="http://www.python.org/download/cvs.html">Source access via
452CVS</a> page for details. When you check the sources out you will get
Jack Jansen95375861999-03-10 15:51:56 +0000453something like <code>Python:dist:src</code>, and under that the
454<code>Modules</code>, <code>Lib</code>, etc hierarchy. The
455<code>src</code> folder should be renamed to <code>Python</code>, and
456is what this document refers to as the "toplevel Python folder". <P>
Jack Jansenc256ece1999-02-03 13:09:27 +0000457
Jack Jansen90cf4912000-02-11 23:14:46 +0000458Next, <em>in a separate folder</em>, you check out the
459mac-specific sources. You then move the <code>Mac</code> folder from this
460checkout (the only folder with anything in it) to the Python source folder.
461Note that the checking out in a separate folder and moving is necessary,
462due to the way cvs works.
463
464The CVS path to use for the mac stuff can be found
Jack Jansen95375861999-03-10 15:51:56 +0000465at the <a href="http://www.cwi.nl/~jack/macpython.html">MacPython
466homepage</a>. Finally, you check out the external libraries needed in
Jack Jansen90cf4912000-02-11 23:14:46 +0000467the parent of the toplevel Python folder. The CVS path for these libraries is
Jack Jansen95375861999-03-10 15:51:56 +0000468also mentioned at the MacPython homepage. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000469
Jack Jansenc256ece1999-02-03 13:09:27 +0000470
Jack Jansen90cf4912000-02-11 23:14:46 +0000471You should end up with a folder structure as described at the top of this
472document. <p>
473
Jack Jansendae108c2000-02-11 23:17:14 +0000474Note that while the Mac folder is now a subfolder of your toplevel Python
475folder this does not mean that they "act as one" as far as CVS is concerned.
476To update all your sources you have to do a "cvs update" in the toplevel
477Python folder and another one in the Mac folder. This is again a cvs problem:
478it cannot deal with subpackages coming from different repositories. <p>
479
Jack Jansen8f2d8021996-08-05 15:34:45 +0000480<H2>Odds and ends</H2>
481
482Some remarks that I could not fit in elsewhere:
483
484<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000485
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000486<LI> It may be possible to use the <code>PythonCore</code> shared
487library to embed Python in another program, if your program can live
Jack Jansen1473af71997-05-07 15:43:38 +0000488with using GUSI for I/O. Use PythonCore in stead of your MSL C library
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000489(or, at the very least, link it before the normal C library).
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000490
491<LI> It is possible to build PPC extension modules without building a
Jack Jansenc256ece1999-02-03 13:09:27 +0000492complete Python. The binary distribution installer can optionally install
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000493all the needed folders (the develop option). A template for a dynamic module can be found in
Jack Jansen3412c5d1997-08-27 14:08:22 +0000494<code>xx.prj</code>.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000495
496<LI> The Python shared library architecture is a variant of the architecture
497described as "application with shared libraries and dropins" in the MetroWerks
498"Targeting MacOS" documentation. The Python Application and applet-template use
Jack Jansen1473af71997-05-07 15:43:38 +0000499the <code>MSL AppRuntime.Lib</code> runtime library (with properly set CFM
500initialization and termination routines). PythonCore uses <code>MSL Runtime.Lib</code>,
501which is really intended for standalone programs but which we fool into working by
502providing a dummy main program.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000503It is linked statically into PythonCore (and exported to the applications and plugins)
504so we do not have to distribute yet another shared library. Plugin modules use
Jack Jansen1473af71997-05-07 15:43:38 +0000505<code>MSL ShlibRuntime.Lib</code> (not the dropin runtime: modules are never unloaded)
506and obtain the rest from PythonCore. PythonCore uses a
Jack Jansen27b10ec1996-08-23 15:44:18 +0000507non-standard initialization entry point, <code>__initialize_with_resources</code>, to
Jack Jansen1473af71997-05-07 15:43:38 +0000508be able to obtain resources from the library file later on. Plugins can do the same
509(_tkinter does) or use the standard <code>__initialize</code> entry point.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000510
511
Jack Jansen6ad8d131997-01-15 16:53:37 +0000512</UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000513</BODY>
514</HTML>