blob: 9c182dc653da83eea0b5b7b227af259fd65409d8 [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
35HREF="ftp://ftp.cwi.nl/pub/jack/python/mac">ftp://ftp.cwi.nl/pub/jack/python/mac</A>,
36and possibly also from the standard <A
37HREF="ftp://ftp.python.org/pub/python/mac">python.org ftp
38site</A>. Everything you need is also included in the standard Python
39source distribution, but the organization is different. Look in
40directory <code>Mac/mwerks/projects</code> for the project files and
41related stuff.
Jack Jansen8f2d8021996-08-05 15:34:45 +000042
Jack Jansen4c1e56c1996-08-06 16:16:20 +000043<LI> You need MetroWerks CodeWarrior. The current distribution has
44been built with version 9 of CodeWarrior. Ordering information is
45available on the <A HREF="http://www.metrowerks.com/">MetroWerks
46homepage</A>. You might still be able to build Python with MPW or
47Think/Symantec C but you are basically on your own.
48
49<LI> You need GUSI, the Grand Unified Socket Interface, by Matthias
Jack Jansen16e99c01996-09-07 17:11:26 +000050Neeracher. The current distribution has been built with a modified version of
Jack Jansen061ac501996-10-22 15:27:56 +000051CWGUSI 1.8.0. CWGUSI is
Jack Jansen4c1e56c1996-08-06 16:16:20 +000052obtainable from <A
53HREF="ftp://ftp.switch.ch/software/mac/src/mw_c">ftp://ftp.switch.ch/software/mac/src/mw_c</A>.
54It is possible to build a non-GUSI Python, see below.
55
Jack Jansen8f2d8021996-08-05 15:34:45 +000056</UL>
57
Jack Jansen4c1e56c1996-08-06 16:16:20 +000058<A NAME="optional">The MacPython project files are configured to
59include a plethora of optional modules</A>, and these modules need a
60number extra packages. To use the project files as-is you have to
Jack Jansen27b10ec1996-08-23 15:44:18 +000061download these packages too. PPC and CFM68K Python have all such modules as
Jack Jansen4c1e56c1996-08-06 16:16:20 +000062dynamically loaded modules, so if you don't need a certain package it
Jack Jansen27b10ec1996-08-23 15:44:18 +000063suffices to just refrain from builing the extension module. For static 68K
Jack Jansen4c1e56c1996-08-06 16:16:20 +000064Python things are a bit more complicated: you have to edit the
65interpreter project file to remove the reference to the module (and
Jack Jansen27b10ec1996-08-23 15:44:18 +000066the libraries it uses), and edit the <code>Mac:mwerks:mwerks_nonshared_config.h</code>
67file to remove the <code>USE_...</code> line. Here are the locations for the various things
Jack Jansen4c1e56c1996-08-06 16:16:20 +000068you need:
Jack Jansen8f2d8021996-08-05 15:34:45 +000069
70<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000071
Jack Jansen4c1e56c1996-08-06 16:16:20 +000072<LI> Tcl and Tk can be obtained from <A
73HREF="ftp://ftp.smli.com/pub/tcl/mac/">ftp://ftp.smli.com/pub/tcl/mac/</A>.
74The current distributions, Tcl 7.5p1 and Tk 4.1p1 need a bit of work,
75see the section on <A HREF="#tcltk">building Tcl/Tk Python</A>
76below. Get the "full source" distribution, which includes MoreFiles.
Jack Jansen8f2d8021996-08-05 15:34:45 +000077
Jack Jansen4c1e56c1996-08-06 16:16:20 +000078<LI> Waste, a TextEdit replacement written by Marco Piovanelli, <A
79HREF="mailto:piovanel@kagi.com">&lt;piovanel@kagi.com&gt;</A>. Python
80was built using version 1.2, which you can obtain from <A
81HREF="ftp://rhino.harvard.edu/pub/dan/WASTE">&lt;ftp://rhino.harvard.edu/pub/dan/WASTE&gt;</A>
82and various other places.
Jack Jansen8f2d8021996-08-05 15:34:45 +000083
Jack Jansen4c1e56c1996-08-06 16:16:20 +000084<LI> JPEG library by the Independent JPEG Group. Python is still built
85using an archaic version of the library, version 4. It can be obtained
86from the <A HREF="ftp://ftp.cwi.nl/pub/jack/python/mac">
87ftp://ftp.cwi.nl/pub/jack/python/mac</A> directory, complete with CW8
88projects. If someone manages to build Python with the version 6
89library I would be grateful if they sent me the changes needed. The
90most recent JPEG library can always be obtained from <A
91HREF="ftp://ftp.uu.net/graphics/jpeg/">ftp://ftp.uu.net/graphics/jpeg/</A>.
92
93<LI> The netpbm/pbmplus and libtiff libraries. The netpbm distribution
94(which includes libtiff) is generally available on Internet ftp
95servers. For Python pbmplus, an older incarnation of netpbm, is
96functionally identical to netpbm, since Python only uses the library
97and not the complete applications. A distribution with correct
98projects and library source only is available from, you guessed it, <A
99HREF="ftp://ftp.cwi.nl/pub/jack/python/mac">ftp://ftp.cwi.nl/pub/jack/python/mac</A>.
100
Jack Jansen8f2d8021996-08-05 15:34:45 +0000101</UL>
102
103<H2>Setting Up</H2>
104
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000105Now that you have collected everything you should start with building
106the various parts. Everything is independent, with the single
107exception that Tcl and Tk depend on CWGUSI. If you don't want to fix
108access paths try to set things up as follows:
109
Jack Jansen8f2d8021996-08-05 15:34:45 +0000110<PRE>
111Top-level-folder:
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000112 CWGUSI
Jack Jansen8f2d8021996-08-05 15:34:45 +0000113 imglibs
114 libjpeg
115 pbmplus
116 libtiff
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000117 MoreFiles 1.4.2 (not needed by Python, only by tcl/tk)
Jack Jansen8f2d8021996-08-05 15:34:45 +0000118 Python
119 Tcl 7.5
120 Tk 4.1
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000121 Waste 1.2 distribution (if you want waste)
Jack Jansen8f2d8021996-08-05 15:34:45 +0000122</PRE>
123
Jack Jansen16e99c01996-09-07 17:11:26 +0000124First build GUSI. Move the files from the "CWGUSI-mods" to the right
125place in the CWGUSI distribution folder, and build the
Jack Jansen27b10ec1996-08-23 15:44:18 +0000126projects <code>GUSI.68K.µ</code>, <code>GUSI.CFM68K.µ</code>
Jack Jansen319f1a21996-10-16 15:28:30 +0000127(note that the Gusi CFM68K project is
128distributed without "far data": you should set this option before building)
129and <code>GUSI.PPC.µ</code>.
130If you have a CWGUSI version more recent than
Jack Jansen16e99c01996-09-07 17:11:26 +00001311.7.2 it could be that the fixes are already included, check it. Alternatively,
132you can forget about the fixes and remove the one reference to GUSILoadPreferences
133in the Python sources. This will disable the "default file creator/type" and
134"Delay Sioux window" preferences in Python.
135
136Next, in
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000137<code>MoreFiles</code>, <code>libjpeg</code>, <code>pbmplus</code>
138and<code>libtiff</code> you build all projects. Tcl/tk is a special
Jack Jansen27b10ec1996-08-23 15:44:18 +0000139case, see below. Of course, if you are only interested in one of
140static 68K, CFM68K or PPC you can skip building the other libraries.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000141
142<H2><A NAME="tcltk">Building Tcl/Tk</H2>
143
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000144You need to make a minor organizational change to the Tcl/Tk
145distribution. The current instructions are for the
146<code>tcl7.5.1</code> and <code>tk4.1.1</code> distribution:
147
Jack Jansen8f2d8021996-08-05 15:34:45 +0000148<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000149
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000150<LI> Rename the <code>compat</code> folders to <code>(compat)</code>
151in both the Tcl and Tk folders.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000152
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000153<LI> In the Tcl folder, move <code>strncasecmp.c</code> and
154<code>tclErrno.h</code> from <code>(compat)</code> to the main Tcl
155folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000156
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000157<LI> Fix <code>dnr.c</code> as provided by MetroWerks by inserting
158<pre><code> #pragma ANSI_strict off </code></pre> at the
159beginning. The tcl library is built with strict ANSI on, and this file
160uses C++ style comments.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000161
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000162<LI> If you want to build <code>SimpleTcl</code> and
163<code>SimpleTk</code> you will probably have to remove the references
164to <code>libmoto</code> from the project.
165
166<LI> You are <EM>strongly</EM> advised to add a line
Jack Jansen8f2d8021996-08-05 15:34:45 +0000167<pre><code>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000168#define USE_TCLALLOC 1
Jack Jansen8f2d8021996-08-05 15:34:45 +0000169</code></pre>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000170somewhere at the beginning of <code>MW_TclHeader.pch</code>.
171As distributed, tcl and tk assume that malloc calls always succeed and
172use the resulting pointer without checking for <code>NULL</code>
173values. Needless to say, this wreaks havoc on a Macintosh.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000174
Jack Jansen27b10ec1996-08-23 15:44:18 +0000175<LI> If you want to build for CFM68K you have to modify <code>TclMacNotify.c</code>
176because there is an error in the Apple Universal headers (sic!). Read the
177comments at the beginning of <code>Mac:Python:macglue.c</code> and copy the
178code to <code>TclMacNotify.c</code>. If you get linker errors on <code>GetEvQHdr</code>
179you have not done this correctly.
180
Jack Jansen8f2d8021996-08-05 15:34:45 +0000181</UL>
182
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000183Build first the MoreFiles library, then the Tcl library, then
184SimpleTcl (test it by typing <code>ls -l</code> in the window you get)
185then the Tk library, then SimpleTk (which can again be tested with
186<code>ls -l</code>). If this all worked you are all set to try
Jack Jansen8f2d8021996-08-05 15:34:45 +0000187building Python.
188
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000189<H2>Building Waste</H2>
190
191You do not need to build the Waste libraries, as Python includes the
192source modules themselves. You have to make one modification,
193though. In file <code>ICCFMGlue.c</code> in folder <code>Minimal IC
194APIs</code>, add the following lines:
195
196<blockquote><pre><code>
197#include <Gestalt.h>
198#include <Errors.h>
199</code></pre></blockquote>
200
Jack Jansen8f2d8021996-08-05 15:34:45 +0000201<H2>The organization of the Python source tree</H2>
202
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000203Time for a short break, while we have a look at the organization of
204the Python source tree. At the top level, we find the following
205folders:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000206
207<DL>
208<DT> build.mac68k.stand
Jack Jansen27b10ec1996-08-23 15:44:18 +0000209<DD> This is where you will build static 68K interpreters.
210
211<DT> build.mac68k.shared
212<DD> This is where you build the CFM68K shared library, interpreter
213and applet framework.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000214
215<DT> build.macppc.shared
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000216<DD> This is where you build the PPC shared library, interpreter and
Jack Jansen27b10ec1996-08-23 15:44:18 +0000217applet framework. You can also build the fat applet framework here.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000218
219<DT> build.macppc.stand
220<DD> This is where you build a nonshared PPC interpreter (optional).
221
222<DT> Demo
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000223<DD> Demo programs that are not Mac-specific. Some of these may not
224work, the file <code>README-Mac</code> has some details.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000225
226<DT> Extensions
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000227<DD> Extensions to the interpreter that are not Mac-specific. Contains
228only the <code>img</code> extension in this distribution. Extensions
229are <em>not</em> built here, as they are on Unix, but incorporated in
230the core interpreter or built as plugin modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000231
232<DT> Grammar
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000233<DD> The Python grammar. Included for reference only, you cannot build
234the parser on a Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000235
236<DT> Include
237<DD> Machine-independent header files.
238
239<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000240<DD> Machine-independent optional modules. Not all of these will work
241on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000242
243<DT> Objects
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000244<DD> Machine-independent code for various objects. Most of these are
245not really optional: the interpreter will not function without them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000246
247<DT> Parser
248<DD> The Python parser (machine-independent).
249
250<DT> PlugIns
Jack Jansen27b10ec1996-08-23 15:44:18 +0000251<DD> This is where you build the PPC and CFM68K dynamically-loaded plugin modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000252
253<DT> Python
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000254<DD> The core interpreter. Most files are machine-independent, some
255are unix-specific and not used on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000256
257<DT> Tools
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000258<DD> Tools for python developers. Contains <code>modulator</code>
259which builds skeleton C extension modules and <code>bgen</code> which
260generates complete interface modules from information in C header
261files. There are some readme files, but more documentation is sorely
262needed.
263
Jack Jansen8f2d8021996-08-05 15:34:45 +0000264</DL>
265
266All the mac-specific stuff lives in the <code>Mac</code> folder:
267<DL>
268
269<DT> Compat
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000270<DD> Unix-compatability routines. Some of these are not used anymore,
271since CWGUSI provides a rather complete emulation, but you may need
272these if you are trying to build a non-GUSI python.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000273
274<DT> Demo
275<DD> Mac-specific demo programs, some of them annotated.
276
277<DT> Include
278<DD> Mac-specific but compiler-independent include files.
279
280<DT> Lib
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000281<DD> Mac-specific standard modules. The <code>toolbox</code> folder
282contains modules specifically needed with various MacOS toolbox
283interface modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000284
285<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000286<DD> Mac-specific builtin modules. Theoretically these are all
287optional, but some are rather essential (like
288<code>macmodule</code>). A lot of these modules are generated with
289<code>bgen</code>, in which case the bgen input files are included so
290you can attempt to regenerate them or extend them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000291
292<DT> MPW
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000293<DD> MPW-specific files. These have not been used or kept up-to-date
294for a long time, so use at your own risk.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000295
296<DT> mwerks
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000297<DD> Mwerks-specific sources and headers. Contains glue code for
298Pythons shared-library architecture, a replacement for
299<code>malloc</code> and a directory with various projects for building
300variations on the Python interpreter. The <code>mwerks_*.h</code>
301files here are the option-setting files for the various interpreters
302and such, comparable to the unix command-line <code>-D</code> options
303to the compiler. Each project uses the correct option file as its
304"prefix file" in the "C/C++ language" settings. Disabling optional
305modules (for the 68K interpreter), building non-GUSI interpreters and
306various other things are accomplished by modifying these files (and
307possibly changing the list of files included in the project window, of
308course).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000309
310<DT> Python
311<DD> Mac-specific parts of the core interpreter.
312
313<DT> Resources
314<DD> Resource files needed to build the interpreter.
315
316<DT> Scripts
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000317<DD> A collection of various mac-specific Python scripts. Some are
318essential, some are useful but few are documented, so you will have to
319use your imagination to work them out.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000320
321<DT> Unsupported
322<DD> Modules that are not supported any longer but may still work with a little effort.
323</DL>
324
325<H2>Building the 68K interpreter</H2>
326
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000327If you have all the optional libraries mentioned <A
328HREF="#optional">above</A> loaded buildin Python for 68K macs is a
329breeze: open the project in the folder <code>build.mac68k.stand</code>
330and build it. Do <em>not</em> run it yet, this will possibly result
331in a garbled preferences file. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000332
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000333First remove the <code>Python preferences</code> file from your
334preference folder, only if you had an older version of Python
335installed. (this is also what you do if you did not heed the last
336sentence of the preceeding paragraph). Next, move the interpreter to
337the main Python folder (up one level) and run it there. This will
338create a correct initial preferences file. You are now all set, and
339your tree should be completely compatible with a binary-only
340distribution. Read the release notes
341(<code>Relnotes-somethingorother</code>) and
342<code>ReadMeOrSuffer</code> in the <code>Mac</code> folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000343
Jack Jansen27b10ec1996-08-23 15:44:18 +0000344<H2>Building the CFM68K interpreter</H2>
345
346Building the CFM68K interpreter is as almost exactly the same as building
347the PPC interpreter, with the exception that you should read "CFM68K"
348for "PPC" every time. Continue reading with the next section.
349
Jack Jansen8f2d8021996-08-05 15:34:45 +0000350<H2>Building the PPC interpreter</H2>
351
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000352First you build the interpreter, core library and applet skeleton in
353folder <code>build.macppc.stand</code>. The order to build things is
354the following:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000355
356<DL>
Jack Jansen27b10ec1996-08-23 15:44:18 +0000357<DT> MWRuntimeStaticLib
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000358<DD> A modified version of the MetroWerks runtime library that is
359suitable for Pythons' shared library architecture. The sources all
360come from the MW distribution.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000361
Jack Jansen27b10ec1996-08-23 15:44:18 +0000362<DT> PythonCorePPC
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000363<DD> The shared library that contains the bulk of the interpreter and
364its resources. It is a good idea to immedeately put an alias to this
365shared library in the <code>Extensions</code> folder of your system
366folder. Do exactly that: put an <em>alias</em> there, copying or
367moving the file will cause you grief later.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000368
369<DT> PythonPPC
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000370<DD> The interpreter. This is basically a routine to call out to the
371shared library. Because of the organization of GUSI it also contains
372the Gusi settings resource (together with a ResEdit template, so you
373can change the gusi settings should you feel like doing so). Do
374<em>not</em> run it yet, this will possibly result in a garbled
375preferences file. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000376
Jack Jansen061ac501996-10-22 15:27:56 +0000377<DT> PythonAppletPPC
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000378<DD> The applet skeleton application. Very similar to
379<code>PythonPPC</code>, but it calls to a different entrypoint in the
380core library. The <code>mkapplet</code> script will copy this complete
381file, and add a <code>'PYC '</code> with the module to generate an
382applet. <p>
383
Jack Jansen8f2d8021996-08-05 15:34:45 +0000384</DL>
385
Jack Jansen061ac501996-10-22 15:27:56 +0000386After creating the alias to <code>PythonCorePPC</code> you should move
387<code>PythonPPC</code> to the main Python folder. Next you remove any old
388<code>Python XXX Preferences</code> file from the <code>Preferences</code> folder
389(if you had python installed on your system before) and run the interpreter once
390to create the correct preferences file. You should also make an alias
391<code>PythonApplet</code> pointing to <code>PythonAppletPPC</code> in the main
392Python folder. (again: making an alias is preferrable to copying or moving the
393file, since this will cause the correct file to be used if you ever rebuild
394PythonAppletPPC). <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000395
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000396Next, you have to build the extension modules in the
Jack Jansen27b10ec1996-08-23 15:44:18 +0000397<code>PlugIns</code> folder. Open each project with <code>.ppc</code> in the
398name and build it. After all
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000399the dynamically loaded modules are built you have to create a number
400of aliases: some modules live together in a single dynamic
Jack Jansen27b10ec1996-08-23 15:44:18 +0000401library. Run the <code>MkPluginAliases.py</code> script from
402<code>Mac:scripts</code> to create the aliases. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000403
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000404Finally, you must build the standard applets:
405<code>EditPythonPrefs</code>, <code>mkapplet</code>, etc. This is
406easiest done with the <code>fullbuild</code> script from
407<code>Mac:scripts</code>. Answer <em>no</em> to all questions except
408when it asks whether to build the applets. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000409
410<BLOCKQUOTE>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000411Actually, the <code>fullbuild</code> script can be used to build
412everything, but you need a fully-functional interpreter before you can
413use it (and one that isn't rebuilt in the process: you cannot rebuild
414a running program). You could copy the 68K interpreter to a different
415place and use that to run fullbuild, or use the standalone PPC python
416for this. I tend to keep a standalone interpreter in a safe place for
417this use only.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000418</BLOCKQUOTE>
419
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000420You are all set now, and should read the release notes and
421<code>ReadMeOrSuffer</code> file from the <code>Mac</code> folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000422
Jack Jansen27b10ec1996-08-23 15:44:18 +0000423<H2>Rebuilding <code>.exp</code> files for PPC and CFM68K</H2>
424
425Occasionally it may be necessary to rebuild your PythonCore <code>.exp</code>
426file, a file that controls which symbols are exported by your PythonCore
427shared library. Rebuild it if you get unexpected undefined symbols when you
428are building a plugin module. <p>
429
430Rebuilding the .exp file is done by first removing the file and removing the
431reference to it in the project (in the "config" section). Next, build PythonCore.
432This will create a new .exp file. Edit this file to remove the references to
433the symbols <code>__initialize</code>, <code>__terminate</code>, <code>setjmp</code>,
434<code>longjmp</code> and <code>__ptmf_null</code>. Next, add the .exp file to the project
435again and rebuild PythonCore. <p>
436
437This rather convoluted procedure is needed to ensure that plugin modules don't
438accidentally link with those entrypoints from PythonCore, which will not work because
439those routines have to be in the same code fragment as they are used from.
440
Jack Jansen8f2d8021996-08-05 15:34:45 +0000441<H2>Odds and ends</H2>
442
443Some remarks that I could not fit in elsewhere:
444
445<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000446
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000447<LI> It may be possible to use the <code>PythonCore</code> shared
448library to embed Python in another program, if your program can live
449with using GUSI for I/O. Use PythonCore in stead of your C library
450(or, at the very least, link it before the normal C library). Let me
451know whether this works.
452
453<LI> It is possible to build PPC extension modules without building a
454complete Python. Take the binary distribution, add folders
455<code>Include</code>, <code>Mac:Include</code> and
456<code>Mac:mwerks</code> from the source distribution and you should be
457all set. A template for a dynamic module can be found in
Jack Jansen27b10ec1996-08-23 15:44:18 +0000458<code>xx.ppc.µ</code> or <code>xx.CFM68K.µ</code>.
459
460<LI> The Python shared library architecture is a variant of the architecture
461described as "application with shared libraries and dropins" in the MetroWerks
462"Targeting MacOS" documentation. The Python Application and applet-template use
463the <code>AppRuntime.Lib</code> runtime library (with properly set CFM
464initialization and termination routines). PythonCore uses <code>ShlibRuntime.Lib</code>
465and <code>MWRuntimeStaticLib.Lib</code>, which is almost identical to the MW
466standard <code>MWRuntimeLib</code>, but not dynamically loaded. This library contains
467the part of the runtime that can (or must) be shared between all modules in the program.
468It is linked statically into PythonCore (and exported to the applications and plugins)
469so we do not have to distribute yet another shared library. Plugin modules use
470<code>ShlibRuntime.Lib</code> and obtain the rest from PythonCore. PythonCore uses a
471non-standard initialization entry point, <code>__initialize_with_resources</code>, to
472be able to obtain resources from the library file lateron. Plugins can do the same or
473use the standard <code>__initialize</code> entry point.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000474
475
476<UL>
477</BODY>
478</HTML>