blob: e1a229e5861faab29d380c3bb6125d0143cdbdcd [file] [log] [blame]
Jack Jansen8f2d8021996-08-05 15:34:45 +00001<HTML>
2<HEAD>
3<TITLE>Building Mac Python from source</TITLE>
4</HEAD>
5<BODY>
6<H1>Building Mac Python from source</H1>
7<HR>
Jack Jansen8f2d8021996-08-05 15:34:45 +00008
Jack Jansen4c1e56c1996-08-06 16:16:20 +00009This document explains how to build MacPython from source. This is
10necessary if you want to write extension modules for 68K Python, and
Jack Jansenc256ece1999-02-03 13:09:27 +000011is also necessary if you want to make modifications to the Python core.
12Building Python is not something to be undertaken lightly,
13you need a reasonable working
Jack Jansen4c1e56c1996-08-06 16:16:20 +000014knowledge of the CodeWarrior development environment, a good net
15connection and probably quite some time too. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +000016
Jack Jansen4c1e56c1996-08-06 16:16:20 +000017The information density in this file is high, so you should probably
18print it and read it at your leasure. Most things are explained only
19once (and probably in the wrong place:-). <p>
20
Jack Jansen90cf4912000-02-11 23:14:46 +000021<blockquote>
22First a warning: this information may become outdated if a new CodeWarrior is
23released after MacPython. The
24<a href="http://www.cwi.nl/~jack/macpython.html">MacPython homepage</a> will
25hopefully have updated instructions in that case.
26</blockquote>
27
Jack Jansenc256ece1999-02-03 13:09:27 +000028I am very interested in feedback on this document, send your
Jack Jansen4c1e56c1996-08-06 16:16:20 +000029comments to the <A
30HREF="http://www.python.org/sigs/pythonmac-sig/">Mac Python Special
31Interest Group</A>.
Jack Jansen8f2d8021996-08-05 15:34:45 +000032
33<H2>What you need.</H2>
34
35The following things you definitely need:
36
37<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000038
Jack Jansen4c1e56c1996-08-06 16:16:20 +000039<LI> You need a MacPython source distribution, of course. You can
Jack Jansen95375861999-03-10 15:51:56 +000040obtain one from <A HREF="ftp://ftp.cwi.nl/pub/jack/python/mac">
41ftp://ftp.cwi.nl/pub/jack/python/mac</A> or from the companion webpage
42at <A HREF="http://www.cwi.nl/~jack/macpython.html">
43http://www.cwi.nl/~jack/macpython.html</A> (which has up-to-date links
44to the other packages needed too) and possibly also from the standard
45<A HREF="ftp://ftp.python.org/pub/python/mac">python.org ftp
Jack Jansen4c1e56c1996-08-06 16:16:20 +000046site</A>. Everything you need is also included in the standard Python
47source distribution, but the organization is different. Look in
48directory <code>Mac/mwerks/projects</code> for the project files and
Jack Jansenc256ece1999-02-03 13:09:27 +000049related stuff. <BR>
50
Jack Jansen65f685b1999-04-12 09:25:23 +000051An alternative is to check the sources straight out of the CVS
Jack Jansen95375861999-03-10 15:51:56 +000052repository, see below. Most of the packages mentioned here are also
53available through CVS. Check the section on <a href="#cvs">CVS
54repository use</a> below.
Jack Jansen8f2d8021996-08-05 15:34:45 +000055
Jack Jansen4c1e56c1996-08-06 16:16:20 +000056<LI> You need MetroWerks CodeWarrior. The current distribution has
Jack Jansenc256ece1999-02-03 13:09:27 +000057been built with CodeWarrior Pro 4. Ordering information is
Jack Jansen4c1e56c1996-08-06 16:16:20 +000058available on the <A HREF="http://www.metrowerks.com/">MetroWerks
Jack Jansena2139fe1998-02-25 15:40:35 +000059homepage</A>. Building Python with MPW or Think/Symantec C is
60probably impossible without major surgery.
Jack Jansen4c1e56c1996-08-06 16:16:20 +000061
62<LI> You need GUSI, the Grand Unified Socket Interface, by Matthias
Jack Jansen1473af71997-05-07 15:43:38 +000063Neeracher. The original CWGUSI is
Jack Jansen4c1e56c1996-08-06 16:16:20 +000064obtainable from <A
Jack Jansenf3dd5aa1996-12-23 17:29:51 +000065HREF="ftp://sunsite.cnlab-switch.ch/software/platform/macos/src">
Jack Jansene66b8c81997-05-29 14:57:07 +000066ftp://sunsite.cnlab-switch.ch/software/platform/macos/src</A>.
Jack Jansen3412c5d1997-08-27 14:08:22 +000067At the moment Python is built with a slightly modified version of GUSI,
Jack Jansena598bc41999-02-10 23:08:24 +000068these modifications are available in folder <code>Python:Mac:GUSI-mods</code>. <br>
69
70The modified GUSI is also in the MacPython cvs source repository, in the
71directory <code>lib-src/CWGUSI</code>. However, some files contain slashes in
72their names, something CVS seriously frowns upon, and each slash has been
73replaced by <code>"_s_"</code>. There is a script
74<code>Mac:scripts:fixgusidir.py</code> which you should run after checking CWGUSI
75out
Jack Jansen4c1e56c1996-08-06 16:16:20 +000076
Jack Jansen8f2d8021996-08-05 15:34:45 +000077</UL>
78
Jack Jansen4c1e56c1996-08-06 16:16:20 +000079<A NAME="optional">The MacPython project files are configured to
80include a plethora of optional modules</A>, and these modules need a
Jack Jansena2139fe1998-02-25 15:40:35 +000081number of extra packages. To use the project files as-is you have to
Jack Jansen27b10ec1996-08-23 15:44:18 +000082download these packages too. PPC and CFM68K Python have all such modules as
Jack Jansen4c1e56c1996-08-06 16:16:20 +000083dynamically loaded modules, so if you don't need a certain package it
Jack Jansen27b10ec1996-08-23 15:44:18 +000084suffices to just refrain from builing the extension module. For static 68K
Jack Jansen4c1e56c1996-08-06 16:16:20 +000085Python things are a bit more complicated: you have to edit the
86interpreter project file to remove the reference to the module (and
Jack Jansen27b10ec1996-08-23 15:44:18 +000087the libraries it uses), and edit the <code>Mac:mwerks:mwerks_nonshared_config.h</code>
88file to remove the <code>USE_...</code> line. Here are the locations for the various things
Jack Jansen4c1e56c1996-08-06 16:16:20 +000089you need:
Jack Jansen8f2d8021996-08-05 15:34:45 +000090
91<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000092
Jack Jansen8b41d532000-05-07 22:08:42 +000093<LI> Tcl and Tk are in a sad state on the Mac, the standard source distributions
94simply don't compile, so I have created a distribution especially for use
95with MacPython.
96See the section on <A HREF="#tcltk">building Tcl/Tk Python</A>
97below.
Jack Jansen8f2d8021996-08-05 15:34:45 +000098
Jack Jansen4c1e56c1996-08-06 16:16:20 +000099<LI> Waste, a TextEdit replacement written by Marco Piovanelli, <A
100HREF="mailto:piovanel@kagi.com">&lt;piovanel@kagi.com&gt;</A>. Python
Jack Jansena2139fe1998-02-25 15:40:35 +0000101was built using version 1.3, which you can obtain from <A
102HREF="http://www.boingo.com/waste">&lt;http://www.boingo.com/waste&gt;</A>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000103and various other places.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000104
Jack Jansen1473af71997-05-07 15:43:38 +0000105<LI> Gdbm library for the Mac. Available from Jack's Mac software page at
106<A HREF="http://www.cwi.nl/~jack/macsoftware.html">
107http://www.cwi.nl/~jack/macsoftware.html</A> and <A HREF="ftp://ftp.cwi.nl/pub/jack/mac">
Jack Jansena598bc41999-02-10 23:08:24 +0000108ftp://ftp.cwi.nl/pub/jack/mac</A>. Also in the MacPython cvs repository at
109<code>lib-src/gdbm</code>.
Jack Jansen1473af71997-05-07 15:43:38 +0000110
111<LI> JPEG library by the Independent JPEG Group. A version including
112Mac projects can be found at Jack's page mentioned above.
113The most recent JPEG library can always be obtained from <A
Jack Jansena598bc41999-02-10 23:08:24 +0000114HREF="ftp://ftp.uu.net/graphics/jpeg/">ftp://ftp.uu.net/graphics/jpeg/</A>. Again,
115also in the MacPython cvs repository at <code>lib-src/jpeg</code>.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000116
Jack Jansen1473af71997-05-07 15:43:38 +0000117<LI> The netpbm/pbmplus, libtiff, zlib and png libraries. The netpbm distribution
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000118(which includes libtiff) is generally available on Internet ftp
119servers. For Python pbmplus, an older incarnation of netpbm, is
120functionally identical to netpbm, since Python only uses the library
121and not the complete applications. A distribution with correct
Jack Jansen1473af71997-05-07 15:43:38 +0000122projects and library source only is available from, you guessed it, Jack's Mac software
Jack Jansena598bc41999-02-10 23:08:24 +0000123page mentioned above. And, guessed it again, in the MacPython cvs repository
124at <code>lib-src/netpbm</code>, etc. The only gotcha is that libtiff lives in
125<code>lib-src/netpbm/libtiff</code>, for historical reasons.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000126
Jack Jansen8f2d8021996-08-05 15:34:45 +0000127</UL>
128
129<H2>Setting Up</H2>
130
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000131Now that you have collected everything you should start with building
Jack Jansen1473af71997-05-07 15:43:38 +0000132the various parts. If you don't want to fix
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000133access paths try to set things up as follows:
134
Jack Jansen8f2d8021996-08-05 15:34:45 +0000135<PRE>
136Top-level-folder:
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000137 CWGUSI
Jack Jansen8f2d8021996-08-05 15:34:45 +0000138 imglibs
Jack Jansende570301998-08-27 13:39:01 +0000139 jpeg
140 netpbm
141 libtiff
Jack Jansen1473af71997-05-07 15:43:38 +0000142 zlib
Jack Jansende570301998-08-27 13:39:01 +0000143 png
Jack Jansen1473af71997-05-07 15:43:38 +0000144 gdbm
Jack Jansen8f2d8021996-08-05 15:34:45 +0000145 Python
Jack Jansen90cf4912000-02-11 23:14:46 +0000146 Modules
147 ...
148 Mac
149 Modules
150 Build
151 ...
Jack Jansen32617191997-08-19 14:01:16 +0000152 Tcl/Tk Folder
153 tcl8.0
154 tk8.0
Jack Jansena2139fe1998-02-25 15:40:35 +0000155 MoreFiles 1.4.3
156 Waste 1.3 distribution (if you want waste)
Jack Jansen8f2d8021996-08-05 15:34:45 +0000157</PRE>
158
Jack Jansende570301998-08-27 13:39:01 +0000159If your setup of the libraries is exactly the same as mine (which is
160not very likely, unless you happen to work from the same CVS
161repository) you can use the project <code>buildlibs.prj</code> in the
Jack Jansenc256ece1999-02-03 13:09:27 +0000162<code>:Mac:build.mac</code> folder to build all needed libraries in one
Jack Jansende570301998-08-27 13:39:01 +0000163fell swoop, otherwise you will have to build the libraries one by
164one. <p>
165
Jack Jansen1473af71997-05-07 15:43:38 +0000166First build GUSI. If you didn't get the python-specific GUSI you have to
167move the files from the "CWGUSI-mods" to the right
Jack Jansen3412c5d1997-08-27 14:08:22 +0000168place in the CWGUSI distribution folder. Build the MSL version for your
169platform (ppc, 68k, cfm68k). <p>
Jack Jansen16e99c01996-09-07 17:11:26 +0000170
Jack Jansen95375861999-03-10 15:51:56 +0000171<em>Note:</em> always rebuild the CWGUSI libraries, even if you have
172checked them out from the CVS repository. <P>
173
Jack Jansen16e99c01996-09-07 17:11:26 +0000174Next, in
Jack Jansen1473af71997-05-07 15:43:38 +0000175<code>MoreFiles</code>, <code>libjpeg</code>, <code>pbmplus</code>,
176<code>zlib</code>, <code>libpng</code>, <code>gdbm</code>,
Jack Jansena2139fe1998-02-25 15:40:35 +0000177and<code>libtiff</code> you build all projects. Usually the projects are in "mac"
Jack Jansen1473af71997-05-07 15:43:38 +0000178subfolders, sometimes they are in the main folder. Tcl/tk is a special
Jack Jansen27b10ec1996-08-23 15:44:18 +0000179case, see below. Of course, if you are only interested in one of
180static 68K, CFM68K or PPC you can skip building the other libraries.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000181
182<H2><A NAME="tcltk">Building Tcl/Tk</H2>
183
Jack Jansen8b41d532000-05-07 22:08:42 +0000184The Tcl/Tk 8.3.0 source distribution does not work on the Mac. I have created
185an archive of the sources that I used to build _tkinter for MacPython,
186you can obtain this from <a
187href="ftp://ftp.cwi.nl/pub/jack/python/mac/tcltk830src-for-python.sit">
188ftp://ftp.cwi.nl/pub/jack/python/mac/tcltk830src-for-python.sit</a>. Only the
189libraries needed to build _tkinter for PPC have been fixed. <P>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000190
Jack Jansen8b41d532000-05-07 22:08:42 +0000191Note that if you use a different release of Tcl and Tk than the ones
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000192I have used you may have to adapt the Python <code>tkresources.rsrc</code> file.
193This is easiest done by building <code>SimpleTk</code> and copying the TEXT, ICON
194and CRSR resources from it to <code>tkresources.rsrc</code>. This allows
195the <code>_tkinter</code> module to work without an installed Tk/Tcl on your
Jack Jansen8b41d532000-05-07 22:08:42 +0000196machine. <P>
197
198Also note that the <code>_tkinter.ppc.slb</code> that is normally distributed
199in the <code>PlugIns</code> folder is the one from the Imaging extension,
200which has some extra features needed by PIL (and which features should not
201hinder normal operation).
Jack Jansen27b10ec1996-08-23 15:44:18 +0000202
Jack Jansen8f2d8021996-08-05 15:34:45 +0000203</UL>
204
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000205Build first the Tcl library, then
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000206SimpleTcl (test it by typing <code>ls -l</code> in the window you get)
207then the Tk library, then SimpleTk (which can again be tested with
208<code>ls -l</code>). If this all worked you are all set to try
Jack Jansen8f2d8021996-08-05 15:34:45 +0000209building Python.
210
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000211<H2>Building Waste</H2>
212
213You do not need to build the Waste libraries, as Python includes the
Jack Jansena2139fe1998-02-25 15:40:35 +0000214source modules themselves.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000215
Jack Jansen8f2d8021996-08-05 15:34:45 +0000216<H2>The organization of the Python source tree</H2>
217
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000218Time for a short break, while we have a look at the organization of
219the Python source tree. At the top level, we find the following
220folders:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000221
222<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000223<DT> Demo
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000224<DD> Demo programs that are not Mac-specific. Some of these may not
225work, the file <code>README-Mac</code> has some details.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000226
227<DT> Extensions
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000228<DD> Extensions to the interpreter that are not Mac-specific. Contains
Jack Jansena598bc41999-02-10 23:08:24 +0000229the <code>img</code>, <code>Imaging</code> and <code>Numeric</code> extensions
230in this distribution. Nowadays, the extensions are all built in their own
231folders (unlike in older distributions, where img was incorporated in the main
232build procedure).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000233
234<DT> Grammar
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000235<DD> The Python grammar. Included for reference only, you cannot build
236the parser on a Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000237
238<DT> Include
239<DD> Machine-independent header files.
240
241<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000242<DD> Machine-independent optional modules. Not all of these will work
243on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000244
245<DT> Objects
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000246<DD> Machine-independent code for various objects. Most of these are
247not really optional: the interpreter will not function without them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000248
249<DT> Parser
250<DD> The Python parser (machine-independent).
251
Jack Jansen8f2d8021996-08-05 15:34:45 +0000252<DT> Python
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000253<DD> The core interpreter. Most files are machine-independent, some
254are unix-specific and not used on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000255
256<DT> Tools
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000257<DD> Tools for python developers. Contains <code>modulator</code>
258which builds skeleton C extension modules and <code>bgen</code> which
259generates complete interface modules from information in C header
260files. There are some readme files, but more documentation is sorely
261needed.
262
Jack Jansen8f2d8021996-08-05 15:34:45 +0000263</DL>
264
265All the mac-specific stuff lives in the <code>Mac</code> folder:
266<DL>
Jack Jansenc256ece1999-02-03 13:09:27 +0000267<DT> Build
268<DD> This is where the project files live and where you build the
269libraries, shared libraries, executables and plugin modules. All the
270resulting binaries, except for intermedeate results, are deposited in
Jack Jansena598bc41999-02-10 23:08:24 +0000271the toplevel folder or the Mac:PlugIns folder (for plugin modules).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000272
273<DT> Compat
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000274<DD> Unix-compatability routines. Some of these are not used anymore,
275since CWGUSI provides a rather complete emulation, but you may need
276these if you are trying to build a non-GUSI python.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000277
278<DT> Demo
279<DD> Mac-specific demo programs, some of them annotated.
280
281<DT> Include
282<DD> Mac-specific but compiler-independent include files.
283
284<DT> Lib
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000285<DD> Mac-specific standard modules. The <code>toolbox</code> folder
286contains modules specifically needed with various MacOS toolbox
287interface modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000288
289<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000290<DD> Mac-specific builtin modules. Theoretically these are all
291optional, but some are rather essential (like
292<code>macmodule</code>). A lot of these modules are generated with
293<code>bgen</code>, in which case the bgen input files are included so
294you can attempt to regenerate them or extend them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000295
296<DT> MPW
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000297<DD> MPW-specific files. These have not been used or kept up-to-date
298for a long time, so use at your own risk.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000299
300<DT> mwerks
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000301<DD> Mwerks-specific sources and headers. Contains glue code for
302Pythons shared-library architecture, a replacement for
303<code>malloc</code> and a directory with various projects for building
304variations on the Python interpreter. The <code>mwerks_*.h</code>
305files here are the option-setting files for the various interpreters
306and such, comparable to the unix command-line <code>-D</code> options
307to the compiler. Each project uses the correct option file as its
308"prefix file" in the "C/C++ language" settings. Disabling optional
309modules (for the 68K interpreter), building non-GUSI interpreters and
310various other things are accomplished by modifying these files (and
311possibly changing the list of files included in the project window, of
312course).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000313
Jack Jansenc256ece1999-02-03 13:09:27 +0000314<DT> PlugIns
315<DD> This is where the PPC and CFM68K dynamically-loaded plugin modules live.
316
Jack Jansen8f2d8021996-08-05 15:34:45 +0000317<DT> Python
318<DD> Mac-specific parts of the core interpreter.
319
320<DT> Resources
321<DD> Resource files needed to build the interpreter.
322
323<DT> Scripts
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000324<DD> A collection of various mac-specific Python scripts. Some are
325essential, some are useful but few are documented, so you will have to
326use your imagination to work them out.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000327
Jack Jansenc256ece1999-02-03 13:09:27 +0000328<DT> Tools
329<DD> A collection of tools, usually bigger than those in the scripts
330folder. The important ones here are the IDE and macfreeze. The IDE is built
331with the buildIDE.py script, which puts the resulting applet in the toplevel
332folder. Macfreeze is usually invoked through the BuildApplication script,
333but for more control over the freezing process you can run the main script here.
334
335
Jack Jansen8f2d8021996-08-05 15:34:45 +0000336<DT> Unsupported
337<DD> Modules that are not supported any longer but may still work with a little effort.
338</DL>
339
340<H2>Building the 68K interpreter</H2>
341
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000342If you have all the optional libraries mentioned <A
Jack Jansenc256ece1999-02-03 13:09:27 +0000343HREF="#optional">above</A> loaded building Python for 68K macs is a
344breeze: in the Mac:Build folder you build the libraries with buildlibs.prj
345and then the interpreter with PythonStandalone.prj. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000346
Jack Jansenc256ece1999-02-03 13:09:27 +0000347If you were previously running another copy of this Python release,
348from a binary installer for instance, you should
349first remove the <code>Python XXX preferences</code> file from your
350preference folder. Next, run the interpreter, in the toplevel folder. This will
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000351create a correct initial preferences file. You are now all set, and
352your tree should be completely compatible with a binary-only
353distribution. Read the release notes
354(<code>Relnotes-somethingorother</code>) and
Jack Jansenc256ece1999-02-03 13:09:27 +0000355<code>ReadMe</code> in the <code>Mac</code> folder. <p>
356
357If something goes wrong you may end up with a garbled preferences file. Removing
358it from the system folder and running Python once again will re-create it.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000359
Jack Jansen3412c5d1997-08-27 14:08:22 +0000360<H2>Building the PPC and CFM68K interpreter</H2>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000361
Jack Jansenc256ece1999-02-03 13:09:27 +0000362First you optionally build the external libraries with buildlibs.prj. Next,
363the projects for
364interpreter, core library and applet skeleton are all linked together, so
Jack Jansen3b805261999-02-14 23:12:06 +0000365building the fat target in <code>PythonEngine.prj</code>
366will result in everything being built. The
Jack Jansen3412c5d1997-08-27 14:08:22 +0000367resulting applications and fat shared library are deposited in the main
Jack Jansenc256ece1999-02-03 13:09:27 +0000368Python folder. Finally, you build all the plugins with the plugins.prj project.
369
370For completeness sake here is a breakdown of the projects:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000371
372<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000373
Jack Jansen3412c5d1997-08-27 14:08:22 +0000374<DT> PythonCore (with subprojects PythonCorePPC and PythonCoreCFM68K)
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000375<DD> The shared library that contains the bulk of the interpreter and
376its resources. It is a good idea to immedeately put an alias to this
377shared library in the <code>Extensions</code> folder of your system
378folder. Do exactly that: put an <em>alias</em> there, copying or
Jack Jansen3412c5d1997-08-27 14:08:22 +0000379moving the file will cause you grief later if you rebuild the library and
Jack Jansenc256ece1999-02-03 13:09:27 +0000380forget to copy it to the extensions folder again. The InstallPython applet
381will also do this, along with creating the plugin aliases.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000382
Jack Jansen3b805261999-02-14 23:12:06 +0000383<DT> PythonInterpeter
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000384<DD> The interpreter. This is basically a routine to call out to the
Jack Jansen3b805261999-02-14 23:12:06 +0000385shared library. Unlike in previous releases the same program is used for
386creating applets (for which formerly PythonApplet was used). <p>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000387
Jack Jansenc256ece1999-02-03 13:09:27 +0000388<DT> Plugin projects
Jack Jansena598bc41999-02-10 23:08:24 +0000389<DD> Each plugin module has a separate project. The <code>Plugins.prj</code>
390project tries to build them all, but is known to be flakey under CW Pro 4.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000391</DL>
392
Jack Jansen3412c5d1997-08-27 14:08:22 +0000393After creating the alias to <code>PythonCore</code> you remove any old
Jack Jansen061ac501996-10-22 15:27:56 +0000394<code>Python XXX Preferences</code> file from the <code>Preferences</code> folder
395(if you had python installed on your system before) and run the interpreter once
Jack Jansen3412c5d1997-08-27 14:08:22 +0000396to create the correct preferences file. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000397
Jack Jansenc256ece1999-02-03 13:09:27 +0000398Next, you have to build the extension modules.
399The <code>PlugIns.ppc</code> project has all the
Jack Jansena598bc41999-02-10 23:08:24 +0000400other projects as subprojects and builds everything (but see the gotcha above).
401<p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000402
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000403Finally, you must build the standard applets:
Jack Jansen3412c5d1997-08-27 14:08:22 +0000404<code>EditPythonPrefs</code>, <code>BuildApplet</code>, etc. This is
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000405easiest done with the <code>fullbuild</code> script from
Jack Jansen3412c5d1997-08-27 14:08:22 +0000406<code>Mac:scripts</code>. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000407
408<BLOCKQUOTE>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000409Actually, the <code>fullbuild</code> script can be used to build
410everything, but you need a fully-functional interpreter before you can
411use it (and one that isn't rebuilt in the process: you cannot rebuild
412a running program). You could copy the 68K interpreter to a different
413place and use that to run fullbuild, or use the standalone PPC python
414for this. I tend to keep a standalone interpreter in a safe place for
Jack Jansene66b8c81997-05-29 14:57:07 +0000415this use only. <p>
416
Jack Jansen8f2d8021996-08-05 15:34:45 +0000417</BLOCKQUOTE>
418
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000419You are all set now, and should read the release notes and
Jack Jansen3412c5d1997-08-27 14:08:22 +0000420<code>ReadMe</code> file from the <code>Mac</code> folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000421
Jack Jansen27b10ec1996-08-23 15:44:18 +0000422<H2>Rebuilding <code>.exp</code> files for PPC and CFM68K</H2>
423
424Occasionally it may be necessary to rebuild your PythonCore <code>.exp</code>
425file, a file that controls which symbols are exported by your PythonCore
426shared library. Rebuild it if you get unexpected undefined symbols when you
427are building a plugin module. <p>
428
429Rebuilding the .exp file is done by first removing the file and removing the
430reference to it in the project (in the "config" section). Next, build PythonCore.
431This will create a new .exp file. Edit this file to remove the references to
432the symbols <code>__initialize</code>, <code>__terminate</code>, <code>setjmp</code>,
Jack Jansen2afc2c71999-09-30 19:48:49 +0000433<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 +0000434CFM68K) <code>__start</code> and <code>dummy_init_routine</code>.
435Next, add the .exp file to the project
Jack Jansen27b10ec1996-08-23 15:44:18 +0000436again and rebuild PythonCore. <p>
437
438This rather convoluted procedure is needed to ensure that plugin modules don't
439accidentally link with those entrypoints from PythonCore, which will not work because
440those routines have to be in the same code fragment as they are used from.
441
Jack Jansen95375861999-03-10 15:51:56 +0000442<H2><a name="cvs">Using the CVS source archive</a></H2>
Jack Jansenc256ece1999-02-03 13:09:27 +0000443
Jack Jansen65f685b1999-04-12 09:25:23 +0000444It is possible to access the Python sources through remote CVS. The
445advantage of this is that you get the very latest sources, so any bug
446fixed or new features will be immedeately available. This is also the
447disadvantage, of course: as this is the same tree as is used for
448development it may sometimes be a little less stable. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000449
450The CVS client of choice is Alexandre Parenteau's MacCVS. It can be
Jack Jansen65f685b1999-04-12 09:25:23 +0000451obtained through the <a href="http://www.wincvs.org">WinCVS
452homepage</a>. MacCVS uses Internet Config to set file types correctly
453based on the filename extension. In the maccvs preferences you should
454also set (in the "binary files" section) "use mac encoding:
455applesingle" and (in the "text files" section) "use ISO latin 1
Jack Jansenc256ece1999-02-03 13:09:27 +0000456conversion". <p>
457
Jack Jansen8b41d532000-05-07 22:08:42 +0000458It is also a good idea to disable Quicktime Exchange in the Quicktime
459control panel. Quicktime Exchange will magically map some extensions to
460filetypes, and this can seriously hinder you if, for instance, <code>.bmp</code>
461is not a Windows bitmap file. <p>
462
Jack Jansen95375861999-03-10 15:51:56 +0000463The machine-independent Python sources are checked out from the main
Jack Jansen65f685b1999-04-12 09:25:23 +0000464Python CVS archive, see the <a
465href="http://www.python.org/download/cvs.html">Source access via
466CVS</a> page for details. When you check the sources out you will get
Jack Jansen95375861999-03-10 15:51:56 +0000467something like <code>Python:dist:src</code>, and under that the
468<code>Modules</code>, <code>Lib</code>, etc hierarchy. The
469<code>src</code> folder should be renamed to <code>Python</code>, and
470is what this document refers to as the "toplevel Python folder". <P>
Jack Jansenc256ece1999-02-03 13:09:27 +0000471
Jack Jansen90cf4912000-02-11 23:14:46 +0000472Next, <em>in a separate folder</em>, you check out the
473mac-specific sources. You then move the <code>Mac</code> folder from this
474checkout (the only folder with anything in it) to the Python source folder.
475Note that the checking out in a separate folder and moving is necessary,
476due to the way cvs works.
477
478The CVS path to use for the mac stuff can be found
Jack Jansen95375861999-03-10 15:51:56 +0000479at the <a href="http://www.cwi.nl/~jack/macpython.html">MacPython
480homepage</a>. Finally, you check out the external libraries needed in
Jack Jansen90cf4912000-02-11 23:14:46 +0000481the parent of the toplevel Python folder. The CVS path for these libraries is
Jack Jansen95375861999-03-10 15:51:56 +0000482also mentioned at the MacPython homepage. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000483
Jack Jansen95375861999-03-10 15:51:56 +0000484Neither of the pages mentioned above contains the passwords for the
485CVS sites, for obvious reasons, but they do contain instructions on
486how to obtain the passwords. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000487
Jack Jansen90cf4912000-02-11 23:14:46 +0000488You should end up with a folder structure as described at the top of this
489document. <p>
490
Jack Jansendae108c2000-02-11 23:17:14 +0000491Note that while the Mac folder is now a subfolder of your toplevel Python
492folder this does not mean that they "act as one" as far as CVS is concerned.
493To update all your sources you have to do a "cvs update" in the toplevel
494Python folder and another one in the Mac folder. This is again a cvs problem:
495it cannot deal with subpackages coming from different repositories. <p>
496
Jack Jansen8f2d8021996-08-05 15:34:45 +0000497<H2>Odds and ends</H2>
498
499Some remarks that I could not fit in elsewhere:
500
501<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000502
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000503<LI> It may be possible to use the <code>PythonCore</code> shared
504library to embed Python in another program, if your program can live
Jack Jansen1473af71997-05-07 15:43:38 +0000505with using GUSI for I/O. Use PythonCore in stead of your MSL C library
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000506(or, at the very least, link it before the normal C library). Let me
507know whether this works.
508
509<LI> It is possible to build PPC extension modules without building a
Jack Jansenc256ece1999-02-03 13:09:27 +0000510complete Python. The binary distribution installer can optionally install
511all the needed folders. A template for a dynamic module can be found in
Jack Jansen3412c5d1997-08-27 14:08:22 +0000512<code>xx.prj</code>.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000513
514<LI> The Python shared library architecture is a variant of the architecture
515described as "application with shared libraries and dropins" in the MetroWerks
516"Targeting MacOS" documentation. The Python Application and applet-template use
Jack Jansen1473af71997-05-07 15:43:38 +0000517the <code>MSL AppRuntime.Lib</code> runtime library (with properly set CFM
518initialization and termination routines). PythonCore uses <code>MSL Runtime.Lib</code>,
519which is really intended for standalone programs but which we fool into working by
520providing a dummy main program.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000521It is linked statically into PythonCore (and exported to the applications and plugins)
522so we do not have to distribute yet another shared library. Plugin modules use
Jack Jansen1473af71997-05-07 15:43:38 +0000523<code>MSL ShlibRuntime.Lib</code> (not the dropin runtime: modules are never unloaded)
524and obtain the rest from PythonCore. PythonCore uses a
Jack Jansen27b10ec1996-08-23 15:44:18 +0000525non-standard initialization entry point, <code>__initialize_with_resources</code>, to
Jack Jansen1473af71997-05-07 15:43:38 +0000526be able to obtain resources from the library file later on. Plugins can do the same
527(_tkinter does) or use the standard <code>__initialize</code> entry point.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000528
529
Jack Jansen6ad8d131997-01-15 16:53:37 +0000530</UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000531</BODY>
532</HTML>