blob: ee214e69d6d5833a23be52c4bb6ca5f3d84be8c1 [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
33obtain one from <A
Jack Jansen1473af71997-05-07 15:43:38 +000034HREF="ftp://ftp.cwi.nl/pub/jack/python/mac">ftp://ftp.cwi.nl/pub/jack/python/mac</A>
35or from the companion webpage at <A HREF="http://www.cwi.nl/~jack/macpython.html">
36http://www.cwi.nl/~jack/macpython.html</A> (which has up-to-date links to the other
37packages needed too)
Jack Jansen4c1e56c1996-08-06 16:16:20 +000038and possibly also from the standard <A
39HREF="ftp://ftp.python.org/pub/python/mac">python.org ftp
40site</A>. Everything you need is also included in the standard Python
41source distribution, but the organization is different. Look in
42directory <code>Mac/mwerks/projects</code> for the project files and
Jack Jansenc256ece1999-02-03 13:09:27 +000043related stuff. <BR>
44
45If you are a <a href="http://www.python.org/psa">PSA</a> member, an alternative
46is to check the sources straight out of the CVS repository,
47see below. Most of the packages mentioned here are also available through CVS.
Jack Jansen8f2d8021996-08-05 15:34:45 +000048
Jack Jansen4c1e56c1996-08-06 16:16:20 +000049<LI> You need MetroWerks CodeWarrior. The current distribution has
Jack Jansenc256ece1999-02-03 13:09:27 +000050been built with CodeWarrior Pro 4. Ordering information is
Jack Jansen4c1e56c1996-08-06 16:16:20 +000051available on the <A HREF="http://www.metrowerks.com/">MetroWerks
Jack Jansena2139fe1998-02-25 15:40:35 +000052homepage</A>. Building Python with MPW or Think/Symantec C is
53probably impossible without major surgery.
Jack Jansen4c1e56c1996-08-06 16:16:20 +000054
55<LI> You need GUSI, the Grand Unified Socket Interface, by Matthias
Jack Jansen1473af71997-05-07 15:43:38 +000056Neeracher. The original CWGUSI is
Jack Jansen4c1e56c1996-08-06 16:16:20 +000057obtainable from <A
Jack Jansenf3dd5aa1996-12-23 17:29:51 +000058HREF="ftp://sunsite.cnlab-switch.ch/software/platform/macos/src">
Jack Jansene66b8c81997-05-29 14:57:07 +000059ftp://sunsite.cnlab-switch.ch/software/platform/macos/src</A>.
Jack Jansen3412c5d1997-08-27 14:08:22 +000060At the moment Python is built with a slightly modified version of GUSI,
Jack Jansena598bc41999-02-10 23:08:24 +000061these modifications are available in folder <code>Python:Mac:GUSI-mods</code>. <br>
62
63The modified GUSI is also in the MacPython cvs source repository, in the
64directory <code>lib-src/CWGUSI</code>. However, some files contain slashes in
65their names, something CVS seriously frowns upon, and each slash has been
66replaced by <code>"_s_"</code>. There is a script
67<code>Mac:scripts:fixgusidir.py</code> which you should run after checking CWGUSI
68out
Jack Jansen4c1e56c1996-08-06 16:16:20 +000069
Jack Jansen8f2d8021996-08-05 15:34:45 +000070</UL>
71
Jack Jansen4c1e56c1996-08-06 16:16:20 +000072<A NAME="optional">The MacPython project files are configured to
73include a plethora of optional modules</A>, and these modules need a
Jack Jansena2139fe1998-02-25 15:40:35 +000074number of extra packages. To use the project files as-is you have to
Jack Jansen27b10ec1996-08-23 15:44:18 +000075download these packages too. PPC and CFM68K Python have all such modules as
Jack Jansen4c1e56c1996-08-06 16:16:20 +000076dynamically loaded modules, so if you don't need a certain package it
Jack Jansen27b10ec1996-08-23 15:44:18 +000077suffices to just refrain from builing the extension module. For static 68K
Jack Jansen4c1e56c1996-08-06 16:16:20 +000078Python things are a bit more complicated: you have to edit the
79interpreter project file to remove the reference to the module (and
Jack Jansen27b10ec1996-08-23 15:44:18 +000080the libraries it uses), and edit the <code>Mac:mwerks:mwerks_nonshared_config.h</code>
81file to remove the <code>USE_...</code> line. Here are the locations for the various things
Jack Jansen4c1e56c1996-08-06 16:16:20 +000082you need:
Jack Jansen8f2d8021996-08-05 15:34:45 +000083
84<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000085
Jack Jansen4c1e56c1996-08-06 16:16:20 +000086<LI> Tcl and Tk can be obtained from <A
87HREF="ftp://ftp.smli.com/pub/tcl/mac/">ftp://ftp.smli.com/pub/tcl/mac/</A>.
Jack Jansen44a89311997-12-23 22:56:25 +000088The current distributions, Tcl 8.0p2 and Tk 8.0p2 need a bit of work,
Jack Jansen4c1e56c1996-08-06 16:16:20 +000089see the section on <A HREF="#tcltk">building Tcl/Tk Python</A>
90below. Get the "full source" distribution, which includes MoreFiles.
Jack Jansen8f2d8021996-08-05 15:34:45 +000091
Jack Jansen4c1e56c1996-08-06 16:16:20 +000092<LI> Waste, a TextEdit replacement written by Marco Piovanelli, <A
93HREF="mailto:piovanel@kagi.com">&lt;piovanel@kagi.com&gt;</A>. Python
Jack Jansena2139fe1998-02-25 15:40:35 +000094was built using version 1.3, which you can obtain from <A
95HREF="http://www.boingo.com/waste">&lt;http://www.boingo.com/waste&gt;</A>
Jack Jansen4c1e56c1996-08-06 16:16:20 +000096and various other places.
Jack Jansen8f2d8021996-08-05 15:34:45 +000097
Jack Jansen1473af71997-05-07 15:43:38 +000098<LI> Gdbm library for the Mac. Available from Jack's Mac software page at
99<A HREF="http://www.cwi.nl/~jack/macsoftware.html">
100http://www.cwi.nl/~jack/macsoftware.html</A> and <A HREF="ftp://ftp.cwi.nl/pub/jack/mac">
Jack Jansena598bc41999-02-10 23:08:24 +0000101ftp://ftp.cwi.nl/pub/jack/mac</A>. Also in the MacPython cvs repository at
102<code>lib-src/gdbm</code>.
Jack Jansen1473af71997-05-07 15:43:38 +0000103
104<LI> JPEG library by the Independent JPEG Group. A version including
105Mac projects can be found at Jack's page mentioned above.
106The most recent JPEG library can always be obtained from <A
Jack Jansena598bc41999-02-10 23:08:24 +0000107HREF="ftp://ftp.uu.net/graphics/jpeg/">ftp://ftp.uu.net/graphics/jpeg/</A>. Again,
108also in the MacPython cvs repository at <code>lib-src/jpeg</code>.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000109
Jack Jansen1473af71997-05-07 15:43:38 +0000110<LI> The netpbm/pbmplus, libtiff, zlib and png libraries. The netpbm distribution
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000111(which includes libtiff) is generally available on Internet ftp
112servers. For Python pbmplus, an older incarnation of netpbm, is
113functionally identical to netpbm, since Python only uses the library
114and not the complete applications. A distribution with correct
Jack Jansen1473af71997-05-07 15:43:38 +0000115projects and library source only is available from, you guessed it, Jack's Mac software
Jack Jansena598bc41999-02-10 23:08:24 +0000116page mentioned above. And, guessed it again, in the MacPython cvs repository
117at <code>lib-src/netpbm</code>, etc. The only gotcha is that libtiff lives in
118<code>lib-src/netpbm/libtiff</code>, for historical reasons.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000119
Jack Jansen8f2d8021996-08-05 15:34:45 +0000120</UL>
121
122<H2>Setting Up</H2>
123
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000124Now that you have collected everything you should start with building
Jack Jansen1473af71997-05-07 15:43:38 +0000125the various parts. If you don't want to fix
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000126access paths try to set things up as follows:
127
Jack Jansen8f2d8021996-08-05 15:34:45 +0000128<PRE>
129Top-level-folder:
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000130 CWGUSI
Jack Jansen8f2d8021996-08-05 15:34:45 +0000131 imglibs
Jack Jansende570301998-08-27 13:39:01 +0000132 jpeg
133 netpbm
134 libtiff
Jack Jansen1473af71997-05-07 15:43:38 +0000135 zlib
Jack Jansende570301998-08-27 13:39:01 +0000136 png
Jack Jansen1473af71997-05-07 15:43:38 +0000137 gdbm
Jack Jansen8f2d8021996-08-05 15:34:45 +0000138 Python
Jack Jansen32617191997-08-19 14:01:16 +0000139 Tcl/Tk Folder
140 tcl8.0
141 tk8.0
Jack Jansena2139fe1998-02-25 15:40:35 +0000142 MoreFiles 1.4.3
143 Waste 1.3 distribution (if you want waste)
Jack Jansen8f2d8021996-08-05 15:34:45 +0000144</PRE>
145
Jack Jansende570301998-08-27 13:39:01 +0000146If your setup of the libraries is exactly the same as mine (which is
147not very likely, unless you happen to work from the same CVS
148repository) you can use the project <code>buildlibs.prj</code> in the
Jack Jansenc256ece1999-02-03 13:09:27 +0000149<code>:Mac:build.mac</code> folder to build all needed libraries in one
Jack Jansende570301998-08-27 13:39:01 +0000150fell swoop, otherwise you will have to build the libraries one by
151one. <p>
152
Jack Jansen1473af71997-05-07 15:43:38 +0000153First build GUSI. If you didn't get the python-specific GUSI you have to
154move the files from the "CWGUSI-mods" to the right
Jack Jansen3412c5d1997-08-27 14:08:22 +0000155place in the CWGUSI distribution folder. Build the MSL version for your
156platform (ppc, 68k, cfm68k). <p>
Jack Jansen16e99c01996-09-07 17:11:26 +0000157
158Next, in
Jack Jansen1473af71997-05-07 15:43:38 +0000159<code>MoreFiles</code>, <code>libjpeg</code>, <code>pbmplus</code>,
160<code>zlib</code>, <code>libpng</code>, <code>gdbm</code>,
Jack Jansena2139fe1998-02-25 15:40:35 +0000161and<code>libtiff</code> you build all projects. Usually the projects are in "mac"
Jack Jansen1473af71997-05-07 15:43:38 +0000162subfolders, sometimes they are in the main folder. Tcl/tk is a special
Jack Jansen27b10ec1996-08-23 15:44:18 +0000163case, see below. Of course, if you are only interested in one of
164static 68K, CFM68K or PPC you can skip building the other libraries.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000165
166<H2><A NAME="tcltk">Building Tcl/Tk</H2>
167
Jack Jansen3412c5d1997-08-27 14:08:22 +0000168You need to make some minor changes to the Tcl/Tk 8.0
169distribution. You should make the CW Pro projects (in the mac subfolders).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000170<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000171
Jack Jansen32617191997-08-19 14:01:16 +0000172<LI> There are no cfm68k targets. You make these by copying the 68k targets,
173setting the "68k target" to "cfm68k library" and changing the output filename,
174and changing the prefix
175header filename in the C/C++ settings panel to "MW_???HeaderCFM68K".
Jack Jansene66b8c81997-05-29 14:57:07 +0000176
Jack Jansen32617191997-08-19 14:01:16 +0000177<LI> I had to add Search.c (from MoreFiles) to the tcl library projects. I don't
178understand why this is, but it seemed to cure the problems I had.
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000179
180<LI> Note that if you use a different release of Tcl and Tk than the ones
181I have used you may have to adapt the Python <code>tkresources.rsrc</code> file.
182This is easiest done by building <code>SimpleTk</code> and copying the TEXT, ICON
183and CRSR resources from it to <code>tkresources.rsrc</code>. This allows
184the <code>_tkinter</code> module to work without an installed Tk/Tcl on your
185machine.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000186
Jack Jansen8f2d8021996-08-05 15:34:45 +0000187</UL>
188
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000189Build first the Tcl library, then
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000190SimpleTcl (test it by typing <code>ls -l</code> in the window you get)
191then the Tk library, then SimpleTk (which can again be tested with
192<code>ls -l</code>). If this all worked you are all set to try
Jack Jansen8f2d8021996-08-05 15:34:45 +0000193building Python.
194
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000195<H2>Building Waste</H2>
196
197You do not need to build the Waste libraries, as Python includes the
Jack Jansena2139fe1998-02-25 15:40:35 +0000198source modules themselves.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000199
Jack Jansen8f2d8021996-08-05 15:34:45 +0000200<H2>The organization of the Python source tree</H2>
201
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000202Time for a short break, while we have a look at the organization of
203the Python source tree. At the top level, we find the following
204folders:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000205
206<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000207<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
Jack Jansena598bc41999-02-10 23:08:24 +0000213the <code>img</code>, <code>Imaging</code> and <code>Numeric</code> extensions
214in this distribution. Nowadays, the extensions are all built in their own
215folders (unlike in older distributions, where img was incorporated in the main
216build procedure).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000217
218<DT> Grammar
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000219<DD> The Python grammar. Included for reference only, you cannot build
220the parser on a Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000221
222<DT> Include
223<DD> Machine-independent header files.
224
225<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000226<DD> Machine-independent optional modules. Not all of these will work
227on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000228
229<DT> Objects
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000230<DD> Machine-independent code for various objects. Most of these are
231not really optional: the interpreter will not function without them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000232
233<DT> Parser
234<DD> The Python parser (machine-independent).
235
Jack Jansen8f2d8021996-08-05 15:34:45 +0000236<DT> Python
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000237<DD> The core interpreter. Most files are machine-independent, some
238are unix-specific and not used on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000239
240<DT> Tools
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000241<DD> Tools for python developers. Contains <code>modulator</code>
242which builds skeleton C extension modules and <code>bgen</code> which
243generates complete interface modules from information in C header
244files. There are some readme files, but more documentation is sorely
245needed.
246
Jack Jansen8f2d8021996-08-05 15:34:45 +0000247</DL>
248
249All the mac-specific stuff lives in the <code>Mac</code> folder:
250<DL>
Jack Jansenc256ece1999-02-03 13:09:27 +0000251<DT> Build
252<DD> This is where the project files live and where you build the
253libraries, shared libraries, executables and plugin modules. All the
254resulting binaries, except for intermedeate results, are deposited in
Jack Jansena598bc41999-02-10 23:08:24 +0000255the toplevel folder or the Mac:PlugIns folder (for plugin modules).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000256
257<DT> Compat
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000258<DD> Unix-compatability routines. Some of these are not used anymore,
259since CWGUSI provides a rather complete emulation, but you may need
260these if you are trying to build a non-GUSI python.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000261
262<DT> Demo
263<DD> Mac-specific demo programs, some of them annotated.
264
265<DT> Include
266<DD> Mac-specific but compiler-independent include files.
267
268<DT> Lib
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000269<DD> Mac-specific standard modules. The <code>toolbox</code> folder
270contains modules specifically needed with various MacOS toolbox
271interface modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000272
273<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000274<DD> Mac-specific builtin modules. Theoretically these are all
275optional, but some are rather essential (like
276<code>macmodule</code>). A lot of these modules are generated with
277<code>bgen</code>, in which case the bgen input files are included so
278you can attempt to regenerate them or extend them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000279
280<DT> MPW
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000281<DD> MPW-specific files. These have not been used or kept up-to-date
282for a long time, so use at your own risk.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000283
284<DT> mwerks
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000285<DD> Mwerks-specific sources and headers. Contains glue code for
286Pythons shared-library architecture, a replacement for
287<code>malloc</code> and a directory with various projects for building
288variations on the Python interpreter. The <code>mwerks_*.h</code>
289files here are the option-setting files for the various interpreters
290and such, comparable to the unix command-line <code>-D</code> options
291to the compiler. Each project uses the correct option file as its
292"prefix file" in the "C/C++ language" settings. Disabling optional
293modules (for the 68K interpreter), building non-GUSI interpreters and
294various other things are accomplished by modifying these files (and
295possibly changing the list of files included in the project window, of
296course).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000297
Jack Jansenc256ece1999-02-03 13:09:27 +0000298<DT> PlugIns
299<DD> This is where the PPC and CFM68K dynamically-loaded plugin modules live.
300
Jack Jansen8f2d8021996-08-05 15:34:45 +0000301<DT> Python
302<DD> Mac-specific parts of the core interpreter.
303
304<DT> Resources
305<DD> Resource files needed to build the interpreter.
306
307<DT> Scripts
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000308<DD> A collection of various mac-specific Python scripts. Some are
309essential, some are useful but few are documented, so you will have to
310use your imagination to work them out.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000311
Jack Jansenc256ece1999-02-03 13:09:27 +0000312<DT> Tools
313<DD> A collection of tools, usually bigger than those in the scripts
314folder. The important ones here are the IDE and macfreeze. The IDE is built
315with the buildIDE.py script, which puts the resulting applet in the toplevel
316folder. Macfreeze is usually invoked through the BuildApplication script,
317but for more control over the freezing process you can run the main script here.
318
319
Jack Jansen8f2d8021996-08-05 15:34:45 +0000320<DT> Unsupported
321<DD> Modules that are not supported any longer but may still work with a little effort.
322</DL>
323
324<H2>Building the 68K interpreter</H2>
325
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000326If you have all the optional libraries mentioned <A
Jack Jansenc256ece1999-02-03 13:09:27 +0000327HREF="#optional">above</A> loaded building Python for 68K macs is a
328breeze: in the Mac:Build folder you build the libraries with buildlibs.prj
329and then the interpreter with PythonStandalone.prj. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000330
Jack Jansenc256ece1999-02-03 13:09:27 +0000331If you were previously running another copy of this Python release,
332from a binary installer for instance, you should
333first remove the <code>Python XXX preferences</code> file from your
334preference folder. Next, run the interpreter, in the toplevel folder. This will
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000335create a correct initial preferences file. You are now all set, and
336your tree should be completely compatible with a binary-only
337distribution. Read the release notes
338(<code>Relnotes-somethingorother</code>) and
Jack Jansenc256ece1999-02-03 13:09:27 +0000339<code>ReadMe</code> in the <code>Mac</code> folder. <p>
340
341If something goes wrong you may end up with a garbled preferences file. Removing
342it from the system folder and running Python once again will re-create it.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000343
Jack Jansen3412c5d1997-08-27 14:08:22 +0000344<H2>Building the PPC and CFM68K interpreter</H2>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000345
Jack Jansenc256ece1999-02-03 13:09:27 +0000346First you optionally build the external libraries with buildlibs.prj. Next,
347the projects for
348interpreter, core library and applet skeleton are all linked together, so
Jack Jansen3b805261999-02-14 23:12:06 +0000349building the fat target in <code>PythonEngine.prj</code>
350will result in everything being built. The
Jack Jansen3412c5d1997-08-27 14:08:22 +0000351resulting applications and fat shared library are deposited in the main
Jack Jansenc256ece1999-02-03 13:09:27 +0000352Python folder. Finally, you build all the plugins with the plugins.prj project.
353
354For completeness sake here is a breakdown of the projects:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000355
356<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000357
Jack Jansen3412c5d1997-08-27 14:08:22 +0000358<DT> PythonCore (with subprojects PythonCorePPC and PythonCoreCFM68K)
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000359<DD> The shared library that contains the bulk of the interpreter and
360its resources. It is a good idea to immedeately put an alias to this
361shared library in the <code>Extensions</code> folder of your system
362folder. Do exactly that: put an <em>alias</em> there, copying or
Jack Jansen3412c5d1997-08-27 14:08:22 +0000363moving the file will cause you grief later if you rebuild the library and
Jack Jansenc256ece1999-02-03 13:09:27 +0000364forget to copy it to the extensions folder again. The InstallPython applet
365will also do this, along with creating the plugin aliases.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000366
Jack Jansen3b805261999-02-14 23:12:06 +0000367<DT> PythonInterpeter
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000368<DD> The interpreter. This is basically a routine to call out to the
Jack Jansen3b805261999-02-14 23:12:06 +0000369shared library. Unlike in previous releases the same program is used for
370creating applets (for which formerly PythonApplet was used). <p>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000371
Jack Jansenc256ece1999-02-03 13:09:27 +0000372<DT> Plugin projects
Jack Jansena598bc41999-02-10 23:08:24 +0000373<DD> Each plugin module has a separate project. The <code>Plugins.prj</code>
374project tries to build them all, but is known to be flakey under CW Pro 4.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000375</DL>
376
Jack Jansen3412c5d1997-08-27 14:08:22 +0000377After creating the alias to <code>PythonCore</code> you remove any old
Jack Jansen061ac501996-10-22 15:27:56 +0000378<code>Python XXX Preferences</code> file from the <code>Preferences</code> folder
379(if you had python installed on your system before) and run the interpreter once
Jack Jansen3412c5d1997-08-27 14:08:22 +0000380to create the correct preferences file. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000381
Jack Jansenc256ece1999-02-03 13:09:27 +0000382Next, you have to build the extension modules.
383The <code>PlugIns.ppc</code> project has all the
Jack Jansena598bc41999-02-10 23:08:24 +0000384other projects as subprojects and builds everything (but see the gotcha above).
385<p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000386
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000387Finally, you must build the standard applets:
Jack Jansen3412c5d1997-08-27 14:08:22 +0000388<code>EditPythonPrefs</code>, <code>BuildApplet</code>, etc. This is
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000389easiest done with the <code>fullbuild</code> script from
Jack Jansen3412c5d1997-08-27 14:08:22 +0000390<code>Mac:scripts</code>. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000391
392<BLOCKQUOTE>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000393Actually, the <code>fullbuild</code> script can be used to build
394everything, but you need a fully-functional interpreter before you can
395use it (and one that isn't rebuilt in the process: you cannot rebuild
396a running program). You could copy the 68K interpreter to a different
397place and use that to run fullbuild, or use the standalone PPC python
398for this. I tend to keep a standalone interpreter in a safe place for
Jack Jansene66b8c81997-05-29 14:57:07 +0000399this use only. <p>
400
Jack Jansen8f2d8021996-08-05 15:34:45 +0000401</BLOCKQUOTE>
402
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000403You are all set now, and should read the release notes and
Jack Jansen3412c5d1997-08-27 14:08:22 +0000404<code>ReadMe</code> file from the <code>Mac</code> folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000405
Jack Jansen27b10ec1996-08-23 15:44:18 +0000406<H2>Rebuilding <code>.exp</code> files for PPC and CFM68K</H2>
407
408Occasionally it may be necessary to rebuild your PythonCore <code>.exp</code>
409file, a file that controls which symbols are exported by your PythonCore
410shared library. Rebuild it if you get unexpected undefined symbols when you
411are building a plugin module. <p>
412
413Rebuilding the .exp file is done by first removing the file and removing the
414reference to it in the project (in the "config" section). Next, build PythonCore.
415This will create a new .exp file. Edit this file to remove the references to
416the symbols <code>__initialize</code>, <code>__terminate</code>, <code>setjmp</code>,
Jack Jansen1473af71997-05-07 15:43:38 +0000417<code>longjmp</code>, <code>main</code> and (for PPC) <code>__ptmf_null</code> or (for
418CFM68K) <code>__start</code> and <code>dummy_init_routine</code>.
419Next, add the .exp file to the project
Jack Jansen27b10ec1996-08-23 15:44:18 +0000420again and rebuild PythonCore. <p>
421
422This rather convoluted procedure is needed to ensure that plugin modules don't
423accidentally link with those entrypoints from PythonCore, which will not work because
424those routines have to be in the same code fragment as they are used from.
425
Jack Jansenc256ece1999-02-03 13:09:27 +0000426<H2>Using the CVS source archive</H2>
427
428It is possible to access the Python sources through remote CVS if you are
429a PSA member. The advantage of this is that you get the very latest sources,
430so any bug fixed or new features will be immedeately available. This is also
431the disadvantage, of course: as this is the same tree as is used for development it
432may sometimes be a little less stable. <p>
433
434The CVS client of choice is Alexandre Parenteau's MacCVS. It can be
435obtained through the <a href="http://www.cyclic.com">Cyclic CVS homepage</a>. MacCVS
436uses Internet Config to set file types correctly based on the filename extension. In
437the maccvs preferences you should also set (in the "binary files" section)
438"use mac encoding: applesingle" and (in the "text files" section) "use ISO latin 1
439conversion". <p>
440
441The machine-independent Python sources are checked out from the main Python
442CVS archive, see the <a href="http://www.python.org/psa">PSA homepage</a> for
443details. <p>
444
445Next, within the toplevel Python folder, you check out the mac-specific sources
446in a Mac folder. The CVS path to use can be found at the
447<a href="http://www.cwi.nl/~jack/macpython.html">MacPython homepage</a>. Finally,
448you check out the external libraries needed in the parent of the Python folder. The
449CVS path for these libraries is also mentioned at the MacPython homepage. <p>
450
451Neither of the pages mentioned above contains the passwords for the CVS sites,
452for obvious reasons, but they do contain instructions on how to obtain the passwords. <p>
453
Jack Jansen8f2d8021996-08-05 15:34:45 +0000454<H2>Odds and ends</H2>
455
456Some remarks that I could not fit in elsewhere:
457
458<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000459
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000460<LI> It may be possible to use the <code>PythonCore</code> shared
461library to embed Python in another program, if your program can live
Jack Jansen1473af71997-05-07 15:43:38 +0000462with using GUSI for I/O. Use PythonCore in stead of your MSL C library
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000463(or, at the very least, link it before the normal C library). Let me
464know whether this works.
465
466<LI> It is possible to build PPC extension modules without building a
Jack Jansenc256ece1999-02-03 13:09:27 +0000467complete Python. The binary distribution installer can optionally install
468all the needed folders. A template for a dynamic module can be found in
Jack Jansen3412c5d1997-08-27 14:08:22 +0000469<code>xx.prj</code>.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000470
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>