blob: dc6c9a294827505f2ff3dcec4d526b2defaaefd0 [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 Jansen4c1e56c1996-08-06 16:16:20 +00009This document explains how to build MacPython from source. This is
10necessary if you want to write extension modules for 68K Python, and
11currently also probably the easiest way to build PPC extension
12modules. Building Python is not something to be undertaken lightly,
13the process is not very streamlined so you need a reasonable working
14knowledge of the CodeWarrior development environment, a good net
15connection and probably quite some time too. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +000016
Jack Jansen4c1e56c1996-08-06 16:16:20 +000017The information density in this file is high, so you should probably
18print it and read it at your leasure. Most things are explained only
19once (and probably in the wrong place:-). <p>
20
21I am very interested in feedback on this document, contact me at <A
22HREF="mailto:jack@cwi.nl">&lt;jack@cwi.nl&gt;</A> or send your
23comments to the <A
24HREF="http://www.python.org/sigs/pythonmac-sig/">Mac Python Special
25Interest Group</A>.
Jack Jansen8f2d8021996-08-05 15:34:45 +000026
27<H2>What you need.</H2>
28
29The following things you definitely need:
30
31<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000032
Jack Jansen4c1e56c1996-08-06 16:16:20 +000033<LI> You need a MacPython source distribution, of course. You can
34obtain one from <A
Jack Jansen1473af71997-05-07 15:43:38 +000035HREF="ftp://ftp.cwi.nl/pub/jack/python/mac">ftp://ftp.cwi.nl/pub/jack/python/mac</A>
36or from the companion webpage at <A HREF="http://www.cwi.nl/~jack/macpython.html">
37http://www.cwi.nl/~jack/macpython.html</A> (which has up-to-date links to the other
38packages needed too)
Jack Jansen4c1e56c1996-08-06 16:16:20 +000039and possibly also from the standard <A
40HREF="ftp://ftp.python.org/pub/python/mac">python.org ftp
41site</A>. Everything you need is also included in the standard Python
42source distribution, but the organization is different. Look in
43directory <code>Mac/mwerks/projects</code> for the project files and
44related stuff.
Jack Jansen8f2d8021996-08-05 15:34:45 +000045
Jack Jansen4c1e56c1996-08-06 16:16:20 +000046<LI> You need MetroWerks CodeWarrior. The current distribution has
Jack Jansen1473af71997-05-07 15:43:38 +000047been built with version 11 of CodeWarrior. Ordering information is
Jack Jansen4c1e56c1996-08-06 16:16:20 +000048available on the <A HREF="http://www.metrowerks.com/">MetroWerks
49homepage</A>. You might still be able to build Python with MPW or
50Think/Symantec C but you are basically on your own.
51
52<LI> You need GUSI, the Grand Unified Socket Interface, by Matthias
Jack Jansen1473af71997-05-07 15:43:38 +000053Neeracher. The original CWGUSI is
Jack Jansen4c1e56c1996-08-06 16:16:20 +000054obtainable from <A
Jack Jansenf3dd5aa1996-12-23 17:29:51 +000055HREF="ftp://sunsite.cnlab-switch.ch/software/platform/macos/src">
Jack Jansene66b8c81997-05-29 14:57:07 +000056ftp://sunsite.cnlab-switch.ch/software/platform/macos/src</A>.
57At the moment Python is built with a rather hacked-up version of GUSI,
58these modifications are available in folder <code>Python:Mac:GUSI-mods</code>.
Jack Jansen4c1e56c1996-08-06 16:16:20 +000059
Jack Jansen8f2d8021996-08-05 15:34:45 +000060</UL>
61
Jack Jansen4c1e56c1996-08-06 16:16:20 +000062<A NAME="optional">The MacPython project files are configured to
63include a plethora of optional modules</A>, and these modules need a
64number extra packages. To use the project files as-is you have to
Jack Jansen27b10ec1996-08-23 15:44:18 +000065download these packages too. PPC and CFM68K Python have all such modules as
Jack Jansen4c1e56c1996-08-06 16:16:20 +000066dynamically loaded modules, so if you don't need a certain package it
Jack Jansen27b10ec1996-08-23 15:44:18 +000067suffices to just refrain from builing the extension module. For static 68K
Jack Jansen4c1e56c1996-08-06 16:16:20 +000068Python things are a bit more complicated: you have to edit the
69interpreter project file to remove the reference to the module (and
Jack Jansen27b10ec1996-08-23 15:44:18 +000070the libraries it uses), and edit the <code>Mac:mwerks:mwerks_nonshared_config.h</code>
71file to remove the <code>USE_...</code> line. Here are the locations for the various things
Jack Jansen4c1e56c1996-08-06 16:16:20 +000072you need:
Jack Jansen8f2d8021996-08-05 15:34:45 +000073
74<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000075
Jack Jansen4c1e56c1996-08-06 16:16:20 +000076<LI> Tcl and Tk can be obtained from <A
77HREF="ftp://ftp.smli.com/pub/tcl/mac/">ftp://ftp.smli.com/pub/tcl/mac/</A>.
Jack Jansenf3dd5aa1996-12-23 17:29:51 +000078The current distributions, Tcl 7.6 and Tk 4.2 need a bit of work,
Jack Jansen4c1e56c1996-08-06 16:16:20 +000079see the section on <A HREF="#tcltk">building Tcl/Tk Python</A>
80below. Get the "full source" distribution, which includes MoreFiles.
Jack Jansen8f2d8021996-08-05 15:34:45 +000081
Jack Jansen4c1e56c1996-08-06 16:16:20 +000082<LI> Waste, a TextEdit replacement written by Marco Piovanelli, <A
83HREF="mailto:piovanel@kagi.com">&lt;piovanel@kagi.com&gt;</A>. Python
84was built using version 1.2, which you can obtain from <A
85HREF="ftp://rhino.harvard.edu/pub/dan/WASTE">&lt;ftp://rhino.harvard.edu/pub/dan/WASTE&gt;</A>
86and various other places.
Jack Jansen8f2d8021996-08-05 15:34:45 +000087
Jack Jansen1473af71997-05-07 15:43:38 +000088<LI> Gdbm library for the Mac. Available from Jack's Mac software page at
89<A HREF="http://www.cwi.nl/~jack/macsoftware.html">
90http://www.cwi.nl/~jack/macsoftware.html</A> and <A HREF="ftp://ftp.cwi.nl/pub/jack/mac">
91ftp://ftp.cwi.nl/pub/jack/mac</A>.
92
93<LI> JPEG library by the Independent JPEG Group. A version including
94Mac projects can be found at Jack's page mentioned above.
95The most recent JPEG library can always be obtained from <A
Jack Jansen4c1e56c1996-08-06 16:16:20 +000096HREF="ftp://ftp.uu.net/graphics/jpeg/">ftp://ftp.uu.net/graphics/jpeg/</A>.
97
Jack Jansen1473af71997-05-07 15:43:38 +000098<LI> The netpbm/pbmplus, libtiff, zlib and png libraries. The netpbm distribution
Jack Jansen4c1e56c1996-08-06 16:16:20 +000099(which includes libtiff) is generally available on Internet ftp
100servers. For Python pbmplus, an older incarnation of netpbm, is
101functionally identical to netpbm, since Python only uses the library
102and not the complete applications. A distribution with correct
Jack Jansen1473af71997-05-07 15:43:38 +0000103projects and library source only is available from, you guessed it, Jack's Mac software
104page mentioned above.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000105
Jack Jansen8f2d8021996-08-05 15:34:45 +0000106</UL>
107
108<H2>Setting Up</H2>
109
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000110Now that you have collected everything you should start with building
Jack Jansen1473af71997-05-07 15:43:38 +0000111the various parts. If you don't want to fix
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000112access paths try to set things up as follows:
113
Jack Jansen8f2d8021996-08-05 15:34:45 +0000114<PRE>
115Top-level-folder:
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000116 CWGUSI
Jack Jansen8f2d8021996-08-05 15:34:45 +0000117 imglibs
118 libjpeg
119 pbmplus
Jack Jansen1473af71997-05-07 15:43:38 +0000120 libtiff
121 zlib
122 libpng
123 gdbm
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000124 MoreFiles 1.4.3 (not needed by Python, only by tcl/tk)
Jack Jansen8f2d8021996-08-05 15:34:45 +0000125 Python
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000126 Tcl 7.6
127 Tk 4.2
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000128 Waste 1.2 distribution (if you want waste)
Jack Jansen8f2d8021996-08-05 15:34:45 +0000129</PRE>
130
Jack Jansen1473af71997-05-07 15:43:38 +0000131First build GUSI. If you didn't get the python-specific GUSI you have to
132move the files from the "CWGUSI-mods" to the right
Jack Jansene66b8c81997-05-29 14:57:07 +0000133place in the CWGUSI distribution folder. Build the
134projects <code>MSLGUSI.68K.µ</code>, <code>MSLGUSI.CFM68K.µ</code> and
135<code>MSLGUSI.PPC.µ</code>. <p>
Jack Jansen16e99c01996-09-07 17:11:26 +0000136
Jack Jansene66b8c81997-05-29 14:57:07 +0000137If you have a CWGUSI version more recent than
1381.8 it could be that the fixes are already included, check it.
Jack Jansen16e99c01996-09-07 17:11:26 +0000139Next, in
Jack Jansen1473af71997-05-07 15:43:38 +0000140<code>MoreFiles</code>, <code>libjpeg</code>, <code>pbmplus</code>,
141<code>zlib</code>, <code>libpng</code>, <code>gdbm</code>,
142and<code>libtiff</code> you build all projects. Sometimes the projects are in "mac"
143subfolders, sometimes they are in the main folder. Tcl/tk is a special
Jack Jansen27b10ec1996-08-23 15:44:18 +0000144case, see below. Of course, if you are only interested in one of
145static 68K, CFM68K or PPC you can skip building the other libraries.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000146
147<H2><A NAME="tcltk">Building Tcl/Tk</H2>
148
Jack Jansene66b8c81997-05-29 14:57:07 +0000149You need to make some minor changes to the Tcl/Tk
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000150distribution. The current instructions are for the
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000151<code>tcl7.6</code> and <code>tk4.2</code> distribution:
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000152
Jack Jansen8f2d8021996-08-05 15:34:45 +0000153<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000154
Jack Jansene66b8c81997-05-29 14:57:07 +0000155<LI> You have to change the access path setting and such to use the MSL
156libraries (this tcl/tk ditribution predates MSL).
157
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000158<LI> Rename the <code>compat</code> folders to <code>(compat)</code>
159in both the Tcl and Tk folders.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000160
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000161<LI> In the Tcl folder, move <code>strncasecmp.c</code> and
162<code>tclErrno.h</code> from <code>(compat)</code> to the main Tcl
163folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000164
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000165<LI> Fix <code>dnr.c</code> as provided by MetroWerks by inserting
166<pre><code> #pragma ANSI_strict off </code></pre> at the
167beginning. The tcl library is built with strict ANSI on, and this file
168uses C++ style comments.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000169
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000170<LI> If you want to build <code>SimpleTcl</code> and
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000171<code>SimpleTk</code> you may have to remove the references
172to <code>libmoto</code> from the project, not everyone has this library.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000173
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000174<LI> If you want to build for CFM68K you have to create the projects
175for the libraries yourself. Take the 68K library projects, set the C++ header
176file to "MW_TclHeaderCFM68K", the project type to "cfm68K library" and the
177filename to "Tcl-CFM68K.Lib" (and similarly for Tk).
178You may also have to modify <code>TclMacNotify.c</code>
Jack Jansen27b10ec1996-08-23 15:44:18 +0000179because there is an error in the Apple Universal headers (sic!). Read the
180comments at the beginning of <code>Mac:Python:macglue.c</code> and copy the
181code to <code>TclMacNotify.c</code>. If you get linker errors on <code>GetEvQHdr</code>
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000182you have not done this correctly. <em>XXXX Is this still needed?</em>
183
184<LI> Note that if you use a different release of Tcl and Tk than the ones
185I have used you may have to adapt the Python <code>tkresources.rsrc</code> file.
186This is easiest done by building <code>SimpleTk</code> and copying the TEXT, ICON
187and CRSR resources from it to <code>tkresources.rsrc</code>. This allows
188the <code>_tkinter</code> module to work without an installed Tk/Tcl on your
189machine.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000190
Jack Jansen8f2d8021996-08-05 15:34:45 +0000191</UL>
192
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000193Build first the Tcl library, then
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000194SimpleTcl (test it by typing <code>ls -l</code> in the window you get)
195then the Tk library, then SimpleTk (which can again be tested with
196<code>ls -l</code>). If this all worked you are all set to try
Jack Jansen8f2d8021996-08-05 15:34:45 +0000197building Python.
198
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000199<H2>Building Waste</H2>
200
201You do not need to build the Waste libraries, as Python includes the
202source modules themselves. You have to make one modification,
203though. In file <code>ICCFMGlue.c</code> in folder <code>Minimal IC
204APIs</code>, add the following lines:
205
206<blockquote><pre><code>
207#include <Gestalt.h>
208#include <Errors.h>
209</code></pre></blockquote>
210
Jack Jansen8f2d8021996-08-05 15:34:45 +0000211<H2>The organization of the Python source tree</H2>
212
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000213Time for a short break, while we have a look at the organization of
214the Python source tree. At the top level, we find the following
215folders:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000216
217<DL>
218<DT> build.mac68k.stand
Jack Jansen1473af71997-05-07 15:43:38 +0000219<DD> This is where you build static 68K interpreters.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000220
221<DT> build.mac68k.shared
222<DD> This is where you build the CFM68K shared library, interpreter
223and applet framework.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000224
225<DT> build.macppc.shared
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000226<DD> This is where you build the PPC shared library, interpreter and
Jack Jansen27b10ec1996-08-23 15:44:18 +0000227applet framework. You can also build the fat applet framework here.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000228
229<DT> build.macppc.stand
230<DD> This is where you build a nonshared PPC interpreter (optional).
231
232<DT> Demo
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000233<DD> Demo programs that are not Mac-specific. Some of these may not
234work, the file <code>README-Mac</code> has some details.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000235
236<DT> Extensions
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000237<DD> Extensions to the interpreter that are not Mac-specific. Contains
238only the <code>img</code> extension in this distribution. Extensions
239are <em>not</em> built here, as they are on Unix, but incorporated in
240the core interpreter or built as plugin modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000241
242<DT> Grammar
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000243<DD> The Python grammar. Included for reference only, you cannot build
244the parser on a Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000245
246<DT> Include
247<DD> Machine-independent header files.
248
249<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000250<DD> Machine-independent optional modules. Not all of these will work
251on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000252
253<DT> Objects
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000254<DD> Machine-independent code for various objects. Most of these are
255not really optional: the interpreter will not function without them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000256
257<DT> Parser
258<DD> The Python parser (machine-independent).
259
260<DT> PlugIns
Jack Jansen27b10ec1996-08-23 15:44:18 +0000261<DD> This is where you build the PPC and CFM68K dynamically-loaded plugin modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000262
263<DT> Python
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000264<DD> The core interpreter. Most files are machine-independent, some
265are unix-specific and not used on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000266
267<DT> Tools
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000268<DD> Tools for python developers. Contains <code>modulator</code>
269which builds skeleton C extension modules and <code>bgen</code> which
270generates complete interface modules from information in C header
271files. There are some readme files, but more documentation is sorely
272needed.
273
Jack Jansen8f2d8021996-08-05 15:34:45 +0000274</DL>
275
276All the mac-specific stuff lives in the <code>Mac</code> folder:
277<DL>
278
279<DT> Compat
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000280<DD> Unix-compatability routines. Some of these are not used anymore,
281since CWGUSI provides a rather complete emulation, but you may need
282these if you are trying to build a non-GUSI python.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000283
284<DT> Demo
285<DD> Mac-specific demo programs, some of them annotated.
286
287<DT> Include
288<DD> Mac-specific but compiler-independent include files.
289
290<DT> Lib
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000291<DD> Mac-specific standard modules. The <code>toolbox</code> folder
292contains modules specifically needed with various MacOS toolbox
293interface modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000294
295<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000296<DD> Mac-specific builtin modules. Theoretically these are all
297optional, but some are rather essential (like
298<code>macmodule</code>). A lot of these modules are generated with
299<code>bgen</code>, in which case the bgen input files are included so
300you can attempt to regenerate them or extend them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000301
302<DT> MPW
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000303<DD> MPW-specific files. These have not been used or kept up-to-date
304for a long time, so use at your own risk.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000305
306<DT> mwerks
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000307<DD> Mwerks-specific sources and headers. Contains glue code for
308Pythons shared-library architecture, a replacement for
309<code>malloc</code> and a directory with various projects for building
310variations on the Python interpreter. The <code>mwerks_*.h</code>
311files here are the option-setting files for the various interpreters
312and such, comparable to the unix command-line <code>-D</code> options
313to the compiler. Each project uses the correct option file as its
314"prefix file" in the "C/C++ language" settings. Disabling optional
315modules (for the 68K interpreter), building non-GUSI interpreters and
316various other things are accomplished by modifying these files (and
317possibly changing the list of files included in the project window, of
318course).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000319
320<DT> Python
321<DD> Mac-specific parts of the core interpreter.
322
323<DT> Resources
324<DD> Resource files needed to build the interpreter.
325
326<DT> Scripts
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000327<DD> A collection of various mac-specific Python scripts. Some are
328essential, some are useful but few are documented, so you will have to
329use your imagination to work them out.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000330
331<DT> Unsupported
332<DD> Modules that are not supported any longer but may still work with a little effort.
333</DL>
334
335<H2>Building the 68K interpreter</H2>
336
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000337If you have all the optional libraries mentioned <A
338HREF="#optional">above</A> loaded buildin Python for 68K macs is a
339breeze: open the project in the folder <code>build.mac68k.stand</code>
340and build it. Do <em>not</em> run it yet, this will possibly result
341in a garbled preferences file. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000342
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000343First remove the <code>Python preferences</code> file from your
344preference folder, only if you had an older version of Python
345installed. (this is also what you do if you did not heed the last
346sentence of the preceeding paragraph). Next, move the interpreter to
347the main Python folder (up one level) and run it there. This will
348create a correct initial preferences file. You are now all set, and
349your tree should be completely compatible with a binary-only
350distribution. Read the release notes
351(<code>Relnotes-somethingorother</code>) and
352<code>ReadMeOrSuffer</code> in the <code>Mac</code> folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000353
Jack Jansen27b10ec1996-08-23 15:44:18 +0000354<H2>Building the CFM68K interpreter</H2>
355
356Building the CFM68K interpreter is as almost exactly the same as building
357the PPC interpreter, with the exception that you should read "CFM68K"
358for "PPC" every time. Continue reading with the next section.
359
Jack Jansen8f2d8021996-08-05 15:34:45 +0000360<H2>Building the PPC interpreter</H2>
361
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000362First you build the interpreter, core library and applet skeleton in
363folder <code>build.macppc.stand</code>. The order to build things is
364the following:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000365
366<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000367
Jack Jansen27b10ec1996-08-23 15:44:18 +0000368<DT> PythonCorePPC
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000369<DD> The shared library that contains the bulk of the interpreter and
370its resources. It is a good idea to immedeately put an alias to this
371shared library in the <code>Extensions</code> folder of your system
372folder. Do exactly that: put an <em>alias</em> there, copying or
373moving the file will cause you grief later.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000374
375<DT> PythonPPC
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000376<DD> The interpreter. This is basically a routine to call out to the
Jack Jansen1473af71997-05-07 15:43:38 +0000377shared library. Do
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000378<em>not</em> run it yet, this will possibly result in a garbled
Jack Jansen1473af71997-05-07 15:43:38 +0000379preferences file. See the section below on rebuilding .exp files if you
380get funny linker errors. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000381
Jack Jansen061ac501996-10-22 15:27:56 +0000382<DT> PythonAppletPPC
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000383<DD> The applet skeleton application. Very similar to
384<code>PythonPPC</code>, but it calls to a different entrypoint in the
385core library. The <code>mkapplet</code> script will copy this complete
386file, and add a <code>'PYC '</code> with the module to generate an
387applet. <p>
388
Jack Jansen8f2d8021996-08-05 15:34:45 +0000389</DL>
390
Jack Jansen061ac501996-10-22 15:27:56 +0000391After creating the alias to <code>PythonCorePPC</code> you should move
392<code>PythonPPC</code> to the main Python folder. Next you remove any old
393<code>Python XXX Preferences</code> file from the <code>Preferences</code> folder
394(if you had python installed on your system before) and run the interpreter once
395to create the correct preferences file. You should also make an alias
396<code>PythonApplet</code> pointing to <code>PythonAppletPPC</code> in the main
397Python folder. (again: making an alias is preferrable to copying or moving the
398file, since this will cause the correct file to be used if you ever rebuild
399PythonAppletPPC). <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000400
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000401Next, you have to build the extension modules in the
Jack Jansen27b10ec1996-08-23 15:44:18 +0000402<code>PlugIns</code> folder. Open each project with <code>.ppc</code> in the
403name and build it. After all
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000404the dynamically loaded modules are built you have to create a number
405of aliases: some modules live together in a single dynamic
Jack Jansen27b10ec1996-08-23 15:44:18 +0000406library. Run the <code>MkPluginAliases.py</code> script from
407<code>Mac:scripts</code> to create the aliases. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000408
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000409Finally, you must build the standard applets:
410<code>EditPythonPrefs</code>, <code>mkapplet</code>, etc. This is
411easiest done with the <code>fullbuild</code> script from
412<code>Mac:scripts</code>. Answer <em>no</em> to all questions except
413when it asks whether to build the applets. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000414
415<BLOCKQUOTE>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000416Actually, the <code>fullbuild</code> script can be used to build
417everything, but you need a fully-functional interpreter before you can
418use it (and one that isn't rebuilt in the process: you cannot rebuild
419a running program). You could copy the 68K interpreter to a different
420place and use that to run fullbuild, or use the standalone PPC python
421for this. I tend to keep a standalone interpreter in a safe place for
Jack Jansene66b8c81997-05-29 14:57:07 +0000422this use only. <p>
423
424Using fullbuild is also the only easy way to buid the fat application and applet.
425See the fullbuild source for details on how to build the fat binaries "by hand".
426
Jack Jansen8f2d8021996-08-05 15:34:45 +0000427</BLOCKQUOTE>
428
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000429You are all set now, and should read the release notes and
430<code>ReadMeOrSuffer</code> file from the <code>Mac</code> folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000431
Jack Jansen27b10ec1996-08-23 15:44:18 +0000432<H2>Rebuilding <code>.exp</code> files for PPC and CFM68K</H2>
433
434Occasionally it may be necessary to rebuild your PythonCore <code>.exp</code>
435file, a file that controls which symbols are exported by your PythonCore
436shared library. Rebuild it if you get unexpected undefined symbols when you
437are building a plugin module. <p>
438
439Rebuilding the .exp file is done by first removing the file and removing the
440reference to it in the project (in the "config" section). Next, build PythonCore.
441This will create a new .exp file. Edit this file to remove the references to
442the symbols <code>__initialize</code>, <code>__terminate</code>, <code>setjmp</code>,
Jack Jansen1473af71997-05-07 15:43:38 +0000443<code>longjmp</code>, <code>main</code> and (for PPC) <code>__ptmf_null</code> or (for
444CFM68K) <code>__start</code> and <code>dummy_init_routine</code>.
445Next, add the .exp file to the project
Jack Jansen27b10ec1996-08-23 15:44:18 +0000446again and rebuild PythonCore. <p>
447
448This rather convoluted procedure is needed to ensure that plugin modules don't
449accidentally link with those entrypoints from PythonCore, which will not work because
450those routines have to be in the same code fragment as they are used from.
451
Jack Jansen8f2d8021996-08-05 15:34:45 +0000452<H2>Odds and ends</H2>
453
454Some remarks that I could not fit in elsewhere:
455
456<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000457
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000458<LI> It may be possible to use the <code>PythonCore</code> shared
459library to embed Python in another program, if your program can live
Jack Jansen1473af71997-05-07 15:43:38 +0000460with using GUSI for I/O. Use PythonCore in stead of your MSL C library
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000461(or, at the very least, link it before the normal C library). Let me
462know whether this works.
463
464<LI> It is possible to build PPC extension modules without building a
465complete Python. Take the binary distribution, add folders
466<code>Include</code>, <code>Mac:Include</code> and
467<code>Mac:mwerks</code> from the source distribution and you should be
468all set. A template for a dynamic module can be found in
Jack Jansen27b10ec1996-08-23 15:44:18 +0000469<code>xx.ppc.µ</code> or <code>xx.CFM68K.µ</code>.
470
471<LI> The Python shared library architecture is a variant of the architecture
472described as "application with shared libraries and dropins" in the MetroWerks
473"Targeting MacOS" documentation. The Python Application and applet-template use
Jack Jansen1473af71997-05-07 15:43:38 +0000474the <code>MSL AppRuntime.Lib</code> runtime library (with properly set CFM
475initialization and termination routines). PythonCore uses <code>MSL Runtime.Lib</code>,
476which is really intended for standalone programs but which we fool into working by
477providing a dummy main program.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000478It is linked statically into PythonCore (and exported to the applications and plugins)
479so we do not have to distribute yet another shared library. Plugin modules use
Jack Jansen1473af71997-05-07 15:43:38 +0000480<code>MSL ShlibRuntime.Lib</code> (not the dropin runtime: modules are never unloaded)
481and obtain the rest from PythonCore. PythonCore uses a
Jack Jansen27b10ec1996-08-23 15:44:18 +0000482non-standard initialization entry point, <code>__initialize_with_resources</code>, to
Jack Jansen1473af71997-05-07 15:43:38 +0000483be able to obtain resources from the library file later on. Plugins can do the same
484(_tkinter does) or use the standard <code>__initialize</code> entry point.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000485
486
Jack Jansen6ad8d131997-01-15 16:53:37 +0000487</UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000488</BODY>
489</HTML>