blob: a24b86eace4caf7318d4e2a896745707fed949e2 [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
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000010necessary if you want to make modifications to the Python core. Building
11Python is not something to be undertaken lightly, you need a reasonable
12working knowledge of the CodeWarrior development environment, a good net
Jack Jansen4c1e56c1996-08-06 16:16:20 +000013connection and probably quite some time too. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +000014
Jack Jansen4c1e56c1996-08-06 16:16:20 +000015The information density in this file is high, so you should probably
16print it and read it at your leasure. Most things are explained only
17once (and probably in the wrong place:-). <p>
18
Jack Jansen90cf4912000-02-11 23:14:46 +000019<blockquote>
20First a warning: this information may become outdated if a new CodeWarrior is
21released after MacPython. The
22<a href="http://www.cwi.nl/~jack/macpython.html">MacPython homepage</a> will
23hopefully have updated instructions in that case.
24</blockquote>
25
Jack Jansenc256ece1999-02-03 13:09:27 +000026I am very interested in feedback on this document, send your
Jack Jansen4c1e56c1996-08-06 16:16:20 +000027comments to the <A
28HREF="http://www.python.org/sigs/pythonmac-sig/">Mac Python Special
29Interest Group</A>.
Jack Jansen8f2d8021996-08-05 15:34:45 +000030
31<H2>What you need.</H2>
32
33The following things you definitely need:
34
35<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000036
Jack Jansen4c1e56c1996-08-06 16:16:20 +000037<LI> You need a MacPython source distribution, of course. You can
Jack Jansen95375861999-03-10 15:51:56 +000038obtain one from <A HREF="ftp://ftp.cwi.nl/pub/jack/python/mac">
39ftp://ftp.cwi.nl/pub/jack/python/mac</A> or from the companion webpage
40at <A HREF="http://www.cwi.nl/~jack/macpython.html">
41http://www.cwi.nl/~jack/macpython.html</A> (which has up-to-date links
42to the other packages needed too) and possibly also from the standard
43<A HREF="ftp://ftp.python.org/pub/python/mac">python.org ftp
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000044site</A>. <BR>
Jack Jansenc256ece1999-02-03 13:09:27 +000045
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000046A better alternative is to check the sources straight out of the CVS
Jack Jansen95375861999-03-10 15:51:56 +000047repository, see below. Most of the packages mentioned here are also
48available through CVS. Check the section on <a href="#cvs">CVS
49repository use</a> below.
Jack Jansen8f2d8021996-08-05 15:34:45 +000050
Jack Jansen4c1e56c1996-08-06 16:16:20 +000051<LI> You need MetroWerks CodeWarrior. The current distribution has
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000052been built with CodeWarrior Pro 5.2. Ordering information is
Jack Jansen4c1e56c1996-08-06 16:16:20 +000053available on the <A HREF="http://www.metrowerks.com/">MetroWerks
Jack Jansena2139fe1998-02-25 15:40:35 +000054homepage</A>. Building Python with MPW or Think/Symantec C is
55probably impossible without major surgery.
Jack Jansen4c1e56c1996-08-06 16:16:20 +000056
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000057<LI> You need GUSI version 2, the Grand Unified Socket Interface, by
58Matthias Neeracher. The original GUSI is obtainable from <A
Jack Jansen5f884c02000-12-12 22:14:14 +000059HREF="ftp://gusi.sourceforge.net/pub/gusi/">
60ftp://gusi.sourceforge.net/pub/gusi/</A>. At
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000061the moment Python is built with a slightly modified version of GUSI
622.1.1, so it may be better to check the <A
63HREF="http://www.cwi.nl/~jack/macpython.html">MacPython homepage</A>
64for a GUSI that is most easily used for building Python.
65<br>
Jack Jansena598bc41999-02-10 23:08:24 +000066
67The modified GUSI is also in the MacPython cvs source repository, in the
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000068directory <code>lib-src/GUSI2</code>. As GUSI is moving to sourceforge
69this info may be outdated by the time you read it so better check the
70MacPython homepage, probably.
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 Jansen8a6cdcc2000-09-10 12:02:28 +000076download these packages too. Python has 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 Jansen8a6cdcc2000-09-10 12:02:28 +000078suffices to just refrain from builing the extension module.
79Here are the locations for the various things
Jack Jansen4c1e56c1996-08-06 16:16:20 +000080you need:
Jack Jansen8f2d8021996-08-05 15:34:45 +000081
82<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000083
Jack Jansen8b41d532000-05-07 22:08:42 +000084<LI> Tcl and Tk are in a sad state on the Mac, the standard source distributions
85simply don't compile, so I have created a distribution especially for use
86with MacPython.
87See the section on <A HREF="#tcltk">building Tcl/Tk Python</A>
88below.
Jack Jansen8f2d8021996-08-05 15:34:45 +000089
Jack Jansen4c1e56c1996-08-06 16:16:20 +000090<LI> Waste, a TextEdit replacement written by Marco Piovanelli, <A
91HREF="mailto:piovanel@kagi.com">&lt;piovanel@kagi.com&gt;</A>. Python
Jack Jansena2139fe1998-02-25 15:40:35 +000092was built using version 1.3, which you can obtain from <A
93HREF="http://www.boingo.com/waste">&lt;http://www.boingo.com/waste&gt;</A>
Jack Jansen4c1e56c1996-08-06 16:16:20 +000094and various other places.
Jack Jansen8f2d8021996-08-05 15:34:45 +000095
Jack Jansen1473af71997-05-07 15:43:38 +000096<LI> Gdbm library for the Mac. Available from Jack's Mac software page at
97<A HREF="http://www.cwi.nl/~jack/macsoftware.html">
98http://www.cwi.nl/~jack/macsoftware.html</A> and <A HREF="ftp://ftp.cwi.nl/pub/jack/mac">
Jack Jansena598bc41999-02-10 23:08:24 +000099ftp://ftp.cwi.nl/pub/jack/mac</A>. Also in the MacPython cvs repository at
100<code>lib-src/gdbm</code>.
Jack Jansen1473af71997-05-07 15:43:38 +0000101
102<LI> JPEG library by the Independent JPEG Group. A version including
103Mac projects can be found at Jack's page mentioned above.
104The most recent JPEG library can always be obtained from <A
Jack Jansena598bc41999-02-10 23:08:24 +0000105HREF="ftp://ftp.uu.net/graphics/jpeg/">ftp://ftp.uu.net/graphics/jpeg/</A>. Again,
106also in the MacPython cvs repository at <code>lib-src/jpeg</code>.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000107
Jack Jansen1473af71997-05-07 15:43:38 +0000108<LI> The netpbm/pbmplus, libtiff, zlib and png libraries. The netpbm distribution
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000109(which includes libtiff) is generally available on Internet ftp
110servers. For Python pbmplus, an older incarnation of netpbm, is
111functionally identical to netpbm, since Python only uses the library
112and not the complete applications. A distribution with correct
Jack Jansen1473af71997-05-07 15:43:38 +0000113projects and library source only is available from, you guessed it, Jack's Mac software
Jack Jansena598bc41999-02-10 23:08:24 +0000114page mentioned above. And, guessed it again, in the MacPython cvs repository
115at <code>lib-src/netpbm</code>, etc. The only gotcha is that libtiff lives in
116<code>lib-src/netpbm/libtiff</code>, for historical reasons.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000117
Jack Jansen8f2d8021996-08-05 15:34:45 +0000118</UL>
119
120<H2>Setting Up</H2>
121
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000122Now that you have collected everything you should start with building
Jack Jansen1473af71997-05-07 15:43:38 +0000123the various parts. If you don't want to fix
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000124access paths try to set things up as follows:
125
Jack Jansen8f2d8021996-08-05 15:34:45 +0000126<PRE>
127Top-level-folder:
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000128 GUSI2
Jack Jansen8f2d8021996-08-05 15:34:45 +0000129 imglibs
Jack Jansende570301998-08-27 13:39:01 +0000130 jpeg
131 netpbm
132 libtiff
Jack Jansen1473af71997-05-07 15:43:38 +0000133 zlib
Jack Jansende570301998-08-27 13:39:01 +0000134 png
Jack Jansen1473af71997-05-07 15:43:38 +0000135 gdbm
Jack Jansen8f2d8021996-08-05 15:34:45 +0000136 Python
Jack Jansen90cf4912000-02-11 23:14:46 +0000137 Modules
138 ...
139 Mac
140 Modules
141 Build
142 ...
Jack Jansen32617191997-08-19 14:01:16 +0000143 Tcl/Tk Folder
144 tcl8.0
145 tk8.0
Jack Jansena2139fe1998-02-25 15:40:35 +0000146 MoreFiles 1.4.3
147 Waste 1.3 distribution (if you want waste)
Jack Jansen8f2d8021996-08-05 15:34:45 +0000148</PRE>
149
Jack Jansende570301998-08-27 13:39:01 +0000150If your setup of the libraries is exactly the same as mine (which is
151not very likely, unless you happen to work from the same CVS
152repository) you can use the project <code>buildlibs.prj</code> in the
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000153<code>:Mac:Build</code> folder to build all needed libraries in one
Jack Jansende570301998-08-27 13:39:01 +0000154fell swoop, otherwise you will have to build the libraries one by
155one. <p>
156
Jack Jansen1473af71997-05-07 15:43:38 +0000157First build GUSI. If you didn't get the python-specific GUSI you have to
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000158massage some of the Python code (missing routines) and you'll miss the
159functionality of "delay console".
160 <p>
Jack Jansen95375861999-03-10 15:51:56 +0000161
Jack Jansen16e99c01996-09-07 17:11:26 +0000162Next, in
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000163<code>libjpeg</code>, <code>pbmplus</code>,
Jack Jansen1473af71997-05-07 15:43:38 +0000164<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 Jansen8a6cdcc2000-09-10 12:02:28 +0000167case, see below.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000168
169<H2><A NAME="tcltk">Building Tcl/Tk</H2>
170
Jack Jansen8b41d532000-05-07 22:08:42 +0000171The Tcl/Tk 8.3.0 source distribution does not work on the Mac. I have created
172an archive of the sources that I used to build _tkinter for MacPython,
173you can obtain this from <a
174href="ftp://ftp.cwi.nl/pub/jack/python/mac/tcltk830src-for-python.sit">
175ftp://ftp.cwi.nl/pub/jack/python/mac/tcltk830src-for-python.sit</a>. Only the
176libraries needed to build _tkinter for PPC have been fixed. <P>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000177
Jack Jansen8b41d532000-05-07 22:08:42 +0000178Note that if you use a different release of Tcl and Tk than the ones
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000179I have used you may have to adapt the Python <code>tkresources.rsrc</code> file.
180This is easiest done by building <code>SimpleTk</code> and copying the TEXT, ICON
181and CRSR resources from it to <code>tkresources.rsrc</code>. This allows
182the <code>_tkinter</code> module to work without an installed Tk/Tcl on your
Jack Jansen8b41d532000-05-07 22:08:42 +0000183machine. <P>
184
185Also note that the <code>_tkinter.ppc.slb</code> that is normally distributed
186in the <code>PlugIns</code> folder is the one from the Imaging extension,
187which has some extra features needed by PIL (and which features should not
188hinder normal operation).
Jack Jansen27b10ec1996-08-23 15:44:18 +0000189
Jack Jansen8f2d8021996-08-05 15:34:45 +0000190</UL>
191
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000192Build first the Tcl library, then
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000193SimpleTcl (test it by typing <code>ls -l</code> in the window you get)
194then the Tk library, then SimpleTk (which can again be tested with
195<code>ls -l</code>). If this all worked you are all set to try
Jack Jansen8f2d8021996-08-05 15:34:45 +0000196building Python.
197
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000198<H2>Building Waste</H2>
199
200You do not need to build the Waste libraries, as Python includes the
Jack Jansena2139fe1998-02-25 15:40:35 +0000201source modules themselves.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000202
Jack Jansen8f2d8021996-08-05 15:34:45 +0000203<H2>The organization of the Python source tree</H2>
204
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000205Time for a short break, while we have a look at the organization of
206the Python source tree. At the top level, we find the following
207folders:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000208
209<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000210<DT> Demo
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000211<DD> Demo programs that are not Mac-specific. Some of these may not
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000212work.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000213
214<DT> Extensions
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000215<DD> Extensions to the interpreter that are not Mac-specific. Contains
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000216the <code>img</code>, <code>Imaging</code> and <code>Numerical</code> extensions
217in this distribution.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000218
219<DT> Grammar
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000220<DD> The Python grammar. Included for reference only, you cannot build
221the parser on a Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000222
223<DT> Include
224<DD> Machine-independent header files.
225
226<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000227<DD> Machine-independent optional modules. Not all of these will work
228on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000229
230<DT> Objects
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000231<DD> Machine-independent code for various object types. Most of these are
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000232not really optional: the interpreter will not function without them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000233
234<DT> Parser
235<DD> The Python parser (machine-independent).
236
Jack Jansen8f2d8021996-08-05 15:34:45 +0000237<DT> Python
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000238<DD> The core interpreter. Most files are machine-independent, some
239are unix-specific and not used on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000240
241<DT> Tools
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000242<DD> Tools for python developers. Contains <code>modulator</code> which
243builds skeleton C extension modules, <code>bgen</code> which generates
244complete interface modules from information in C header files and
245<code>freeze</code> which is used to turn Python scripts into real
246applications (used by MacFreeze and BuildApplication) There are some
247readme files, but more documentation is sorely needed.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000248
Jack Jansen8f2d8021996-08-05 15:34:45 +0000249</DL>
250
251All the mac-specific stuff lives in the <code>Mac</code> folder:
252<DL>
Jack Jansenc256ece1999-02-03 13:09:27 +0000253<DT> Build
254<DD> This is where the project files live and where you build the
255libraries, shared libraries, executables and plugin modules. All the
256resulting binaries, except for intermedeate results, are deposited in
Jack Jansena598bc41999-02-10 23:08:24 +0000257the toplevel folder or the Mac:PlugIns folder (for plugin modules).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000258
259<DT> Compat
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000260<DD> Unix-compatability routines. Most of these are not used anymore,
261since GUSI provides a rather complete emulation, but you may need
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000262these if you are trying to build a non-GUSI python.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000263
264<DT> Demo
265<DD> Mac-specific demo programs, some of them annotated.
266
267<DT> Include
268<DD> Mac-specific but compiler-independent include files.
269
270<DT> Lib
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000271<DD> Mac-specific standard modules. The <code>toolbox</code> folder
272contains modules specifically needed with various MacOS toolbox
273interface modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000274
275<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000276<DD> Mac-specific builtin modules. Theoretically these are all
277optional, but some are rather essential (like
278<code>macmodule</code>). A lot of these modules are generated with
279<code>bgen</code>, in which case the bgen input files are included so
280you can attempt to regenerate them or extend them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000281
282<DT> MPW
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000283<DD> MPW-specific files. These have not been used or kept up-to-date
284for a long time, so use at your own risk.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000285
286<DT> mwerks
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000287<DD> Mwerks-specific sources and headers. Contains glue code for
288Pythons shared-library architecture, a replacement for
289<code>malloc</code> and a directory with various projects for building
290variations on the Python interpreter. The <code>mwerks_*.h</code>
291files here are the option-setting files for the various interpreters
292and such, comparable to the unix command-line <code>-D</code> options
293to the compiler. Each project uses the correct option file as its
294"prefix file" in the "C/C++ language" settings. Disabling optional
295modules (for the 68K interpreter), building non-GUSI interpreters and
296various other things are accomplished by modifying these files (and
297possibly changing the list of files included in the project window, of
298course).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000299
Jack Jansenc256ece1999-02-03 13:09:27 +0000300<DT> PlugIns
301<DD> This is where the PPC and CFM68K dynamically-loaded plugin modules live.
302
Jack Jansen8f2d8021996-08-05 15:34:45 +0000303<DT> Python
304<DD> Mac-specific parts of the core interpreter.
305
306<DT> Resources
307<DD> Resource files needed to build the interpreter.
308
309<DT> Scripts
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000310<DD> A collection of various mac-specific Python scripts. Some are
311essential, some are useful but few are documented, so you will have to
312use your imagination to work them out.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000313
Jack Jansenc256ece1999-02-03 13:09:27 +0000314<DT> Tools
315<DD> A collection of tools, usually bigger than those in the scripts
316folder. The important ones here are the IDE and macfreeze. The IDE is built
317with the buildIDE.py script, which puts the resulting applet in the toplevel
318folder. Macfreeze is usually invoked through the BuildApplication script,
319but for more control over the freezing process you can run the main script here.
320
321
Jack Jansen8f2d8021996-08-05 15:34:45 +0000322<DT> Unsupported
323<DD> Modules that are not supported any longer but may still work with a little effort.
324</DL>
325
326<H2>Building the 68K interpreter</H2>
327
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000032868K Python is no longer supported, and the projects are not included in the
329source distirbution anymore. If you really want to build Python for the 68K
330your best bet is to check the sources out of the CVS repository. The latest
331projects (in :Mac:build:) that support 68K development are tagged as such,
332and are dated around August 2000. If you plan on doing this announce it on
333the SIG, please. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000334
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000335<H2>Building the PPC interpreter</H2>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000336
Jack Jansenc256ece1999-02-03 13:09:27 +0000337First you optionally build the external libraries with buildlibs.prj. Next,
338the projects for
339interpreter, core library and applet skeleton are all linked together, so
Jack Jansen3b805261999-02-14 23:12:06 +0000340building the fat target in <code>PythonEngine.prj</code>
341will result in everything being built. The
Jack Jansen3412c5d1997-08-27 14:08:22 +0000342resulting applications and fat shared library are deposited in the main
Jack Jansenc256ece1999-02-03 13:09:27 +0000343Python folder. Finally, you build all the plugins with the plugins.prj project.
344
345For completeness sake here is a breakdown of the projects:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000346
347<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000348
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000349<DT> PythonCore (with subproject PythonCorePPC)
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000350<DD> The shared library that contains the bulk of the interpreter and
351its resources. It is a good idea to immedeately put an alias to this
352shared library in the <code>Extensions</code> folder of your system
353folder. Do exactly that: put an <em>alias</em> there, copying or
Jack Jansen3412c5d1997-08-27 14:08:22 +0000354moving the file will cause you grief later if you rebuild the library and
Jack Jansenc256ece1999-02-03 13:09:27 +0000355forget to copy it to the extensions folder again. The InstallPython applet
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000356will also do this, along with creating the plugin aliases. <br>
357Note that the subproject looks a bit silly nowadays (with no more CFM68K
358support) but you will have to live with that for this release.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000359
Jack Jansen3b805261999-02-14 23:12:06 +0000360<DT> PythonInterpeter
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000361<DD> The interpreter. This is basically a routine to call out to the
Jack Jansen3b805261999-02-14 23:12:06 +0000362shared library. Unlike in previous releases the same program is used for
363creating applets (for which formerly PythonApplet was used). <p>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000364
Jack Jansenc256ece1999-02-03 13:09:27 +0000365<DT> Plugin projects
Jack Jansena598bc41999-02-10 23:08:24 +0000366<DD> Each plugin module has a separate project. The <code>Plugins.prj</code>
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000367project tries to build them all, but is known to be flakey. See <code>fullbuild</code>
368below for a better way to build everything.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000369</DL>
370
Jack Jansen3412c5d1997-08-27 14:08:22 +0000371After creating the alias to <code>PythonCore</code> you remove any old
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000372<code>Python 2.0b1 Preferences</code> file from the <code>Preferences</code> folder
Jack Jansen061ac501996-10-22 15:27:56 +0000373(if you had python installed on your system before) and run the interpreter once
Jack Jansen3412c5d1997-08-27 14:08:22 +0000374to create the correct preferences file. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000375
Jack Jansenc256ece1999-02-03 13:09:27 +0000376Next, you have to build the extension modules.
377The <code>PlugIns.ppc</code> project has all the
Jack Jansena598bc41999-02-10 23:08:24 +0000378other projects as subprojects and builds everything (but see the gotcha above).
379<p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000380
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000381Finally, you must build the standard applets:
Jack Jansen3412c5d1997-08-27 14:08:22 +0000382<code>EditPythonPrefs</code>, <code>BuildApplet</code>, etc. This is
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000383easiest done with the <code>fullbuild</code> script from
Jack Jansen3412c5d1997-08-27 14:08:22 +0000384<code>Mac:scripts</code>. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000385
386<BLOCKQUOTE>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000387Actually, the <code>fullbuild</code> script can be used to build
388everything, but you need a fully-functional interpreter before you can
389use it (and one that isn't rebuilt in the process: you cannot rebuild
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000390a running program). You could copy the interpreter to a different
391place and use that to run fullbuild. The <code>PythonStandSmall.prj</code>
392project builds an interpreter that is suited to this, and it can also come
393in handy if you need to debug things (which is easier in a static program). <p>
Jack Jansene66b8c81997-05-29 14:57:07 +0000394
Jack Jansen8f2d8021996-08-05 15:34:45 +0000395</BLOCKQUOTE>
396
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000397You are all set now, and should read the release notes and
Jack Jansen3412c5d1997-08-27 14:08:22 +0000398<code>ReadMe</code> file from the <code>Mac</code> folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000399
Jack Jansen27b10ec1996-08-23 15:44:18 +0000400<H2>Rebuilding <code>.exp</code> files for PPC and CFM68K</H2>
401
402Occasionally it may be necessary to rebuild your PythonCore <code>.exp</code>
403file, a file that controls which symbols are exported by your PythonCore
404shared library. Rebuild it if you get unexpected undefined symbols when you
405are building a plugin module. <p>
406
407Rebuilding the .exp file is done by first removing the file and removing the
408reference to it in the project (in the "config" section). Next, build PythonCore.
409This will create a new .exp file. Edit this file to remove the references to
410the symbols <code>__initialize</code>, <code>__terminate</code>, <code>setjmp</code>,
Jack Jansen2afc2c71999-09-30 19:48:49 +0000411<code>longjmp</code>, <code>vec_longjmp</code>, <code>main</code> and (for PPC) <code>__ptmf_null</code> or (for
Jack Jansen1473af71997-05-07 15:43:38 +0000412CFM68K) <code>__start</code> and <code>dummy_init_routine</code>.
413Next, add the .exp file to the project
Jack Jansen27b10ec1996-08-23 15:44:18 +0000414again and rebuild PythonCore. <p>
415
416This rather convoluted procedure is needed to ensure that plugin modules don't
417accidentally link with those entrypoints from PythonCore, which will not work because
418those routines have to be in the same code fragment as they are used from.
419
Jack Jansen95375861999-03-10 15:51:56 +0000420<H2><a name="cvs">Using the CVS source archive</a></H2>
Jack Jansenc256ece1999-02-03 13:09:27 +0000421
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000422It is possible (and probably best) to access the Python sources through remote CVS. The
Jack Jansen65f685b1999-04-12 09:25:23 +0000423advantage of this is that you get the very latest sources, so any bug
424fixed or new features will be immedeately available. This is also the
425disadvantage, of course: as this is the same tree as is used for
426development it may sometimes be a little less stable. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000427
428The CVS client of choice is Alexandre Parenteau's MacCVS. It can be
Jack Jansen65f685b1999-04-12 09:25:23 +0000429obtained through the <a href="http://www.wincvs.org">WinCVS
430homepage</a>. MacCVS uses Internet Config to set file types correctly
431based on the filename extension. In the maccvs preferences you should
432also set (in the "binary files" section) "use mac encoding:
433applesingle" and (in the "text files" section) "use ISO latin 1
Jack Jansenc256ece1999-02-03 13:09:27 +0000434conversion". <p>
435
Jack Jansen8b41d532000-05-07 22:08:42 +0000436It is also a good idea to disable Quicktime Exchange in the Quicktime
437control panel. Quicktime Exchange will magically map some extensions to
438filetypes, and this can seriously hinder you if, for instance, <code>.bmp</code>
439is not a Windows bitmap file. <p>
440
Jack Jansen95375861999-03-10 15:51:56 +0000441The machine-independent Python sources are checked out from the main
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000442Python CVS archive on sourceforge.net, see the <a
Jack Jansen65f685b1999-04-12 09:25:23 +0000443href="http://www.python.org/download/cvs.html">Source access via
444CVS</a> page for details. When you check the sources out you will get
Jack Jansen95375861999-03-10 15:51:56 +0000445something like <code>Python:dist:src</code>, and under that the
446<code>Modules</code>, <code>Lib</code>, etc hierarchy. The
447<code>src</code> folder should be renamed to <code>Python</code>, and
448is what this document refers to as the "toplevel Python folder". <P>
Jack Jansenc256ece1999-02-03 13:09:27 +0000449
Jack Jansen90cf4912000-02-11 23:14:46 +0000450Next, <em>in a separate folder</em>, you check out the
451mac-specific sources. You then move the <code>Mac</code> folder from this
452checkout (the only folder with anything in it) to the Python source folder.
453Note that the checking out in a separate folder and moving is necessary,
454due to the way cvs works.
455
456The CVS path to use for the mac stuff can be found
Jack Jansen95375861999-03-10 15:51:56 +0000457at the <a href="http://www.cwi.nl/~jack/macpython.html">MacPython
458homepage</a>. Finally, you check out the external libraries needed in
Jack Jansen90cf4912000-02-11 23:14:46 +0000459the parent of the toplevel Python folder. The CVS path for these libraries is
Jack Jansen95375861999-03-10 15:51:56 +0000460also mentioned at the MacPython homepage. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000461
Jack Jansen95375861999-03-10 15:51:56 +0000462Neither of the pages mentioned above contains the passwords for the
463CVS sites, for obvious reasons, but they do contain instructions on
464how to obtain the passwords. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000465
Jack Jansen90cf4912000-02-11 23:14:46 +0000466You should end up with a folder structure as described at the top of this
467document. <p>
468
Jack Jansendae108c2000-02-11 23:17:14 +0000469Note that while the Mac folder is now a subfolder of your toplevel Python
470folder this does not mean that they "act as one" as far as CVS is concerned.
471To update all your sources you have to do a "cvs update" in the toplevel
472Python folder and another one in the Mac folder. This is again a cvs problem:
473it cannot deal with subpackages coming from different repositories. <p>
474
Jack Jansen8f2d8021996-08-05 15:34:45 +0000475<H2>Odds and ends</H2>
476
477Some remarks that I could not fit in elsewhere:
478
479<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000480
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000481<LI> It may be possible to use the <code>PythonCore</code> shared
482library to embed Python in another program, if your program can live
Jack Jansen1473af71997-05-07 15:43:38 +0000483with using GUSI for I/O. Use PythonCore in stead of your MSL C library
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000484(or, at the very least, link it before the normal C library).
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000485
486<LI> It is possible to build PPC extension modules without building a
Jack Jansenc256ece1999-02-03 13:09:27 +0000487complete Python. The binary distribution installer can optionally install
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000488all the needed folders (the develop option). A template for a dynamic module can be found in
Jack Jansen3412c5d1997-08-27 14:08:22 +0000489<code>xx.prj</code>.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000490
491<LI> The Python shared library architecture is a variant of the architecture
492described as "application with shared libraries and dropins" in the MetroWerks
493"Targeting MacOS" documentation. The Python Application and applet-template use
Jack Jansen1473af71997-05-07 15:43:38 +0000494the <code>MSL AppRuntime.Lib</code> runtime library (with properly set CFM
495initialization and termination routines). PythonCore uses <code>MSL Runtime.Lib</code>,
496which is really intended for standalone programs but which we fool into working by
497providing a dummy main program.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000498It is linked statically into PythonCore (and exported to the applications and plugins)
499so we do not have to distribute yet another shared library. Plugin modules use
Jack Jansen1473af71997-05-07 15:43:38 +0000500<code>MSL ShlibRuntime.Lib</code> (not the dropin runtime: modules are never unloaded)
501and obtain the rest from PythonCore. PythonCore uses a
Jack Jansen27b10ec1996-08-23 15:44:18 +0000502non-standard initialization entry point, <code>__initialize_with_resources</code>, to
Jack Jansen1473af71997-05-07 15:43:38 +0000503be able to obtain resources from the library file later on. Plugins can do the same
504(_tkinter does) or use the standard <code>__initialize</code> entry point.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000505
506
Jack Jansen6ad8d131997-01-15 16:53:37 +0000507</UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000508</BODY>
509</HTML>