blob: 48bb135f4d489831b2597c021182325a86da9fd9 [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
Jack Jansenc256ece1999-02-03 13:09:27 +000011is also necessary if you want to make modifications to the Python core.
12Building Python is not something to be undertaken lightly,
13you need a reasonable working
Jack Jansen4c1e56c1996-08-06 16:16:20 +000014knowledge 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
Jack Jansenc256ece1999-02-03 13:09:27 +000021I am very interested in feedback on this document, send your
Jack Jansen4c1e56c1996-08-06 16:16:20 +000022comments to the <A
23HREF="http://www.python.org/sigs/pythonmac-sig/">Mac Python Special
24Interest Group</A>.
Jack Jansen8f2d8021996-08-05 15:34:45 +000025
26<H2>What you need.</H2>
27
28The following things you definitely need:
29
30<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000031
Jack Jansen4c1e56c1996-08-06 16:16:20 +000032<LI> You need a MacPython source distribution, of course. You can
Jack Jansen95375861999-03-10 15:51:56 +000033obtain one from <A HREF="ftp://ftp.cwi.nl/pub/jack/python/mac">
34ftp://ftp.cwi.nl/pub/jack/python/mac</A> or from the companion webpage
35at <A HREF="http://www.cwi.nl/~jack/macpython.html">
36http://www.cwi.nl/~jack/macpython.html</A> (which has up-to-date links
37to the other packages needed too) and possibly also from the standard
38<A HREF="ftp://ftp.python.org/pub/python/mac">python.org ftp
Jack Jansen4c1e56c1996-08-06 16:16:20 +000039site</A>. Everything you need is also included in the standard Python
40source distribution, but the organization is different. Look in
41directory <code>Mac/mwerks/projects</code> for the project files and
Jack Jansenc256ece1999-02-03 13:09:27 +000042related stuff. <BR>
43
Jack Jansen95375861999-03-10 15:51:56 +000044If you are a <a href="http://www.python.org/psa">PSA</a> member, an
45alternative is to check the sources straight out of the CVS
46repository, see below. Most of the packages mentioned here are also
47available through CVS. Check the section on <a href="#cvs">CVS
48repository use</a> below.
Jack Jansen8f2d8021996-08-05 15:34:45 +000049
Jack Jansen4c1e56c1996-08-06 16:16:20 +000050<LI> You need MetroWerks CodeWarrior. The current distribution has
Jack Jansenc256ece1999-02-03 13:09:27 +000051been built with CodeWarrior Pro 4. Ordering information is
Jack Jansen4c1e56c1996-08-06 16:16:20 +000052available on the <A HREF="http://www.metrowerks.com/">MetroWerks
Jack Jansena2139fe1998-02-25 15:40:35 +000053homepage</A>. Building Python with MPW or Think/Symantec C is
54probably impossible without major surgery.
Jack Jansen4c1e56c1996-08-06 16:16:20 +000055
56<LI> You need GUSI, the Grand Unified Socket Interface, by Matthias
Jack Jansen1473af71997-05-07 15:43:38 +000057Neeracher. The original CWGUSI is
Jack Jansen4c1e56c1996-08-06 16:16:20 +000058obtainable from <A
Jack Jansenf3dd5aa1996-12-23 17:29:51 +000059HREF="ftp://sunsite.cnlab-switch.ch/software/platform/macos/src">
Jack Jansene66b8c81997-05-29 14:57:07 +000060ftp://sunsite.cnlab-switch.ch/software/platform/macos/src</A>.
Jack Jansen3412c5d1997-08-27 14:08:22 +000061At the moment Python is built with a slightly modified version of GUSI,
Jack Jansena598bc41999-02-10 23:08:24 +000062these modifications are available in folder <code>Python:Mac:GUSI-mods</code>. <br>
63
64The modified GUSI is also in the MacPython cvs source repository, in the
65directory <code>lib-src/CWGUSI</code>. However, some files contain slashes in
66their names, something CVS seriously frowns upon, and each slash has been
67replaced by <code>"_s_"</code>. There is a script
68<code>Mac:scripts:fixgusidir.py</code> which you should run after checking CWGUSI
69out
Jack Jansen4c1e56c1996-08-06 16:16:20 +000070
Jack Jansen8f2d8021996-08-05 15:34:45 +000071</UL>
72
Jack Jansen4c1e56c1996-08-06 16:16:20 +000073<A NAME="optional">The MacPython project files are configured to
74include a plethora of optional modules</A>, and these modules need a
Jack Jansena2139fe1998-02-25 15:40:35 +000075number of extra packages. To use the project files as-is you have to
Jack Jansen27b10ec1996-08-23 15:44:18 +000076download these packages too. PPC and CFM68K Python have all such modules as
Jack Jansen4c1e56c1996-08-06 16:16:20 +000077dynamically loaded modules, so if you don't need a certain package it
Jack Jansen27b10ec1996-08-23 15:44:18 +000078suffices to just refrain from builing the extension module. For static 68K
Jack Jansen4c1e56c1996-08-06 16:16:20 +000079Python things are a bit more complicated: you have to edit the
80interpreter project file to remove the reference to the module (and
Jack Jansen27b10ec1996-08-23 15:44:18 +000081the libraries it uses), and edit the <code>Mac:mwerks:mwerks_nonshared_config.h</code>
82file to remove the <code>USE_...</code> line. Here are the locations for the various things
Jack Jansen4c1e56c1996-08-06 16:16:20 +000083you need:
Jack Jansen8f2d8021996-08-05 15:34:45 +000084
85<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000086
Jack Jansen4c1e56c1996-08-06 16:16:20 +000087<LI> Tcl and Tk can be obtained from <A
88HREF="ftp://ftp.smli.com/pub/tcl/mac/">ftp://ftp.smli.com/pub/tcl/mac/</A>.
Jack Jansen44a89311997-12-23 22:56:25 +000089The current distributions, Tcl 8.0p2 and Tk 8.0p2 need a bit of work,
Jack Jansen4c1e56c1996-08-06 16:16:20 +000090see the section on <A HREF="#tcltk">building Tcl/Tk Python</A>
91below. Get the "full source" distribution, which includes MoreFiles.
Jack Jansen8f2d8021996-08-05 15:34:45 +000092
Jack Jansen4c1e56c1996-08-06 16:16:20 +000093<LI> Waste, a TextEdit replacement written by Marco Piovanelli, <A
94HREF="mailto:piovanel@kagi.com">&lt;piovanel@kagi.com&gt;</A>. Python
Jack Jansena2139fe1998-02-25 15:40:35 +000095was built using version 1.3, which you can obtain from <A
96HREF="http://www.boingo.com/waste">&lt;http://www.boingo.com/waste&gt;</A>
Jack Jansen4c1e56c1996-08-06 16:16:20 +000097and various other places.
Jack Jansen8f2d8021996-08-05 15:34:45 +000098
Jack Jansen1473af71997-05-07 15:43:38 +000099<LI> Gdbm library for the Mac. Available from Jack's Mac software page at
100<A HREF="http://www.cwi.nl/~jack/macsoftware.html">
101http://www.cwi.nl/~jack/macsoftware.html</A> and <A HREF="ftp://ftp.cwi.nl/pub/jack/mac">
Jack Jansena598bc41999-02-10 23:08:24 +0000102ftp://ftp.cwi.nl/pub/jack/mac</A>. Also in the MacPython cvs repository at
103<code>lib-src/gdbm</code>.
Jack Jansen1473af71997-05-07 15:43:38 +0000104
105<LI> JPEG library by the Independent JPEG Group. A version including
106Mac projects can be found at Jack's page mentioned above.
107The most recent JPEG library can always be obtained from <A
Jack Jansena598bc41999-02-10 23:08:24 +0000108HREF="ftp://ftp.uu.net/graphics/jpeg/">ftp://ftp.uu.net/graphics/jpeg/</A>. Again,
109also in the MacPython cvs repository at <code>lib-src/jpeg</code>.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000110
Jack Jansen1473af71997-05-07 15:43:38 +0000111<LI> The netpbm/pbmplus, libtiff, zlib and png libraries. The netpbm distribution
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000112(which includes libtiff) is generally available on Internet ftp
113servers. For Python pbmplus, an older incarnation of netpbm, is
114functionally identical to netpbm, since Python only uses the library
115and not the complete applications. A distribution with correct
Jack Jansen1473af71997-05-07 15:43:38 +0000116projects and library source only is available from, you guessed it, Jack's Mac software
Jack Jansena598bc41999-02-10 23:08:24 +0000117page mentioned above. And, guessed it again, in the MacPython cvs repository
118at <code>lib-src/netpbm</code>, etc. The only gotcha is that libtiff lives in
119<code>lib-src/netpbm/libtiff</code>, for historical reasons.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000120
Jack Jansen8f2d8021996-08-05 15:34:45 +0000121</UL>
122
123<H2>Setting Up</H2>
124
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000125Now that you have collected everything you should start with building
Jack Jansen1473af71997-05-07 15:43:38 +0000126the various parts. If you don't want to fix
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000127access paths try to set things up as follows:
128
Jack Jansen8f2d8021996-08-05 15:34:45 +0000129<PRE>
130Top-level-folder:
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000131 CWGUSI
Jack Jansen8f2d8021996-08-05 15:34:45 +0000132 imglibs
Jack Jansende570301998-08-27 13:39:01 +0000133 jpeg
134 netpbm
135 libtiff
Jack Jansen1473af71997-05-07 15:43:38 +0000136 zlib
Jack Jansende570301998-08-27 13:39:01 +0000137 png
Jack Jansen1473af71997-05-07 15:43:38 +0000138 gdbm
Jack Jansen8f2d8021996-08-05 15:34:45 +0000139 Python
Jack Jansen32617191997-08-19 14:01:16 +0000140 Tcl/Tk Folder
141 tcl8.0
142 tk8.0
Jack Jansena2139fe1998-02-25 15:40:35 +0000143 MoreFiles 1.4.3
144 Waste 1.3 distribution (if you want waste)
Jack Jansen8f2d8021996-08-05 15:34:45 +0000145</PRE>
146
Jack Jansende570301998-08-27 13:39:01 +0000147If your setup of the libraries is exactly the same as mine (which is
148not very likely, unless you happen to work from the same CVS
149repository) you can use the project <code>buildlibs.prj</code> in the
Jack Jansenc256ece1999-02-03 13:09:27 +0000150<code>:Mac:build.mac</code> folder to build all needed libraries in one
Jack Jansende570301998-08-27 13:39:01 +0000151fell swoop, otherwise you will have to build the libraries one by
152one. <p>
153
Jack Jansen1473af71997-05-07 15:43:38 +0000154First build GUSI. If you didn't get the python-specific GUSI you have to
155move the files from the "CWGUSI-mods" to the right
Jack Jansen3412c5d1997-08-27 14:08:22 +0000156place in the CWGUSI distribution folder. Build the MSL version for your
157platform (ppc, 68k, cfm68k). <p>
Jack Jansen16e99c01996-09-07 17:11:26 +0000158
Jack Jansen95375861999-03-10 15:51:56 +0000159<em>Note:</em> always rebuild the CWGUSI libraries, even if you have
160checked them out from the CVS repository. <P>
161
Jack Jansen16e99c01996-09-07 17:11:26 +0000162Next, in
Jack Jansen1473af71997-05-07 15:43:38 +0000163<code>MoreFiles</code>, <code>libjpeg</code>, <code>pbmplus</code>,
164<code>zlib</code>, <code>libpng</code>, <code>gdbm</code>,
Jack Jansena2139fe1998-02-25 15:40:35 +0000165and<code>libtiff</code> you build all projects. Usually the projects are in "mac"
Jack Jansen1473af71997-05-07 15:43:38 +0000166subfolders, sometimes they are in the main folder. Tcl/tk is a special
Jack Jansen27b10ec1996-08-23 15:44:18 +0000167case, see below. Of course, if you are only interested in one of
168static 68K, CFM68K or PPC you can skip building the other libraries.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000169
170<H2><A NAME="tcltk">Building Tcl/Tk</H2>
171
Jack Jansen3412c5d1997-08-27 14:08:22 +0000172You need to make some minor changes to the Tcl/Tk 8.0
173distribution. You should make the CW Pro projects (in the mac subfolders).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000174<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000175
Jack Jansen32617191997-08-19 14:01:16 +0000176<LI> There are no cfm68k targets. You make these by copying the 68k targets,
177setting the "68k target" to "cfm68k library" and changing the output filename,
178and changing the prefix
179header filename in the C/C++ settings panel to "MW_???HeaderCFM68K".
Jack Jansene66b8c81997-05-29 14:57:07 +0000180
Jack Jansen32617191997-08-19 14:01:16 +0000181<LI> I had to add Search.c (from MoreFiles) to the tcl library projects. I don't
182understand why this is, but it seemed to cure the problems I had.
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000183
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
Jack Jansena2139fe1998-02-25 15:40:35 +0000202source modules themselves.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000203
Jack Jansen8f2d8021996-08-05 15:34:45 +0000204<H2>The organization of the Python source tree</H2>
205
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000206Time for a short break, while we have a look at the organization of
207the Python source tree. At the top level, we find the following
208folders:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000209
210<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000211<DT> Demo
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000212<DD> Demo programs that are not Mac-specific. Some of these may not
213work, the file <code>README-Mac</code> has some details.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000214
215<DT> Extensions
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000216<DD> Extensions to the interpreter that are not Mac-specific. Contains
Jack Jansena598bc41999-02-10 23:08:24 +0000217the <code>img</code>, <code>Imaging</code> and <code>Numeric</code> extensions
218in this distribution. Nowadays, the extensions are all built in their own
219folders (unlike in older distributions, where img was incorporated in the main
220build procedure).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000221
222<DT> Grammar
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000223<DD> The Python grammar. Included for reference only, you cannot build
224the parser on a Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000225
226<DT> Include
227<DD> Machine-independent header files.
228
229<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000230<DD> Machine-independent optional modules. Not all of these will work
231on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000232
233<DT> Objects
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000234<DD> Machine-independent code for various objects. Most of these are
235not really optional: the interpreter will not function without them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000236
237<DT> Parser
238<DD> The Python parser (machine-independent).
239
Jack Jansen8f2d8021996-08-05 15:34:45 +0000240<DT> Python
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000241<DD> The core interpreter. Most files are machine-independent, some
242are unix-specific and not used on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000243
244<DT> Tools
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000245<DD> Tools for python developers. Contains <code>modulator</code>
246which builds skeleton C extension modules and <code>bgen</code> which
247generates complete interface modules from information in C header
248files. There are some readme files, but more documentation is sorely
249needed.
250
Jack Jansen8f2d8021996-08-05 15:34:45 +0000251</DL>
252
253All the mac-specific stuff lives in the <code>Mac</code> folder:
254<DL>
Jack Jansenc256ece1999-02-03 13:09:27 +0000255<DT> Build
256<DD> This is where the project files live and where you build the
257libraries, shared libraries, executables and plugin modules. All the
258resulting binaries, except for intermedeate results, are deposited in
Jack Jansena598bc41999-02-10 23:08:24 +0000259the toplevel folder or the Mac:PlugIns folder (for plugin modules).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000260
261<DT> Compat
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000262<DD> Unix-compatability routines. Some of these are not used anymore,
263since CWGUSI provides a rather complete emulation, but you may need
264these if you are trying to build a non-GUSI python.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000265
266<DT> Demo
267<DD> Mac-specific demo programs, some of them annotated.
268
269<DT> Include
270<DD> Mac-specific but compiler-independent include files.
271
272<DT> Lib
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000273<DD> Mac-specific standard modules. The <code>toolbox</code> folder
274contains modules specifically needed with various MacOS toolbox
275interface modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000276
277<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000278<DD> Mac-specific builtin modules. Theoretically these are all
279optional, but some are rather essential (like
280<code>macmodule</code>). A lot of these modules are generated with
281<code>bgen</code>, in which case the bgen input files are included so
282you can attempt to regenerate them or extend them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000283
284<DT> MPW
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000285<DD> MPW-specific files. These have not been used or kept up-to-date
286for a long time, so use at your own risk.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000287
288<DT> mwerks
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000289<DD> Mwerks-specific sources and headers. Contains glue code for
290Pythons shared-library architecture, a replacement for
291<code>malloc</code> and a directory with various projects for building
292variations on the Python interpreter. The <code>mwerks_*.h</code>
293files here are the option-setting files for the various interpreters
294and such, comparable to the unix command-line <code>-D</code> options
295to the compiler. Each project uses the correct option file as its
296"prefix file" in the "C/C++ language" settings. Disabling optional
297modules (for the 68K interpreter), building non-GUSI interpreters and
298various other things are accomplished by modifying these files (and
299possibly changing the list of files included in the project window, of
300course).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000301
Jack Jansenc256ece1999-02-03 13:09:27 +0000302<DT> PlugIns
303<DD> This is where the PPC and CFM68K dynamically-loaded plugin modules live.
304
Jack Jansen8f2d8021996-08-05 15:34:45 +0000305<DT> Python
306<DD> Mac-specific parts of the core interpreter.
307
308<DT> Resources
309<DD> Resource files needed to build the interpreter.
310
311<DT> Scripts
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000312<DD> A collection of various mac-specific Python scripts. Some are
313essential, some are useful but few are documented, so you will have to
314use your imagination to work them out.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000315
Jack Jansenc256ece1999-02-03 13:09:27 +0000316<DT> Tools
317<DD> A collection of tools, usually bigger than those in the scripts
318folder. The important ones here are the IDE and macfreeze. The IDE is built
319with the buildIDE.py script, which puts the resulting applet in the toplevel
320folder. Macfreeze is usually invoked through the BuildApplication script,
321but for more control over the freezing process you can run the main script here.
322
323
Jack Jansen8f2d8021996-08-05 15:34:45 +0000324<DT> Unsupported
325<DD> Modules that are not supported any longer but may still work with a little effort.
326</DL>
327
328<H2>Building the 68K interpreter</H2>
329
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000330If you have all the optional libraries mentioned <A
Jack Jansenc256ece1999-02-03 13:09:27 +0000331HREF="#optional">above</A> loaded building Python for 68K macs is a
332breeze: in the Mac:Build folder you build the libraries with buildlibs.prj
333and then the interpreter with PythonStandalone.prj. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000334
Jack Jansenc256ece1999-02-03 13:09:27 +0000335If you were previously running another copy of this Python release,
336from a binary installer for instance, you should
337first remove the <code>Python XXX preferences</code> file from your
338preference folder. Next, run the interpreter, in the toplevel folder. This will
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000339create a correct initial preferences file. You are now all set, and
340your tree should be completely compatible with a binary-only
341distribution. Read the release notes
342(<code>Relnotes-somethingorother</code>) and
Jack Jansenc256ece1999-02-03 13:09:27 +0000343<code>ReadMe</code> in the <code>Mac</code> folder. <p>
344
345If something goes wrong you may end up with a garbled preferences file. Removing
346it from the system folder and running Python once again will re-create it.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000347
Jack Jansen3412c5d1997-08-27 14:08:22 +0000348<H2>Building the PPC and CFM68K interpreter</H2>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000349
Jack Jansenc256ece1999-02-03 13:09:27 +0000350First you optionally build the external libraries with buildlibs.prj. Next,
351the projects for
352interpreter, core library and applet skeleton are all linked together, so
Jack Jansen3b805261999-02-14 23:12:06 +0000353building the fat target in <code>PythonEngine.prj</code>
354will result in everything being built. The
Jack Jansen3412c5d1997-08-27 14:08:22 +0000355resulting applications and fat shared library are deposited in the main
Jack Jansenc256ece1999-02-03 13:09:27 +0000356Python folder. Finally, you build all the plugins with the plugins.prj project.
357
358For completeness sake here is a breakdown of the projects:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000359
360<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000361
Jack Jansen3412c5d1997-08-27 14:08:22 +0000362<DT> PythonCore (with subprojects PythonCorePPC and PythonCoreCFM68K)
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
Jack Jansen3412c5d1997-08-27 14:08:22 +0000367moving the file will cause you grief later if you rebuild the library and
Jack Jansenc256ece1999-02-03 13:09:27 +0000368forget to copy it to the extensions folder again. The InstallPython applet
369will also do this, along with creating the plugin aliases.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000370
Jack Jansen3b805261999-02-14 23:12:06 +0000371<DT> PythonInterpeter
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000372<DD> The interpreter. This is basically a routine to call out to the
Jack Jansen3b805261999-02-14 23:12:06 +0000373shared library. Unlike in previous releases the same program is used for
374creating applets (for which formerly PythonApplet was used). <p>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000375
Jack Jansenc256ece1999-02-03 13:09:27 +0000376<DT> Plugin projects
Jack Jansena598bc41999-02-10 23:08:24 +0000377<DD> Each plugin module has a separate project. The <code>Plugins.prj</code>
378project tries to build them all, but is known to be flakey under CW Pro 4.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000379</DL>
380
Jack Jansen3412c5d1997-08-27 14:08:22 +0000381After creating the alias to <code>PythonCore</code> you remove any old
Jack Jansen061ac501996-10-22 15:27:56 +0000382<code>Python XXX Preferences</code> file from the <code>Preferences</code> folder
383(if you had python installed on your system before) and run the interpreter once
Jack Jansen3412c5d1997-08-27 14:08:22 +0000384to create the correct preferences file. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000385
Jack Jansenc256ece1999-02-03 13:09:27 +0000386Next, you have to build the extension modules.
387The <code>PlugIns.ppc</code> project has all the
Jack Jansena598bc41999-02-10 23:08:24 +0000388other projects as subprojects and builds everything (but see the gotcha above).
389<p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000390
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000391Finally, you must build the standard applets:
Jack Jansen3412c5d1997-08-27 14:08:22 +0000392<code>EditPythonPrefs</code>, <code>BuildApplet</code>, etc. This is
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000393easiest done with the <code>fullbuild</code> script from
Jack Jansen3412c5d1997-08-27 14:08:22 +0000394<code>Mac:scripts</code>. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000395
396<BLOCKQUOTE>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000397Actually, the <code>fullbuild</code> script can be used to build
398everything, but you need a fully-functional interpreter before you can
399use it (and one that isn't rebuilt in the process: you cannot rebuild
400a running program). You could copy the 68K interpreter to a different
401place and use that to run fullbuild, or use the standalone PPC python
402for this. I tend to keep a standalone interpreter in a safe place for
Jack Jansene66b8c81997-05-29 14:57:07 +0000403this use only. <p>
404
Jack Jansen8f2d8021996-08-05 15:34:45 +0000405</BLOCKQUOTE>
406
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000407You are all set now, and should read the release notes and
Jack Jansen3412c5d1997-08-27 14:08:22 +0000408<code>ReadMe</code> file from the <code>Mac</code> folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000409
Jack Jansen27b10ec1996-08-23 15:44:18 +0000410<H2>Rebuilding <code>.exp</code> files for PPC and CFM68K</H2>
411
412Occasionally it may be necessary to rebuild your PythonCore <code>.exp</code>
413file, a file that controls which symbols are exported by your PythonCore
414shared library. Rebuild it if you get unexpected undefined symbols when you
415are building a plugin module. <p>
416
417Rebuilding the .exp file is done by first removing the file and removing the
418reference to it in the project (in the "config" section). Next, build PythonCore.
419This will create a new .exp file. Edit this file to remove the references to
420the symbols <code>__initialize</code>, <code>__terminate</code>, <code>setjmp</code>,
Jack Jansen1473af71997-05-07 15:43:38 +0000421<code>longjmp</code>, <code>main</code> and (for PPC) <code>__ptmf_null</code> or (for
422CFM68K) <code>__start</code> and <code>dummy_init_routine</code>.
423Next, add the .exp file to the project
Jack Jansen27b10ec1996-08-23 15:44:18 +0000424again and rebuild PythonCore. <p>
425
426This rather convoluted procedure is needed to ensure that plugin modules don't
427accidentally link with those entrypoints from PythonCore, which will not work because
428those routines have to be in the same code fragment as they are used from.
429
Jack Jansen95375861999-03-10 15:51:56 +0000430<H2><a name="cvs">Using the CVS source archive</a></H2>
Jack Jansenc256ece1999-02-03 13:09:27 +0000431
432It is possible to access the Python sources through remote CVS if you are
433a PSA member. The advantage of this is that you get the very latest sources,
434so any bug fixed or new features will be immedeately available. This is also
435the disadvantage, of course: as this is the same tree as is used for development it
436may sometimes be a little less stable. <p>
437
438The CVS client of choice is Alexandre Parenteau's MacCVS. It can be
439obtained through the <a href="http://www.cyclic.com">Cyclic CVS homepage</a>. MacCVS
440uses Internet Config to set file types correctly based on the filename extension. In
441the maccvs preferences you should also set (in the "binary files" section)
442"use mac encoding: applesingle" and (in the "text files" section) "use ISO latin 1
443conversion". <p>
444
Jack Jansen95375861999-03-10 15:51:56 +0000445The machine-independent Python sources are checked out from the main
446Python CVS archive, see the <a href="http://www.python.org/psa">PSA
447homepage</a> for details. When you check the sources out you will get
448something like <code>Python:dist:src</code>, and under that the
449<code>Modules</code>, <code>Lib</code>, etc hierarchy. The
450<code>src</code> folder should be renamed to <code>Python</code>, and
451is what this document refers to as the "toplevel Python folder". <P>
Jack Jansenc256ece1999-02-03 13:09:27 +0000452
Jack Jansen95375861999-03-10 15:51:56 +0000453Next, within the toplevel Python folder, you check out the
454mac-specific sources in a Mac folder. The CVS path to use can be found
455at the <a href="http://www.cwi.nl/~jack/macpython.html">MacPython
456homepage</a>. Finally, you check out the external libraries needed in
457the parent of the Python folder. The CVS path for these libraries is
458also mentioned at the MacPython homepage. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000459
Jack Jansen95375861999-03-10 15:51:56 +0000460Neither of the pages mentioned above contains the passwords for the
461CVS sites, for obvious reasons, but they do contain instructions on
462how to obtain the passwords. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000463
Jack Jansen8f2d8021996-08-05 15:34:45 +0000464<H2>Odds and ends</H2>
465
466Some remarks that I could not fit in elsewhere:
467
468<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000469
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000470<LI> It may be possible to use the <code>PythonCore</code> shared
471library to embed Python in another program, if your program can live
Jack Jansen1473af71997-05-07 15:43:38 +0000472with using GUSI for I/O. Use PythonCore in stead of your MSL C library
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000473(or, at the very least, link it before the normal C library). Let me
474know whether this works.
475
476<LI> It is possible to build PPC extension modules without building a
Jack Jansenc256ece1999-02-03 13:09:27 +0000477complete Python. The binary distribution installer can optionally install
478all the needed folders. A template for a dynamic module can be found in
Jack Jansen3412c5d1997-08-27 14:08:22 +0000479<code>xx.prj</code>.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000480
481<LI> The Python shared library architecture is a variant of the architecture
482described as "application with shared libraries and dropins" in the MetroWerks
483"Targeting MacOS" documentation. The Python Application and applet-template use
Jack Jansen1473af71997-05-07 15:43:38 +0000484the <code>MSL AppRuntime.Lib</code> runtime library (with properly set CFM
485initialization and termination routines). PythonCore uses <code>MSL Runtime.Lib</code>,
486which is really intended for standalone programs but which we fool into working by
487providing a dummy main program.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000488It is linked statically into PythonCore (and exported to the applications and plugins)
489so we do not have to distribute yet another shared library. Plugin modules use
Jack Jansen1473af71997-05-07 15:43:38 +0000490<code>MSL ShlibRuntime.Lib</code> (not the dropin runtime: modules are never unloaded)
491and obtain the rest from PythonCore. PythonCore uses a
Jack Jansen27b10ec1996-08-23 15:44:18 +0000492non-standard initialization entry point, <code>__initialize_with_resources</code>, to
Jack Jansen1473af71997-05-07 15:43:38 +0000493be able to obtain resources from the library file later on. Plugins can do the same
494(_tkinter does) or use the standard <code>__initialize</code> entry point.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000495
496
Jack Jansen6ad8d131997-01-15 16:53:37 +0000497</UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000498</BODY>
499</HTML>