blob: 6e381d9fe03458db46b761e17d01e90c06253c14 [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 Jansen16904092001-08-16 14:10:56 +000038obtain one via <A HREF="http://www.cwi.nl/~jack/macpython.html">
39http://www.cwi.nl/~jack/macpython.html</A> (which has up-to-date links
Jack Jansen95375861999-03-10 15:51:56 +000040to the other packages needed too) and possibly also from the standard
41<A HREF="ftp://ftp.python.org/pub/python/mac">python.org ftp
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000042site</A>. <BR>
Jack Jansenc256ece1999-02-03 13:09:27 +000043
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000044A better alternative is to check the sources straight out of the CVS
Jack Jansen95375861999-03-10 15:51:56 +000045repository, see below. Most of the packages mentioned here are also
46available through CVS. Check the section on <a href="#cvs">CVS
47repository use</a> below.
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 Jansenc1218bc2001-04-25 22:11:24 +000050been built with CodeWarrior Pro 6.1. Ordering information is
Jack Jansen4c1e56c1996-08-06 16:16:20 +000051available on the <A HREF="http://www.metrowerks.com/">MetroWerks
Jack Jansen16904092001-08-16 14:10:56 +000052homepage</A>. Building Python with MPW, Think/Symantec C or the OSX
53developer tools is impossible without major surgery.
Jack Jansen4c1e56c1996-08-06 16:16:20 +000054
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000055<LI> You need GUSI version 2, the Grand Unified Socket Interface, by
56Matthias Neeracher. The original GUSI is obtainable from <A
Jack Jansen5f884c02000-12-12 22:14:14 +000057HREF="ftp://gusi.sourceforge.net/pub/gusi/">
58ftp://gusi.sourceforge.net/pub/gusi/</A>. At
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000059the moment Python is built with a slightly modified version of GUSI
602.1.1, so it may be better to check the <A
61HREF="http://www.cwi.nl/~jack/macpython.html">MacPython homepage</A>
62for a GUSI that is most easily used for building Python.
Jack Jansena598bc41999-02-10 23:08:24 +000063
Jack Jansen8f2d8021996-08-05 15:34:45 +000064</UL>
65
Jack Jansen4c1e56c1996-08-06 16:16:20 +000066<A NAME="optional">The MacPython project files are configured to
67include a plethora of optional modules</A>, and these modules need a
Jack Jansena2139fe1998-02-25 15:40:35 +000068number of extra packages. To use the project files as-is you have to
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000069download these packages too. Python has all such modules as
Jack Jansen4c1e56c1996-08-06 16:16:20 +000070dynamically loaded modules, so if you don't need a certain package it
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000071suffices to just refrain from builing the extension module.
72Here are the locations for the various things
Jack Jansen4c1e56c1996-08-06 16:16:20 +000073you need:
Jack Jansen8f2d8021996-08-05 15:34:45 +000074
75<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000076
Jack Jansen8b41d532000-05-07 22:08:42 +000077<LI> Tcl and Tk are in a sad state on the Mac, the standard source distributions
78simply don't compile, so I have created a distribution especially for use
79with MacPython.
80See the section on <A HREF="#tcltk">building Tcl/Tk Python</A>
81below.
Jack Jansen8f2d8021996-08-05 15:34:45 +000082
Jack Jansen4c1e56c1996-08-06 16:16:20 +000083<LI> Waste, a TextEdit replacement written by Marco Piovanelli, <A
84HREF="mailto:piovanel@kagi.com">&lt;piovanel@kagi.com&gt;</A>. Python
Jack Jansenc1218bc2001-04-25 22:11:24 +000085was built using version 2.0, which is included in the CodeWarrior
86package. You can also obtain it from <A
Jack Jansen16904092001-08-16 14:10:56 +000087HREF="http://www.merzwaren.com/waste">&lt;http://www.merzwaren.com/waste&gt;</A>
Jack Jansen4c1e56c1996-08-06 16:16:20 +000088and various other places.
Jack Jansen8f2d8021996-08-05 15:34:45 +000089
Jack Jansen1473af71997-05-07 15:43:38 +000090<LI> Gdbm library for the Mac. Available from Jack's Mac software page at
91<A HREF="http://www.cwi.nl/~jack/macsoftware.html">
92http://www.cwi.nl/~jack/macsoftware.html</A> and <A HREF="ftp://ftp.cwi.nl/pub/jack/mac">
Jack Jansen16904092001-08-16 14:10:56 +000093ftp://ftp.cwi.nl/pub/jack/mac</A>.
Jack Jansen1473af71997-05-07 15:43:38 +000094
95<LI> JPEG library by the Independent JPEG Group. A version including
96Mac projects can be found at Jack's page mentioned above.
97The most recent JPEG library can always be obtained from <A
Jack Jansen16904092001-08-16 14:10:56 +000098HREF="ftp://ftp.uu.net/graphics/jpeg/">ftp://ftp.uu.net/graphics/jpeg/</A>.
Jack Jansen4c1e56c1996-08-06 16:16:20 +000099
Jack Jansen1473af71997-05-07 15:43:38 +0000100<LI> The netpbm/pbmplus, libtiff, zlib and png libraries. The netpbm distribution
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000101(which includes libtiff) is generally available on Internet ftp
102servers. For Python pbmplus, an older incarnation of netpbm, is
103functionally identical to netpbm, since Python only uses the library
104and not the complete applications. A distribution with correct
Jack Jansen1473af71997-05-07 15:43:38 +0000105projects and library source only is available from, you guessed it, Jack's Mac software
Jack Jansen16904092001-08-16 14:10:56 +0000106page mentioned above.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000107
Jack Jansen8f2d8021996-08-05 15:34:45 +0000108</UL>
109
110<H2>Setting Up</H2>
111
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000112Now that you have collected everything you should start with building
Jack Jansen1473af71997-05-07 15:43:38 +0000113the various parts. If you don't want to fix
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000114access paths try to set things up as follows:
115
Jack Jansen8f2d8021996-08-05 15:34:45 +0000116<PRE>
117Top-level-folder:
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000118 GUSI2
Jack Jansenc1218bc2001-04-25 22:11:24 +0000119 GUSI2Carbon
Jack Jansen8f2d8021996-08-05 15:34:45 +0000120 imglibs
Jack Jansende570301998-08-27 13:39:01 +0000121 jpeg
122 netpbm
123 libtiff
Jack Jansen1473af71997-05-07 15:43:38 +0000124 zlib
Jack Jansende570301998-08-27 13:39:01 +0000125 png
Jack Jansen1473af71997-05-07 15:43:38 +0000126 gdbm
Jack Jansen8f2d8021996-08-05 15:34:45 +0000127 Python
Jack Jansen90cf4912000-02-11 23:14:46 +0000128 Modules
129 ...
130 Mac
131 Modules
132 Build
133 ...
Jack Jansen32617191997-08-19 14:01:16 +0000134 Tcl/Tk Folder
135 tcl8.0
136 tk8.0
Jack Jansena2139fe1998-02-25 15:40:35 +0000137 MoreFiles 1.4.3
Jack Jansen8f2d8021996-08-05 15:34:45 +0000138</PRE>
139
Jack Jansende570301998-08-27 13:39:01 +0000140If your setup of the libraries is exactly the same as mine (which is
141not very likely, unless you happen to work from the same CVS
142repository) you can use the project <code>buildlibs.prj</code> in the
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000143<code>:Mac:Build</code> folder to build all needed libraries in one
Jack Jansende570301998-08-27 13:39:01 +0000144fell swoop, otherwise you will have to build the libraries one by
145one. <p>
146
Jack Jansenc1218bc2001-04-25 22:11:24 +0000147First build GUSI, both the norla one and the Carbon variant.
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000148 <p>
Jack Jansen95375861999-03-10 15:51:56 +0000149
Jack Jansen16e99c01996-09-07 17:11:26 +0000150Next, in
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000151<code>libjpeg</code>, <code>pbmplus</code>,
Jack Jansen1473af71997-05-07 15:43:38 +0000152<code>zlib</code>, <code>libpng</code>, <code>gdbm</code>,
Jack Jansena2139fe1998-02-25 15:40:35 +0000153and<code>libtiff</code> you build all projects. Usually the projects are in "mac"
Jack Jansen1473af71997-05-07 15:43:38 +0000154subfolders, sometimes they are in the main folder. Tcl/tk is a special
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000155case, see below.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000156
157<H2><A NAME="tcltk">Building Tcl/Tk</H2>
158
Jack Jansen8b41d532000-05-07 22:08:42 +0000159The Tcl/Tk 8.3.0 source distribution does not work on the Mac. I have created
160an archive of the sources that I used to build _tkinter for MacPython,
161you can obtain this from <a
162href="ftp://ftp.cwi.nl/pub/jack/python/mac/tcltk830src-for-python.sit">
163ftp://ftp.cwi.nl/pub/jack/python/mac/tcltk830src-for-python.sit</a>. Only the
164libraries needed to build _tkinter for PPC have been fixed. <P>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000165
Jack Jansen8b41d532000-05-07 22:08:42 +0000166Note that if you use a different release of Tcl and Tk than the ones
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000167I have used you may have to adapt the Python <code>tkresources.rsrc</code> file.
168This is easiest done by building <code>SimpleTk</code> and copying the TEXT, ICON
169and CRSR resources from it to <code>tkresources.rsrc</code>. This allows
170the <code>_tkinter</code> module to work without an installed Tk/Tcl on your
Jack Jansen8b41d532000-05-07 22:08:42 +0000171machine. <P>
172
173Also note that the <code>_tkinter.ppc.slb</code> that is normally distributed
174in the <code>PlugIns</code> folder is the one from the Imaging extension,
175which has some extra features needed by PIL (and which features should not
176hinder normal operation).
Jack Jansen27b10ec1996-08-23 15:44:18 +0000177
Jack Jansen8f2d8021996-08-05 15:34:45 +0000178</UL>
179
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000180Build first the Tcl library, then
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000181SimpleTcl (test it by typing <code>ls -l</code> in the window you get)
182then the Tk library, then SimpleTk (which can again be tested with
183<code>ls -l</code>). If this all worked you are all set to try
Jack Jansen8f2d8021996-08-05 15:34:45 +0000184building Python.
185
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000186<H2>Building Waste</H2>
187
188You do not need to build the Waste libraries, as Python includes the
Jack Jansena2139fe1998-02-25 15:40:35 +0000189source modules themselves.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000190
Jack Jansen8f2d8021996-08-05 15:34:45 +0000191<H2>The organization of the Python source tree</H2>
192
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000193Time for a short break, while we have a look at the organization of
194the Python source tree. At the top level, we find the following
195folders:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000196
197<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000198<DT> Demo
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000199<DD> Demo programs that are not Mac-specific. Some of these may not
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000200work.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000201
202<DT> Extensions
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000203<DD> Extensions to the interpreter that are not Mac-specific. Contains
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000204the <code>img</code>, <code>Imaging</code> and <code>Numerical</code> extensions
205in this distribution.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000206
207<DT> Grammar
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000208<DD> The Python grammar. Included for reference only, you cannot build
209the parser on a Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000210
211<DT> Include
212<DD> Machine-independent header files.
213
214<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000215<DD> Machine-independent optional modules. Not all of these will work
216on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000217
218<DT> Objects
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000219<DD> Machine-independent code for various object types. Most of these are
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000220not really optional: the interpreter will not function without them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000221
222<DT> Parser
223<DD> The Python parser (machine-independent).
224
Jack Jansen8f2d8021996-08-05 15:34:45 +0000225<DT> Python
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000226<DD> The core interpreter. Most files are machine-independent, some
227are unix-specific and not used on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000228
229<DT> Tools
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000230<DD> Tools for python developers. Contains <code>modulator</code> which
231builds skeleton C extension modules, <code>bgen</code> which generates
232complete interface modules from information in C header files and
233<code>freeze</code> which is used to turn Python scripts into real
234applications (used by MacFreeze and BuildApplication) There are some
235readme files, but more documentation is sorely needed.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000236
Jack Jansen8f2d8021996-08-05 15:34:45 +0000237</DL>
238
239All the mac-specific stuff lives in the <code>Mac</code> folder:
240<DL>
Jack Jansenc256ece1999-02-03 13:09:27 +0000241<DT> Build
242<DD> This is where the project files live and where you build the
243libraries, shared libraries, executables and plugin modules. All the
244resulting binaries, except for intermedeate results, are deposited in
Jack Jansena598bc41999-02-10 23:08:24 +0000245the toplevel folder or the Mac:PlugIns folder (for plugin modules).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000246
247<DT> Compat
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000248<DD> Unix-compatability routines. Most of these are not used anymore,
249since GUSI provides a rather complete emulation, but you may need
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000250these if you are trying to build a non-GUSI python.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000251
252<DT> Demo
253<DD> Mac-specific demo programs, some of them annotated.
254
255<DT> Include
256<DD> Mac-specific but compiler-independent include files.
257
258<DT> Lib
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000259<DD> Mac-specific standard modules. The <code>toolbox</code> folder
260contains modules specifically needed with various MacOS toolbox
261interface modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000262
263<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000264<DD> Mac-specific builtin modules. Theoretically these are all
265optional, but some are rather essential (like
Jack Jansen16904092001-08-16 14:10:56 +0000266<code>macosmodule</code>). A lot of these modules are generated with
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000267<code>bgen</code>, in which case the bgen input files are included so
268you can attempt to regenerate them or extend them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000269
270<DT> MPW
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000271<DD> MPW-specific files. These have not been used or kept up-to-date
272for a long time, so use at your own risk.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000273
274<DT> mwerks
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000275<DD> Mwerks-specific sources and headers. Contains glue code for
276Pythons shared-library architecture, a replacement for
277<code>malloc</code> and a directory with various projects for building
278variations on the Python interpreter. The <code>mwerks_*.h</code>
279files here are the option-setting files for the various interpreters
280and such, comparable to the unix command-line <code>-D</code> options
281to the compiler. Each project uses the correct option file as its
282"prefix file" in the "C/C++ language" settings. Disabling optional
283modules (for the 68K interpreter), building non-GUSI interpreters and
284various other things are accomplished by modifying these files (and
285possibly changing the list of files included in the project window, of
286course).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000287
Jack Jansenc256ece1999-02-03 13:09:27 +0000288<DT> PlugIns
Jack Jansenc1218bc2001-04-25 22:11:24 +0000289<DD> This is where the Classic and Carbon dynamically-loaded plugin modules live.
Jack Jansenc256ece1999-02-03 13:09:27 +0000290
Jack Jansen8f2d8021996-08-05 15:34:45 +0000291<DT> Python
292<DD> Mac-specific parts of the core interpreter.
293
294<DT> Resources
295<DD> Resource files needed to build the interpreter.
296
297<DT> Scripts
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000298<DD> A collection of various mac-specific Python scripts. Some are
299essential, some are useful but few are documented, so you will have to
300use your imagination to work them out.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000301
Jack Jansenc256ece1999-02-03 13:09:27 +0000302<DT> Tools
303<DD> A collection of tools, usually bigger than those in the scripts
304folder. The important ones here are the IDE and macfreeze. The IDE is built
305with the buildIDE.py script, which puts the resulting applet in the toplevel
306folder. Macfreeze is usually invoked through the BuildApplication script,
307but for more control over the freezing process you can run the main script here.
308
309
Jack Jansen8f2d8021996-08-05 15:34:45 +0000310<DT> Unsupported
311<DD> Modules that are not supported any longer but may still work with a little effort.
312</DL>
313
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000314<H2>Building the PPC interpreter</H2>
Jack Jansenc1218bc2001-04-25 22:11:24 +0000315<em>This is different under 2.1. You are best off using the fullbuild.py
Jack Jansen16904092001-08-16 14:10:56 +0000316script, see <a href="#fullbuild">below</a>. </em><p>
317
Jack Jansenc256ece1999-02-03 13:09:27 +0000318First you optionally build the external libraries with buildlibs.prj. Next,
319the projects for
Jack Jansen16904092001-08-16 14:10:56 +0000320interpreter and core library are linked together, so
321building the PythonInterpreterClassic and/or PythonInterpreterCarbon target
322in <code>PythonInterpreter.prj</code>
323will result in everything being built. The result, however, is an "Application
324template", (filetype Atmp). If you don't use fullbuild you can manually
325turn either of these into an interpreter by copying it to PythonInterpreter
326and setting the filetype to APPL (with ResEdit or some such). <p>
327
328Fullbuild does this for you, and the Atmp files is also how ConfigurePythonCarbon
329and ConfigurePythonClassic work their magic. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000330
331For completeness sake here is a breakdown of the projects:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000332
333<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000334
Jack Jansen16904092001-08-16 14:10:56 +0000335<DT> PythonCore
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000336<DD> The shared library that contains the bulk of the interpreter and
Jack Jansen16904092001-08-16 14:10:56 +0000337its resources. It has targets for PythonCore and PythonCoreCarbon.
338It is a good idea to immedeately put an alias to this
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000339shared library in the <code>Extensions</code> folder of your system
340folder. Do exactly that: put an <em>alias</em> there, copying or
Jack Jansen3412c5d1997-08-27 14:08:22 +0000341moving the file will cause you grief later if you rebuild the library and
Jack Jansen16904092001-08-16 14:10:56 +0000342forget to copy it to the extensions folder again. The ConfigurePythonXXX applets
343will also do this. <br>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000344
Jack Jansen3b805261999-02-14 23:12:06 +0000345<DT> PythonInterpeter
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000346<DD> The interpreter. This is basically a routine to call out to the
Jack Jansen3b805261999-02-14 23:12:06 +0000347shared library. Unlike in previous releases the same program is used for
348creating applets (for which formerly PythonApplet was used). <p>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000349
Jack Jansenc256ece1999-02-03 13:09:27 +0000350<DT> Plugin projects
Jack Jansen16904092001-08-16 14:10:56 +0000351<DD> Each plugin module has a separate project, and these can be rebuilt on
352the fly. Fullbuild (or actually it's little helper genpluginprojects) takes
353care of this.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000354</DL>
355
Jack Jansen3412c5d1997-08-27 14:08:22 +0000356After creating the alias to <code>PythonCore</code> you remove any old
Jack Jansen16904092001-08-16 14:10:56 +0000357<code>Python XXXX Preferences</code> file from the <code>Preferences</code> folder
Jack Jansen061ac501996-10-22 15:27:56 +0000358(if you had python installed on your system before) and run the interpreter once
Jack Jansen3412c5d1997-08-27 14:08:22 +0000359to create the correct preferences file. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000360
Jack Jansenc256ece1999-02-03 13:09:27 +0000361Next, you have to build the extension modules.
Jack Jansen16904092001-08-16 14:10:56 +0000362If you don't use fullbuild simply open each project and build it.
Jack Jansena598bc41999-02-10 23:08:24 +0000363<p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000364
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000365Finally, you must build the standard applets:
Jack Jansen16904092001-08-16 14:10:56 +0000366<code>EditPythonPrefs</code>, <code>BuildApplet</code>, etc. For the N-th time:
367fullbuild does this for you, but you can also manually drag/drop them onto
368BuildApplet. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000369
370<BLOCKQUOTE>
Jack Jansen16904092001-08-16 14:10:56 +0000371<a name="fullbuild"></a>
372The <code>fullbuild</code> script can be used to build
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000373everything, but you need a fully-functional interpreter before you can
374use it (and one that isn't rebuilt in the process: you cannot rebuild
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000375a running program). You could copy the interpreter to a different
376place and use that to run fullbuild. The <code>PythonStandSmall.prj</code>
377project builds an interpreter that is suited to this, and it can also come
378in handy if you need to debug things (which is easier in a static program). <p>
Jack Jansene66b8c81997-05-29 14:57:07 +0000379
Jack Jansen8f2d8021996-08-05 15:34:45 +0000380</BLOCKQUOTE>
381
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000382You are all set now, and should read the release notes and
Jack Jansen3412c5d1997-08-27 14:08:22 +0000383<code>ReadMe</code> file from the <code>Mac</code> folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000384
Jack Jansenc1218bc2001-04-25 22:11:24 +0000385<H2>Rebuilding <code>.exp</code> files</H2>
Jack Jansen27b10ec1996-08-23 15:44:18 +0000386
387Occasionally it may be necessary to rebuild your PythonCore <code>.exp</code>
388file, a file that controls which symbols are exported by your PythonCore
389shared library. Rebuild it if you get unexpected undefined symbols when you
390are building a plugin module. <p>
391
Jack Jansen16904092001-08-16 14:10:56 +0000392Rebuilding the .exp file is done by first both removing the file and removing the
393reference to it in the project (in the "config" section). Next, build PythonCore or
394PythonCoreCarbon.
395This will create a new .exp file, with the name <code>PythonCore.mcp.exp</code>.
396Rename this file to either <code>PythonCore.exp</code> or <code>PythonCoreCarbon.exp</code>
397and add this file back to the project. Next, edit ot to remove the references to
Jack Jansen27b10ec1996-08-23 15:44:18 +0000398the symbols <code>__initialize</code>, <code>__terminate</code>, <code>setjmp</code>,
Jack Jansen16904092001-08-16 14:10:56 +0000399<code>longjmp</code>, <code>vec_longjmp</code>, <code>main</code> and <code>__ptmf_null</code>.
400They are all close together about halfway the file.
401
402Finally rebuild again. <p>
Jack Jansen27b10ec1996-08-23 15:44:18 +0000403
404This rather convoluted procedure is needed to ensure that plugin modules don't
405accidentally link with those entrypoints from PythonCore, which will not work because
406those routines have to be in the same code fragment as they are used from.
407
Jack Jansen95375861999-03-10 15:51:56 +0000408<H2><a name="cvs">Using the CVS source archive</a></H2>
Jack Jansenc256ece1999-02-03 13:09:27 +0000409
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000410It is possible (and probably best) to access the Python sources through remote CVS. The
Jack Jansen65f685b1999-04-12 09:25:23 +0000411advantage of this is that you get the very latest sources, so any bug
412fixed or new features will be immedeately available. This is also the
413disadvantage, of course: as this is the same tree as is used for
414development it may sometimes be a little less stable. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000415
416The CVS client of choice is Alexandre Parenteau's MacCVS. It can be
Jack Jansen65f685b1999-04-12 09:25:23 +0000417obtained through the <a href="http://www.wincvs.org">WinCVS
418homepage</a>. MacCVS uses Internet Config to set file types correctly
419based on the filename extension. In the maccvs preferences you should
420also set (in the "binary files" section) "use mac encoding:
421applesingle" and (in the "text files" section) "use ISO latin 1
Jack Jansenc256ece1999-02-03 13:09:27 +0000422conversion". <p>
423
Jack Jansen16904092001-08-16 14:10:56 +0000424<blockquote>
425There is one group of people for whom MacCVS is not the best choice: people with
426checkin rights to the Python repository. You will have to use MacCVS Pro
427(completely unrelated) from www.maccvs.org, because it has working SSH support.
428</blockquote>
429
430It is a good idea to disable Quicktime Exchange in the Quicktime
Jack Jansen8b41d532000-05-07 22:08:42 +0000431control panel. Quicktime Exchange will magically map some extensions to
432filetypes, and this can seriously hinder you if, for instance, <code>.bmp</code>
433is not a Windows bitmap file. <p>
434
Jack Jansen16904092001-08-16 14:10:56 +0000435The Python sources are checked out from the main
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000436Python CVS archive on sourceforge.net, see the <a
Jack Jansen65f685b1999-04-12 09:25:23 +0000437href="http://www.python.org/download/cvs.html">Source access via
438CVS</a> page for details. When you check the sources out you will get
Jack Jansen95375861999-03-10 15:51:56 +0000439something like <code>Python:dist:src</code>, and under that the
Jack Jansen16904092001-08-16 14:10:56 +0000440<code>Modules</code>, <code>Lib</code>, <code>Mac</code> etc hierarchy. The
441<code>src</code> folder can be renamed to <code>Python</code>, and
Jack Jansen95375861999-03-10 15:51:56 +0000442is what this document refers to as the "toplevel Python folder". <P>
Jack Jansenc256ece1999-02-03 13:09:27 +0000443
Jack Jansen16904092001-08-16 14:10:56 +0000444The CVS repository does not contain all the projects for the plugin modules,
445these are built with <code>fullbuild.py</code> normally. For this reason
446it is probably a good idea to first build <code>PythonStandSmall.prj</code>,
447which builds a fairly minimal interpreter, and then follow the
448<a href="#fullbuild">fullbuild instructions</a>.
Jack Jansendae108c2000-02-11 23:17:14 +0000449
Jack Jansen8f2d8021996-08-05 15:34:45 +0000450<H2>Odds and ends</H2>
451
452Some remarks that I could not fit in elsewhere:
453
454<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000455
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000456<LI> It may be possible to use the <code>PythonCore</code> shared
457library to embed Python in another program, if your program can live
Jack Jansen1473af71997-05-07 15:43:38 +0000458with using GUSI for I/O. Use PythonCore in stead of your MSL C library
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000459(or, at the very least, link it before the normal C library).
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000460
461<LI> It is possible to build PPC extension modules without building a
Jack Jansenc256ece1999-02-03 13:09:27 +0000462complete Python. The binary distribution installer can optionally install
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000463all the needed folders (the develop option). A template for a dynamic module can be found in
Jack Jansen3412c5d1997-08-27 14:08:22 +0000464<code>xx.prj</code>.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000465
466<LI> The Python shared library architecture is a variant of the architecture
467described as "application with shared libraries and dropins" in the MetroWerks
468"Targeting MacOS" documentation. The Python Application and applet-template use
Jack Jansen1473af71997-05-07 15:43:38 +0000469the <code>MSL AppRuntime.Lib</code> runtime library (with properly set CFM
470initialization and termination routines). PythonCore uses <code>MSL Runtime.Lib</code>,
471which is really intended for standalone programs but which we fool into working by
472providing a dummy main program.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000473It is linked statically into PythonCore (and exported to the applications and plugins)
474so we do not have to distribute yet another shared library. Plugin modules use
Jack Jansen1473af71997-05-07 15:43:38 +0000475<code>MSL ShlibRuntime.Lib</code> (not the dropin runtime: modules are never unloaded)
476and obtain the rest from PythonCore. PythonCore uses a
Jack Jansen27b10ec1996-08-23 15:44:18 +0000477non-standard initialization entry point, <code>__initialize_with_resources</code>, to
Jack Jansen1473af71997-05-07 15:43:38 +0000478be able to obtain resources from the library file later on. Plugins can do the same
479(_tkinter does) or use the standard <code>__initialize</code> entry point.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000480
481
Jack Jansen6ad8d131997-01-15 16:53:37 +0000482</UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000483</BODY>
484</HTML>