blob: d983461d765eec099e9b750f8d8c8792d7cfd1a4 [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 Jansene0b1e6a2002-01-08 23:03:45 +000015Note that if you only want to build new extension modules you don't need to
16build Python from source, see the <a href="#extending">note on extending Python</a>.<p>
17
Jack Jansen4c1e56c1996-08-06 16:16:20 +000018The information density in this file is high, so you should probably
19print it and read it at your leasure. Most things are explained only
20once (and probably in the wrong place:-). <p>
21
Jack Jansen90cf4912000-02-11 23:14:46 +000022<blockquote>
23First a warning: this information may become outdated if a new CodeWarrior is
24released after MacPython. The
25<a href="http://www.cwi.nl/~jack/macpython.html">MacPython homepage</a> will
Jack Jansene0b1e6a2002-01-08 23:03:45 +000026hopefully have updated instructions in that case. These instructions are for CW7.
Jack Jansen90cf4912000-02-11 23:14:46 +000027</blockquote>
28
Jack Jansenc256ece1999-02-03 13:09:27 +000029I am very interested in feedback on this document, send your
Jack Jansen4c1e56c1996-08-06 16:16:20 +000030comments to the <A
31HREF="http://www.python.org/sigs/pythonmac-sig/">Mac Python Special
32Interest Group</A>.
Jack Jansen8f2d8021996-08-05 15:34:45 +000033
34<H2>What you need.</H2>
35
36The following things you definitely need:
37
38<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000039
Jack Jansen4c1e56c1996-08-06 16:16:20 +000040<LI> You need a MacPython source distribution, of course. You can
Jack Jansen16904092001-08-16 14:10:56 +000041obtain one via <A HREF="http://www.cwi.nl/~jack/macpython.html">
42http://www.cwi.nl/~jack/macpython.html</A> (which has up-to-date links
Jack Jansen95375861999-03-10 15:51:56 +000043to the other packages needed too) and possibly also from the standard
44<A HREF="ftp://ftp.python.org/pub/python/mac">python.org ftp
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000045site</A>. <BR>
Jack Jansenc256ece1999-02-03 13:09:27 +000046
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000047A better alternative is to check the sources straight out of the CVS
Jack Jansen95375861999-03-10 15:51:56 +000048repository, see below. Most of the packages mentioned here are also
49available through CVS. Check the section on <a href="#cvs">CVS
50repository use</a> below.
Jack Jansen8f2d8021996-08-05 15:34:45 +000051
Jack Jansen4c1e56c1996-08-06 16:16:20 +000052<LI> You need MetroWerks CodeWarrior. The current distribution has
Jack Jansene0b1e6a2002-01-08 23:03:45 +000053been built with CodeWarrior Pro 7.1. Ordering information is
Jack Jansen4c1e56c1996-08-06 16:16:20 +000054available on the <A HREF="http://www.metrowerks.com/">MetroWerks
Jack Jansen16904092001-08-16 14:10:56 +000055homepage</A>. Building Python with MPW, Think/Symantec C or the OSX
56developer tools is impossible without major surgery.
Jack Jansen4c1e56c1996-08-06 16:16:20 +000057
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000058<LI> You need GUSI version 2, the Grand Unified Socket Interface, by
59Matthias Neeracher. The original GUSI is obtainable from <A
Jack Jansen5f884c02000-12-12 22:14:14 +000060HREF="ftp://gusi.sourceforge.net/pub/gusi/">
61ftp://gusi.sourceforge.net/pub/gusi/</A>. At
Jack Jansene0b1e6a2002-01-08 23:03:45 +000062the moment Python is built with a modified version of GUSI
63with Carbon adaptations, so it may be better to check the <A
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000064HREF="http://www.cwi.nl/~jack/macpython.html">MacPython homepage</A>
65for a GUSI that is most easily used for building Python.
Jack Jansena598bc41999-02-10 23:08:24 +000066
Jack Jansen8f2d8021996-08-05 15:34:45 +000067</UL>
68
Jack Jansen4c1e56c1996-08-06 16:16:20 +000069<A NAME="optional">The MacPython project files are configured to
70include a plethora of optional modules</A>, and these modules need a
Jack Jansena2139fe1998-02-25 15:40:35 +000071number of extra packages. To use the project files as-is you have to
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000072download these packages too. Python has all such modules as
Jack Jansen4c1e56c1996-08-06 16:16:20 +000073dynamically loaded modules, so if you don't need a certain package it
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000074suffices to just refrain from builing the extension module.
75Here are the locations for the various things
Jack Jansen4c1e56c1996-08-06 16:16:20 +000076you need:
Jack Jansen8f2d8021996-08-05 15:34:45 +000077
78<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000079
Jack Jansene0b1e6a2002-01-08 23:03:45 +000080<LI> Tcl and Tk are somewhat less supported on the Mac than on Unix
81or Windows.
Jack Jansen8b41d532000-05-07 22:08:42 +000082See the section on <A HREF="#tcltk">building Tcl/Tk Python</A>
83below.
Jack Jansen8f2d8021996-08-05 15:34:45 +000084
Jack Jansen4c1e56c1996-08-06 16:16:20 +000085<LI> Waste, a TextEdit replacement written by Marco Piovanelli, <A
86HREF="mailto:piovanel@kagi.com">&lt;piovanel@kagi.com&gt;</A>. Python
Jack Jansenc1218bc2001-04-25 22:11:24 +000087was built using version 2.0, which is included in the CodeWarrior
88package. You can also obtain it from <A
Jack Jansen16904092001-08-16 14:10:56 +000089HREF="http://www.merzwaren.com/waste">&lt;http://www.merzwaren.com/waste&gt;</A>
Jack Jansen4c1e56c1996-08-06 16:16:20 +000090and various other places.
Jack Jansen8f2d8021996-08-05 15:34:45 +000091
Jack Jansen1473af71997-05-07 15:43:38 +000092<LI> Gdbm library for the Mac. Available from Jack's Mac software page at
93<A HREF="http://www.cwi.nl/~jack/macsoftware.html">
94http://www.cwi.nl/~jack/macsoftware.html</A> and <A HREF="ftp://ftp.cwi.nl/pub/jack/mac">
Jack Jansen16904092001-08-16 14:10:56 +000095ftp://ftp.cwi.nl/pub/jack/mac</A>.
Jack Jansen1473af71997-05-07 15:43:38 +000096
97<LI> JPEG library by the Independent JPEG Group. A version including
98Mac projects can be found at Jack's page mentioned above.
99The most recent JPEG library can always be obtained from <A
Jack Jansen16904092001-08-16 14:10:56 +0000100HREF="ftp://ftp.uu.net/graphics/jpeg/">ftp://ftp.uu.net/graphics/jpeg/</A>.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000101
Jack Jansen1473af71997-05-07 15:43:38 +0000102<LI> The netpbm/pbmplus, libtiff, zlib and png libraries. The netpbm distribution
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000103(which includes libtiff) is generally available on Internet ftp
104servers. For Python pbmplus, an older incarnation of netpbm, is
105functionally identical to netpbm, since Python only uses the library
106and not the complete applications. A distribution with correct
Jack Jansen1473af71997-05-07 15:43:38 +0000107projects and library source only is available from, you guessed it, Jack's Mac software
Jack Jansen16904092001-08-16 14:10:56 +0000108page mentioned above.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000109
Jack Jansen8f2d8021996-08-05 15:34:45 +0000110</UL>
111
112<H2>Setting Up</H2>
113
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000114Now that you have collected everything you should start with building
Jack Jansen1473af71997-05-07 15:43:38 +0000115the various parts. If you don't want to fix
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000116access paths try to set things up as follows:
117
Jack Jansen8f2d8021996-08-05 15:34:45 +0000118<PRE>
119Top-level-folder:
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000120 GUSI2
Jack Jansen8f2d8021996-08-05 15:34:45 +0000121 imglibs
Jack Jansende570301998-08-27 13:39:01 +0000122 jpeg
123 netpbm
124 libtiff
Jack Jansen1473af71997-05-07 15:43:38 +0000125 zlib
Jack Jansende570301998-08-27 13:39:01 +0000126 png
Jack Jansen1473af71997-05-07 15:43:38 +0000127 gdbm
Jack Jansen8f2d8021996-08-05 15:34:45 +0000128 Python
Jack Jansen90cf4912000-02-11 23:14:46 +0000129 Modules
130 ...
131 Mac
132 Modules
133 Build
134 ...
Jack Jansene0b1e6a2002-01-08 23:03:45 +0000135 Tcl/Tk Folder 8.3.4
Jack Jansen8f2d8021996-08-05 15:34:45 +0000136</PRE>
137
Jack Jansende570301998-08-27 13:39:01 +0000138If your setup of the libraries is exactly the same as mine (which is
139not very likely, unless you happen to work from the same CVS
140repository) you can use the project <code>buildlibs.prj</code> in the
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000141<code>:Mac:Build</code> folder to build all needed libraries in one
Jack Jansende570301998-08-27 13:39:01 +0000142fell swoop, otherwise you will have to build the libraries one by
143one. <p>
144
Jack Jansene0b1e6a2002-01-08 23:03:45 +0000145First build GUSI, both the normal one and the Carbon variant.
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000146 <p>
Jack Jansen95375861999-03-10 15:51:56 +0000147
Jack Jansen16e99c01996-09-07 17:11:26 +0000148Next, in
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000149<code>libjpeg</code>, <code>pbmplus</code>,
Jack Jansen1473af71997-05-07 15:43:38 +0000150<code>zlib</code>, <code>libpng</code>, <code>gdbm</code>,
Jack Jansena2139fe1998-02-25 15:40:35 +0000151and<code>libtiff</code> you build all projects. Usually the projects are in "mac"
Jack Jansen1473af71997-05-07 15:43:38 +0000152subfolders, sometimes they are in the main folder. Tcl/tk is a special
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000153case, see below.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000154
155<H2><A NAME="tcltk">Building Tcl/Tk</H2>
156
Jack Jansene0b1e6a2002-01-08 23:03:45 +0000157Tkinter has been built with Tcl/Tk 8.3.4. Load the Mac source distribution
158from the tcl sourceforge site and build it. Build with CW7, but you will
159need CW6 to build the MDEF resource (or copy it from a binary
160installation). As of this writing the projects are CW6, so they need
161massaging to build with CW7, but this is a lot less work than applying
162all the workarounds for CW6 that the build instructions give. <P>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000163
Jack Jansen8b41d532000-05-07 22:08:42 +0000164Note that if you use a different release of Tcl and Tk than the ones
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000165I have used you may have to adapt the Python <code>tkresources.rsrc</code> file.
Jack Jansene0b1e6a2002-01-08 23:03:45 +0000166This is easiest done by building <code>Tk8.3.shlb</code> and copying the TEXT, ICON
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000167and CRSR resources from it to <code>tkresources.rsrc</code>. This allows
168the <code>_tkinter</code> module to work without an installed Tk/Tcl on your
Jack Jansen8b41d532000-05-07 22:08:42 +0000169machine. <P>
170
171Also note that the <code>_tkinter.ppc.slb</code> that is normally distributed
Jack Jansene0b1e6a2002-01-08 23:03:45 +0000172in the <code>lib-dynload</code> folder is the one from the Imaging extension,
Jack Jansen8b41d532000-05-07 22:08:42 +0000173which has some extra features needed by PIL (and which features should not
174hinder normal operation).
Jack Jansen27b10ec1996-08-23 15:44:18 +0000175
Jack Jansen8f2d8021996-08-05 15:34:45 +0000176</UL>
177
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000178Build first the Tcl library, then
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000179SimpleTcl (test it by typing <code>ls -l</code> in the window you get)
180then the Tk library, then SimpleTk (which can again be tested with
181<code>ls -l</code>). If this all worked you are all set to try
Jack Jansen8f2d8021996-08-05 15:34:45 +0000182building Python.
183
184<H2>The organization of the Python source tree</H2>
185
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000186Time for a short break, while we have a look at the organization of
187the Python source tree. At the top level, we find the following
188folders:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000189
190<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000191<DT> Demo
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000192<DD> Demo programs that are not Mac-specific. Some of these may not
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000193work.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000194
195<DT> Extensions
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000196<DD> Extensions to the interpreter that are not Mac-specific. Contains
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000197the <code>img</code>, <code>Imaging</code> and <code>Numerical</code> extensions
198in this distribution.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000199
200<DT> Grammar
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000201<DD> The Python grammar. Included for reference only, you cannot build
202the parser on a Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000203
204<DT> Include
205<DD> Machine-independent header files.
206
207<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000208<DD> Machine-independent optional modules. Not all of these will work
209on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000210
Jack Jansene0b1e6a2002-01-08 23:03:45 +0000211<DT> Lib
212<DD> Machine-independent modules in Python.
213
214<DT> Lib:lib-dynload
215<DD> This is where the Classic and Carbon dynamically-loaded plugin modules live.
216
Jack Jansen8f2d8021996-08-05 15:34:45 +0000217<DT> Objects
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000218<DD> Machine-independent code for various object types. Most of these are
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000219not really optional: the interpreter will not function without them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000220
221<DT> Parser
222<DD> The Python parser (machine-independent).
223
Jack Jansen8f2d8021996-08-05 15:34:45 +0000224<DT> Python
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000225<DD> The core interpreter. Most files are machine-independent, some
226are unix-specific and not used on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000227
228<DT> Tools
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000229<DD> Tools for python developers. Contains <code>modulator</code> which
230builds skeleton C extension modules, <code>bgen</code> which generates
231complete interface modules from information in C header files and
232<code>freeze</code> which is used to turn Python scripts into real
233applications (used by MacFreeze and BuildApplication) There are some
234readme files, but more documentation is sorely needed.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000235
Jack Jansen8f2d8021996-08-05 15:34:45 +0000236</DL>
237
238All the mac-specific stuff lives in the <code>Mac</code> folder:
239<DL>
Jack Jansenc256ece1999-02-03 13:09:27 +0000240<DT> Build
241<DD> This is where the project files live and where you build the
242libraries, shared libraries, executables and plugin modules. All the
243resulting binaries, except for intermedeate results, are deposited in
Jack Jansena598bc41999-02-10 23:08:24 +0000244the toplevel folder or the Mac:PlugIns folder (for plugin modules).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000245
246<DT> Compat
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000247<DD> Unix-compatability routines. Most of these are not used anymore,
248since GUSI provides a rather complete emulation, but you may need
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000249these if you are trying to build a non-GUSI python.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000250
251<DT> Demo
252<DD> Mac-specific demo programs, some of them annotated.
253
254<DT> Include
255<DD> Mac-specific but compiler-independent include files.
256
257<DT> Lib
Jack Jansene0b1e6a2002-01-08 23:03:45 +0000258<DD> Mac-specific standard modules. The <code>Carbon</code> package
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000259contains modules specifically needed with various MacOS toolbox
Jack Jansene0b1e6a2002-01-08 23:03:45 +0000260interface modules, both for Carbon and classic PPC, despite the name.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000261
262<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000263<DD> Mac-specific builtin modules. Theoretically these are all
264optional, but some are rather essential (like
Jack Jansen16904092001-08-16 14:10:56 +0000265<code>macosmodule</code>). A lot of these modules are generated with
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000266<code>bgen</code>, in which case the bgen input files are included so
267you can attempt to regenerate them or extend them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000268
269<DT> MPW
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000270<DD> MPW-specific files. These have not been used or kept up-to-date
271for a long time, so use at your own risk.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000272
273<DT> mwerks
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000274<DD> Mwerks-specific sources and headers. Contains glue code for
275Pythons shared-library architecture, a replacement for
276<code>malloc</code> and a directory with various projects for building
277variations on the Python interpreter. The <code>mwerks_*.h</code>
278files here are the option-setting files for the various interpreters
279and such, comparable to the unix command-line <code>-D</code> options
280to the compiler. Each project uses the correct option file as its
281"prefix file" in the "C/C++ language" settings. Disabling optional
282modules (for the 68K interpreter), building non-GUSI interpreters and
283various other things are accomplished by modifying these files (and
284possibly changing the list of files included in the project window, of
285course).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000286
Jack Jansene0b1e6a2002-01-08 23:03:45 +0000287<DT> OSX
288<DD> Specific to unix-Python (also known as MachoPython) on OSX, not used
289by MacPython.
290
291<DT> OSXResources
292<DD> Specific to unix-Python (also known as MachoPython) on OSX, not used
293by MacPython.
Jack Jansenc256ece1999-02-03 13:09:27 +0000294
Jack Jansen8f2d8021996-08-05 15:34:45 +0000295<DT> Python
296<DD> Mac-specific parts of the core interpreter.
297
298<DT> Resources
299<DD> Resource files needed to build the interpreter.
300
301<DT> Scripts
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000302<DD> A collection of various mac-specific Python scripts. Some are
303essential, some are useful but few are documented, so you will have to
304use your imagination to work them out.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000305
Jack Jansenc256ece1999-02-03 13:09:27 +0000306<DT> Tools
307<DD> A collection of tools, usually bigger than those in the scripts
308folder. The important ones here are the IDE and macfreeze. The IDE is built
309with the buildIDE.py script, which puts the resulting applet in the toplevel
310folder. Macfreeze is usually invoked through the BuildApplication script,
311but for more control over the freezing process you can run the main script here.
312
313
Jack Jansen8f2d8021996-08-05 15:34:45 +0000314<DT> Unsupported
315<DD> Modules that are not supported any longer but may still work with a little effort.
316</DL>
317
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000318<H2>Building the PPC interpreter</H2>
Jack Jansene0b1e6a2002-01-08 23:03:45 +0000319<em>This is different since 2.1. You are best off using the fullbuild.py
Jack Jansen16904092001-08-16 14:10:56 +0000320script, see <a href="#fullbuild">below</a>. </em><p>
321
Jack Jansenc256ece1999-02-03 13:09:27 +0000322First you optionally build the external libraries with buildlibs.prj. Next,
323the projects for
Jack Jansen16904092001-08-16 14:10:56 +0000324interpreter and core library are linked together, so
325building the PythonInterpreterClassic and/or PythonInterpreterCarbon target
326in <code>PythonInterpreter.prj</code>
327will result in everything being built. The result, however, is an "Application
328template", (filetype Atmp). If you don't use fullbuild you can manually
329turn either of these into an interpreter by copying it to PythonInterpreter
330and setting the filetype to APPL (with ResEdit or some such). <p>
331
332Fullbuild does this for you, and the Atmp files is also how ConfigurePythonCarbon
333and ConfigurePythonClassic work their magic. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000334
Jack Jansenc7dd34b2002-01-30 10:42:59 +0000335You will get about 100 warnings on "missing prototype" for the various module init
336routines, ignore these. You will also get numerous warnings on functions from GUSI which
337override functions from MSL, ignore these too. <p>
338
Jack Jansenc256ece1999-02-03 13:09:27 +0000339For completeness sake here is a breakdown of the projects:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000340
341<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000342
Jack Jansen16904092001-08-16 14:10:56 +0000343<DT> PythonCore
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000344<DD> The shared library that contains the bulk of the interpreter and
Jack Jansen16904092001-08-16 14:10:56 +0000345its resources. It has targets for PythonCore and PythonCoreCarbon.
346It is a good idea to immedeately put an alias to this
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000347shared library in the <code>Extensions</code> folder of your system
348folder. Do exactly that: put an <em>alias</em> there, copying or
Jack Jansen3412c5d1997-08-27 14:08:22 +0000349moving the file will cause you grief later if you rebuild the library and
Jack Jansen16904092001-08-16 14:10:56 +0000350forget to copy it to the extensions folder again. The ConfigurePythonXXX applets
351will also do this. <br>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000352
Jack Jansen3b805261999-02-14 23:12:06 +0000353<DT> PythonInterpeter
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000354<DD> The interpreter. This is basically a routine to call out to the
Jack Jansen3b805261999-02-14 23:12:06 +0000355shared library. Unlike in previous releases the same program is used for
Jack Jansene0b1e6a2002-01-08 23:03:45 +0000356creating applets (for which formerly PythonApplet was used). There are 4 targets
357in here: two for the classic and carbon templates (which are normally used, and
358converted to PythonInterpreter by the ConfigurePython* applets) and two
359for PythonInterpreter in it's classic and carbon version.<p>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000360
Jack Jansenc256ece1999-02-03 13:09:27 +0000361<DT> Plugin projects
Jack Jansen16904092001-08-16 14:10:56 +0000362<DD> Each plugin module has a separate project, and these can be rebuilt on
363the fly. Fullbuild (or actually it's little helper genpluginprojects) takes
364care of this.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000365</DL>
366
Jack Jansen3412c5d1997-08-27 14:08:22 +0000367After creating the alias to <code>PythonCore</code> you remove any old
Jack Jansen16904092001-08-16 14:10:56 +0000368<code>Python XXXX Preferences</code> file from the <code>Preferences</code> folder
Jack Jansen061ac501996-10-22 15:27:56 +0000369(if you had python installed on your system before) and run the interpreter once
Jack Jansen3412c5d1997-08-27 14:08:22 +0000370to create the correct preferences file. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000371
Jack Jansenc256ece1999-02-03 13:09:27 +0000372Next, you have to build the extension modules.
Jack Jansen16904092001-08-16 14:10:56 +0000373If you don't use fullbuild simply open each project and build it.
Jack Jansena598bc41999-02-10 23:08:24 +0000374<p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000375
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000376Finally, you must build the standard applets:
Jack Jansen16904092001-08-16 14:10:56 +0000377<code>EditPythonPrefs</code>, <code>BuildApplet</code>, etc. For the N-th time:
378fullbuild does this for you, but you can also manually drag/drop them onto
379BuildApplet. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000380
381<BLOCKQUOTE>
Jack Jansen16904092001-08-16 14:10:56 +0000382<a name="fullbuild"></a>
383The <code>fullbuild</code> script can be used to build
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000384everything, but you need a fully-functional interpreter before you can
385use it (and one that isn't rebuilt in the process: you cannot rebuild
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000386a running program). You could copy the interpreter to a different
387place and use that to run fullbuild. The <code>PythonStandSmall.prj</code>
388project builds an interpreter that is suited to this, and it can also come
389in handy if you need to debug things (which is easier in a static program). <p>
Jack Jansene66b8c81997-05-29 14:57:07 +0000390
Jack Jansen8f2d8021996-08-05 15:34:45 +0000391</BLOCKQUOTE>
392
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000393You are all set now, and should read the release notes and
Jack Jansen3412c5d1997-08-27 14:08:22 +0000394<code>ReadMe</code> file from the <code>Mac</code> folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000395
Jack Jansene0b1e6a2002-01-08 23:03:45 +0000396Rebuilding .exp files is no longer needed since CodeWarrior 7.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000397
Jack Jansen95375861999-03-10 15:51:56 +0000398<H2><a name="cvs">Using the CVS source archive</a></H2>
Jack Jansenc256ece1999-02-03 13:09:27 +0000399
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000400It is possible (and probably best) to access the Python sources through remote CVS. The
Jack Jansen65f685b1999-04-12 09:25:23 +0000401advantage of this is that you get the very latest sources, so any bug
402fixed or new features will be immedeately available. This is also the
403disadvantage, of course: as this is the same tree as is used for
404development it may sometimes be a little less stable. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000405
406The CVS client of choice is Alexandre Parenteau's MacCVS. It can be
Jack Jansen65f685b1999-04-12 09:25:23 +0000407obtained through the <a href="http://www.wincvs.org">WinCVS
408homepage</a>. MacCVS uses Internet Config to set file types correctly
409based on the filename extension. In the maccvs preferences you should
410also set (in the "binary files" section) "use mac encoding:
411applesingle" and (in the "text files" section) "use ISO latin 1
Jack Jansenc256ece1999-02-03 13:09:27 +0000412conversion". <p>
413
Jack Jansen16904092001-08-16 14:10:56 +0000414<blockquote>
415There is one group of people for whom MacCVS is not the best choice: people with
416checkin rights to the Python repository. You will have to use MacCVS Pro
417(completely unrelated) from www.maccvs.org, because it has working SSH support.
418</blockquote>
419
420It is a good idea to disable Quicktime Exchange in the Quicktime
Jack Jansen8b41d532000-05-07 22:08:42 +0000421control panel. Quicktime Exchange will magically map some extensions to
422filetypes, and this can seriously hinder you if, for instance, <code>.bmp</code>
423is not a Windows bitmap file. <p>
424
Jack Jansen16904092001-08-16 14:10:56 +0000425The Python sources are checked out from the main
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000426Python CVS archive on sourceforge.net, see the <a
Jack Jansen65f685b1999-04-12 09:25:23 +0000427href="http://www.python.org/download/cvs.html">Source access via
428CVS</a> page for details. When you check the sources out you will get
Jack Jansen95375861999-03-10 15:51:56 +0000429something like <code>Python:dist:src</code>, and under that the
Jack Jansen16904092001-08-16 14:10:56 +0000430<code>Modules</code>, <code>Lib</code>, <code>Mac</code> etc hierarchy. The
431<code>src</code> folder can be renamed to <code>Python</code>, and
Jack Jansen95375861999-03-10 15:51:56 +0000432is what this document refers to as the "toplevel Python folder". <P>
Jack Jansenc256ece1999-02-03 13:09:27 +0000433
Jack Jansen16904092001-08-16 14:10:56 +0000434The CVS repository does not contain all the projects for the plugin modules,
435these are built with <code>fullbuild.py</code> normally. For this reason
436it is probably a good idea to first build <code>PythonStandSmall.prj</code>,
437which builds a fairly minimal interpreter, and then follow the
438<a href="#fullbuild">fullbuild instructions</a>.
Jack Jansendae108c2000-02-11 23:17:14 +0000439
Jack Jansen8f2d8021996-08-05 15:34:45 +0000440<H2>Odds and ends</H2>
441
442Some remarks that I could not fit in elsewhere:
443
444<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000445
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000446<LI> It may be possible to use the <code>PythonCore</code> shared
447library to embed Python in another program, if your program can live
Jack Jansen1473af71997-05-07 15:43:38 +0000448with using GUSI for I/O. Use PythonCore in stead of your MSL C library
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000449(or, at the very least, link it before the normal C library).
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000450
Jack Jansene0b1e6a2002-01-08 23:03:45 +0000451<LI> <a name="extending"></a>It is possible to build PPC extension
452modules without building a complete Python. The binary distribution
453installer can optionally install all the needed folders (the develop
454option). A template for a dynamic module can be found in
Jack Jansen3412c5d1997-08-27 14:08:22 +0000455<code>xx.prj</code>.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000456
457<LI> The Python shared library architecture is a variant of the architecture
458described as "application with shared libraries and dropins" in the MetroWerks
459"Targeting MacOS" documentation. The Python Application and applet-template use
Jack Jansen1473af71997-05-07 15:43:38 +0000460the <code>MSL AppRuntime.Lib</code> runtime library (with properly set CFM
461initialization and termination routines). PythonCore uses <code>MSL Runtime.Lib</code>,
462which is really intended for standalone programs but which we fool into working by
463providing a dummy main program.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000464It is linked statically into PythonCore (and exported to the applications and plugins)
465so we do not have to distribute yet another shared library. Plugin modules use
Jack Jansen1473af71997-05-07 15:43:38 +0000466<code>MSL ShlibRuntime.Lib</code> (not the dropin runtime: modules are never unloaded)
467and obtain the rest from PythonCore. PythonCore uses a
Jack Jansen27b10ec1996-08-23 15:44:18 +0000468non-standard initialization entry point, <code>__initialize_with_resources</code>, to
Jack Jansen1473af71997-05-07 15:43:38 +0000469be able to obtain resources from the library file later on. Plugins can do the same
470(_tkinter does) or use the standard <code>__initialize</code> entry point.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000471
472
Jack Jansen6ad8d131997-01-15 16:53:37 +0000473</UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000474</BODY>
475</HTML>