blob: eb64963be91cea75476518a08ca717ca763bca7f [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 Jansen32617191997-08-19 14:01:16 +000047been built with CodeWarrior Pro 1. 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>.
Jack Jansen3412c5d1997-08-27 14:08:22 +000057At the moment Python is built with a slightly modified version of GUSI,
Jack Jansene66b8c81997-05-29 14:57:07 +000058these 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 Jansen3412c5d1997-08-27 14:08:22 +0000124 MoreFiles 1.4.3 (not needed by Python, only by tcl/tk)
Jack Jansen8f2d8021996-08-05 15:34:45 +0000125 Python
Jack Jansen32617191997-08-19 14:01:16 +0000126 Tcl/Tk Folder
127 tcl8.0
128 tk8.0
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000129 Waste 1.2 distribution (if you want waste)
Jack Jansen8f2d8021996-08-05 15:34:45 +0000130</PRE>
131
Jack Jansen1473af71997-05-07 15:43:38 +0000132First build GUSI. If you didn't get the python-specific GUSI you have to
133move the files from the "CWGUSI-mods" to the right
Jack Jansen3412c5d1997-08-27 14:08:22 +0000134place in the CWGUSI distribution folder. Build the MSL version for your
135platform (ppc, 68k, cfm68k). <p>
Jack Jansen16e99c01996-09-07 17:11:26 +0000136
137Next, in
Jack Jansen1473af71997-05-07 15:43:38 +0000138<code>MoreFiles</code>, <code>libjpeg</code>, <code>pbmplus</code>,
139<code>zlib</code>, <code>libpng</code>, <code>gdbm</code>,
Jack Jansen3412c5d1997-08-27 14:08:22 +0000140and<code>libtiff</code> you build all projects. Sometimes the projects are in "mac"
Jack Jansen1473af71997-05-07 15:43:38 +0000141subfolders, sometimes they are in the main folder. Tcl/tk is a special
Jack Jansen27b10ec1996-08-23 15:44:18 +0000142case, see below. Of course, if you are only interested in one of
143static 68K, CFM68K or PPC you can skip building the other libraries.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000144
145<H2><A NAME="tcltk">Building Tcl/Tk</H2>
146
Jack Jansen3412c5d1997-08-27 14:08:22 +0000147You need to make some minor changes to the Tcl/Tk 8.0
148distribution. You should make the CW Pro projects (in the mac subfolders).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000149<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000150
Jack Jansen32617191997-08-19 14:01:16 +0000151<LI> There are no cfm68k targets. You make these by copying the 68k targets,
152setting the "68k target" to "cfm68k library" and changing the output filename,
153and changing the prefix
154header filename in the C/C++ settings panel to "MW_???HeaderCFM68K".
Jack Jansene66b8c81997-05-29 14:57:07 +0000155
Jack Jansen32617191997-08-19 14:01:16 +0000156<LI> I had to add Search.c (from MoreFiles) to the tcl library projects. I don't
157understand why this is, but it seemed to cure the problems I had.
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000158
159<LI> Note that if you use a different release of Tcl and Tk than the ones
160I have used you may have to adapt the Python <code>tkresources.rsrc</code> file.
161This is easiest done by building <code>SimpleTk</code> and copying the TEXT, ICON
162and CRSR resources from it to <code>tkresources.rsrc</code>. This allows
163the <code>_tkinter</code> module to work without an installed Tk/Tcl on your
164machine.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000165
Jack Jansen8f2d8021996-08-05 15:34:45 +0000166</UL>
167
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000168Build first the Tcl library, then
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000169SimpleTcl (test it by typing <code>ls -l</code> in the window you get)
170then the Tk library, then SimpleTk (which can again be tested with
171<code>ls -l</code>). If this all worked you are all set to try
Jack Jansen8f2d8021996-08-05 15:34:45 +0000172building Python.
173
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000174<H2>Building Waste</H2>
175
176You do not need to build the Waste libraries, as Python includes the
177source modules themselves. You have to make one modification,
178though. In file <code>ICCFMGlue.c</code> in folder <code>Minimal IC
179APIs</code>, add the following lines:
180
181<blockquote><pre><code>
182#include <Gestalt.h>
183#include <Errors.h>
184</code></pre></blockquote>
185
Jack Jansen8f2d8021996-08-05 15:34:45 +0000186<H2>The organization of the Python source tree</H2>
187
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000188Time for a short break, while we have a look at the organization of
189the Python source tree. At the top level, we find the following
190folders:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000191
192<DL>
Jack Jansen3412c5d1997-08-27 14:08:22 +0000193<DT> build.mac68k.stand
194<DD> This is where you build static 68K interpreters.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000195
Jack Jansen3412c5d1997-08-27 14:08:22 +0000196<DT> build.mac68k.shared
197<DD> This is where you build the CFM68K shared library, interpreter
198and applet framework.
199
200<DT> build.macppc.shared
201<DD> This is where you build the PPC shared library, interpreter and
202applet framework. You can also build the fat applet framework here.
203
204<DT> build.macppc.stand
205<DD> This is where you build a nonshared PPC interpreter (optional).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000206
207<DT> Demo
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000208<DD> Demo programs that are not Mac-specific. Some of these may not
209work, the file <code>README-Mac</code> has some details.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000210
211<DT> Extensions
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000212<DD> Extensions to the interpreter that are not Mac-specific. Contains
213only the <code>img</code> extension in this distribution. Extensions
214are <em>not</em> built here, as they are on Unix, but incorporated in
215the core interpreter or built as plugin modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000216
217<DT> Grammar
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000218<DD> The Python grammar. Included for reference only, you cannot build
219the parser on a Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000220
221<DT> Include
222<DD> Machine-independent header files.
223
224<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000225<DD> Machine-independent optional modules. Not all of these will work
226on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000227
228<DT> Objects
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000229<DD> Machine-independent code for various objects. Most of these are
230not really optional: the interpreter will not function without them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000231
232<DT> Parser
233<DD> The Python parser (machine-independent).
234
235<DT> PlugIns
Jack Jansen27b10ec1996-08-23 15:44:18 +0000236<DD> This is where you build the PPC and CFM68K dynamically-loaded plugin modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000237
238<DT> Python
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000239<DD> The core interpreter. Most files are machine-independent, some
240are unix-specific and not used on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000241
242<DT> Tools
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000243<DD> Tools for python developers. Contains <code>modulator</code>
244which builds skeleton C extension modules and <code>bgen</code> which
245generates complete interface modules from information in C header
246files. There are some readme files, but more documentation is sorely
247needed.
248
Jack Jansen8f2d8021996-08-05 15:34:45 +0000249</DL>
250
251All the mac-specific stuff lives in the <code>Mac</code> folder:
252<DL>
253
254<DT> Compat
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000255<DD> Unix-compatability routines. Some of these are not used anymore,
256since CWGUSI provides a rather complete emulation, but you may need
257these if you are trying to build a non-GUSI python.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000258
259<DT> Demo
260<DD> Mac-specific demo programs, some of them annotated.
261
262<DT> Include
263<DD> Mac-specific but compiler-independent include files.
264
265<DT> Lib
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000266<DD> Mac-specific standard modules. The <code>toolbox</code> folder
267contains modules specifically needed with various MacOS toolbox
268interface modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000269
270<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000271<DD> Mac-specific builtin modules. Theoretically these are all
272optional, but some are rather essential (like
273<code>macmodule</code>). A lot of these modules are generated with
274<code>bgen</code>, in which case the bgen input files are included so
275you can attempt to regenerate them or extend them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000276
277<DT> MPW
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000278<DD> MPW-specific files. These have not been used or kept up-to-date
279for a long time, so use at your own risk.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000280
281<DT> mwerks
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000282<DD> Mwerks-specific sources and headers. Contains glue code for
283Pythons shared-library architecture, a replacement for
284<code>malloc</code> and a directory with various projects for building
285variations on the Python interpreter. The <code>mwerks_*.h</code>
286files here are the option-setting files for the various interpreters
287and such, comparable to the unix command-line <code>-D</code> options
288to the compiler. Each project uses the correct option file as its
289"prefix file" in the "C/C++ language" settings. Disabling optional
290modules (for the 68K interpreter), building non-GUSI interpreters and
291various other things are accomplished by modifying these files (and
292possibly changing the list of files included in the project window, of
293course).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000294
295<DT> Python
296<DD> Mac-specific parts of the core interpreter.
297
298<DT> Resources
299<DD> Resource files needed to build the interpreter.
300
301<DT> Scripts
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000302<DD> A collection of various mac-specific Python scripts. Some are
303essential, some are useful but few are documented, so you will have to
304use your imagination to work them out.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000305
306<DT> Unsupported
307<DD> Modules that are not supported any longer but may still work with a little effort.
308</DL>
309
310<H2>Building the 68K interpreter</H2>
311
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000312If you have all the optional libraries mentioned <A
313HREF="#optional">above</A> loaded buildin Python for 68K macs is a
Jack Jansen3412c5d1997-08-27 14:08:22 +0000314breeze: open the project in the folder <code>build.macstand</code> and
315build the 68K target. Do <em>not</em> run it yet, this will possibly
316result in a garbled preferences file. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000317
Jack Jansen3412c5d1997-08-27 14:08:22 +0000318First remove the <code>Python XXX preferences</code> file from your
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000319preference folder, only if you had an older version of Python
320installed. (this is also what you do if you did not heed the last
321sentence of the preceeding paragraph). Next, move the interpreter to
322the main Python folder (up one level) and run it there. This will
323create a correct initial preferences file. You are now all set, and
324your tree should be completely compatible with a binary-only
325distribution. Read the release notes
326(<code>Relnotes-somethingorother</code>) and
Jack Jansen3412c5d1997-08-27 14:08:22 +0000327<code>ReadMe</code> in the <code>Mac</code> folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000328
Jack Jansen3412c5d1997-08-27 14:08:22 +0000329<H2>Building the PPC and CFM68K interpreter</H2>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000330
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000331First you build the interpreter, core library and applet skeleton in
Jack Jansen3412c5d1997-08-27 14:08:22 +0000332folder <code>build.mac</code>. The projects are all linked together, so
333building the fat targets in <code>Python.prj</code> and
334<code>PythonApplet.prj</code> will result in everything being built. The
335resulting applications and fat shared library are deposited in the main
336Python folder. For completeness sake here is a breakdown of the
337projects:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000338
339<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000340
Jack Jansen3412c5d1997-08-27 14:08:22 +0000341<DT> PythonCore (with subprojects PythonCorePPC and PythonCoreCFM68K)
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000342<DD> The shared library that contains the bulk of the interpreter and
343its resources. It is a good idea to immedeately put an alias to this
344shared library in the <code>Extensions</code> folder of your system
345folder. Do exactly that: put an <em>alias</em> there, copying or
Jack Jansen3412c5d1997-08-27 14:08:22 +0000346moving the file will cause you grief later if you rebuild the library and
347forget to copy it to the extensions folder again.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000348
Jack Jansen3412c5d1997-08-27 14:08:22 +0000349<DT> Python
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000350<DD> The interpreter. This is basically a routine to call out to the
Jack Jansen3412c5d1997-08-27 14:08:22 +0000351shared library. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000352
Jack Jansen061ac501996-10-22 15:27:56 +0000353<DT> PythonAppletPPC
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000354<DD> The applet skeleton application. Very similar to
355<code>PythonPPC</code>, but it calls to a different entrypoint in the
356core library. The <code>mkapplet</code> script will copy this complete
357file, and add a <code>'PYC '</code> with the module to generate an
358applet. <p>
359
Jack Jansen8f2d8021996-08-05 15:34:45 +0000360</DL>
361
Jack Jansen3412c5d1997-08-27 14:08:22 +0000362After creating the alias to <code>PythonCore</code> you remove any old
Jack Jansen061ac501996-10-22 15:27:56 +0000363<code>Python XXX Preferences</code> file from the <code>Preferences</code> folder
364(if you had python installed on your system before) and run the interpreter once
Jack Jansen3412c5d1997-08-27 14:08:22 +0000365to create the correct preferences file. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000366
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000367Next, you have to build the extension modules in the
Jack Jansen3412c5d1997-08-27 14:08:22 +0000368<code>PlugIns</code> folder. The <code>PlugIns.ppc</code> project has all the
369other projects as subprojects and builds everything. After all
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000370the dynamically loaded modules are built you have to create a number
371of aliases: some modules live together in a single dynamic
Jack Jansen3412c5d1997-08-27 14:08:22 +0000372library. Run the <code>ConfigurePython.py</code> script from
Jack Jansen27b10ec1996-08-23 15:44:18 +0000373<code>Mac:scripts</code> to create the aliases. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000374
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000375Finally, you must build the standard applets:
Jack Jansen3412c5d1997-08-27 14:08:22 +0000376<code>EditPythonPrefs</code>, <code>BuildApplet</code>, etc. This is
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000377easiest done with the <code>fullbuild</code> script from
Jack Jansen3412c5d1997-08-27 14:08:22 +0000378<code>Mac:scripts</code>. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000379
380<BLOCKQUOTE>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000381Actually, the <code>fullbuild</code> script can be used to build
382everything, but you need a fully-functional interpreter before you can
383use it (and one that isn't rebuilt in the process: you cannot rebuild
384a running program). You could copy the 68K interpreter to a different
385place and use that to run fullbuild, or use the standalone PPC python
386for this. I tend to keep a standalone interpreter in a safe place for
Jack Jansene66b8c81997-05-29 14:57:07 +0000387this use only. <p>
388
Jack Jansen8f2d8021996-08-05 15:34:45 +0000389</BLOCKQUOTE>
390
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000391You are all set now, and should read the release notes and
Jack Jansen3412c5d1997-08-27 14:08:22 +0000392<code>ReadMe</code> file from the <code>Mac</code> folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000393
Jack Jansen27b10ec1996-08-23 15:44:18 +0000394<H2>Rebuilding <code>.exp</code> files for PPC and CFM68K</H2>
395
396Occasionally it may be necessary to rebuild your PythonCore <code>.exp</code>
397file, a file that controls which symbols are exported by your PythonCore
398shared library. Rebuild it if you get unexpected undefined symbols when you
399are building a plugin module. <p>
400
401Rebuilding the .exp file is done by first removing the file and removing the
402reference to it in the project (in the "config" section). Next, build PythonCore.
403This will create a new .exp file. Edit this file to remove the references to
404the symbols <code>__initialize</code>, <code>__terminate</code>, <code>setjmp</code>,
Jack Jansen1473af71997-05-07 15:43:38 +0000405<code>longjmp</code>, <code>main</code> and (for PPC) <code>__ptmf_null</code> or (for
406CFM68K) <code>__start</code> and <code>dummy_init_routine</code>.
407Next, add the .exp file to the project
Jack Jansen27b10ec1996-08-23 15:44:18 +0000408again and rebuild PythonCore. <p>
409
410This rather convoluted procedure is needed to ensure that plugin modules don't
411accidentally link with those entrypoints from PythonCore, which will not work because
412those routines have to be in the same code fragment as they are used from.
413
Jack Jansen8f2d8021996-08-05 15:34:45 +0000414<H2>Odds and ends</H2>
415
416Some remarks that I could not fit in elsewhere:
417
418<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000419
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000420<LI> It may be possible to use the <code>PythonCore</code> shared
421library to embed Python in another program, if your program can live
Jack Jansen1473af71997-05-07 15:43:38 +0000422with using GUSI for I/O. Use PythonCore in stead of your MSL C library
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000423(or, at the very least, link it before the normal C library). Let me
424know whether this works.
425
426<LI> It is possible to build PPC extension modules without building a
427complete Python. Take the binary distribution, add folders
428<code>Include</code>, <code>Mac:Include</code> and
429<code>Mac:mwerks</code> from the source distribution and you should be
430all set. A template for a dynamic module can be found in
Jack Jansen3412c5d1997-08-27 14:08:22 +0000431<code>xx.prj</code>.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000432
433<LI> The Python shared library architecture is a variant of the architecture
434described as "application with shared libraries and dropins" in the MetroWerks
435"Targeting MacOS" documentation. The Python Application and applet-template use
Jack Jansen1473af71997-05-07 15:43:38 +0000436the <code>MSL AppRuntime.Lib</code> runtime library (with properly set CFM
437initialization and termination routines). PythonCore uses <code>MSL Runtime.Lib</code>,
438which is really intended for standalone programs but which we fool into working by
439providing a dummy main program.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000440It is linked statically into PythonCore (and exported to the applications and plugins)
441so we do not have to distribute yet another shared library. Plugin modules use
Jack Jansen1473af71997-05-07 15:43:38 +0000442<code>MSL ShlibRuntime.Lib</code> (not the dropin runtime: modules are never unloaded)
443and obtain the rest from PythonCore. PythonCore uses a
Jack Jansen27b10ec1996-08-23 15:44:18 +0000444non-standard initialization entry point, <code>__initialize_with_resources</code>, to
Jack Jansen1473af71997-05-07 15:43:38 +0000445be able to obtain resources from the library file later on. Plugins can do the same
446(_tkinter does) or use the standard <code>__initialize</code> entry point.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000447
448
Jack Jansen6ad8d131997-01-15 16:53:37 +0000449</UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000450</BODY>
451</HTML>