blob: 716de8b5da11e043602446b31146fe5d1607deef [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 Jansen0eb5f2d2001-02-17 22:04:13 +00009<B>Note</B>: This document is still for Python 2.0. It is wildly incorrect.
10<p>
11
Jack Jansen4c1e56c1996-08-06 16:16:20 +000012This document explains how to build MacPython from source. This is
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000013necessary if you want to make modifications to the Python core. Building
14Python is not something to be undertaken lightly, you need a reasonable
15working knowledge of the CodeWarrior development environment, a good net
Jack Jansen4c1e56c1996-08-06 16:16:20 +000016connection and probably quite some time too. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +000017
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
26hopefully have updated instructions in that case.
27</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 Jansen95375861999-03-10 15:51:56 +000041obtain one from <A HREF="ftp://ftp.cwi.nl/pub/jack/python/mac">
42ftp://ftp.cwi.nl/pub/jack/python/mac</A> or from the companion webpage
43at <A HREF="http://www.cwi.nl/~jack/macpython.html">
44http://www.cwi.nl/~jack/macpython.html</A> (which has up-to-date links
45to the other packages needed too) and possibly also from the standard
46<A HREF="ftp://ftp.python.org/pub/python/mac">python.org ftp
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000047site</A>. <BR>
Jack Jansenc256ece1999-02-03 13:09:27 +000048
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000049A better alternative is to check the sources straight out of the CVS
Jack Jansen95375861999-03-10 15:51:56 +000050repository, see below. Most of the packages mentioned here are also
51available through CVS. Check the section on <a href="#cvs">CVS
52repository use</a> below.
Jack Jansen8f2d8021996-08-05 15:34:45 +000053
Jack Jansen4c1e56c1996-08-06 16:16:20 +000054<LI> You need MetroWerks CodeWarrior. The current distribution has
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000055been built with CodeWarrior Pro 5.2. Ordering information is
Jack Jansen4c1e56c1996-08-06 16:16:20 +000056available on the <A HREF="http://www.metrowerks.com/">MetroWerks
Jack Jansena2139fe1998-02-25 15:40:35 +000057homepage</A>. Building Python with MPW or Think/Symantec C is
58probably impossible without major surgery.
Jack Jansen4c1e56c1996-08-06 16:16:20 +000059
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000060<LI> You need GUSI version 2, the Grand Unified Socket Interface, by
61Matthias Neeracher. The original GUSI is obtainable from <A
Jack Jansen5f884c02000-12-12 22:14:14 +000062HREF="ftp://gusi.sourceforge.net/pub/gusi/">
63ftp://gusi.sourceforge.net/pub/gusi/</A>. At
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000064the moment Python is built with a slightly modified version of GUSI
652.1.1, so it may be better to check the <A
66HREF="http://www.cwi.nl/~jack/macpython.html">MacPython homepage</A>
67for a GUSI that is most easily used for building Python.
68<br>
Jack Jansena598bc41999-02-10 23:08:24 +000069
70The modified GUSI is also in the MacPython cvs source repository, in the
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000071directory <code>lib-src/GUSI2</code>. As GUSI is moving to sourceforge
72this info may be outdated by the time you read it so better check the
73MacPython homepage, probably.
Jack Jansen8f2d8021996-08-05 15:34:45 +000074</UL>
75
Jack Jansen4c1e56c1996-08-06 16:16:20 +000076<A NAME="optional">The MacPython project files are configured to
77include a plethora of optional modules</A>, and these modules need a
Jack Jansena2139fe1998-02-25 15:40:35 +000078number of extra packages. To use the project files as-is you have to
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000079download these packages too. Python has all such modules as
Jack Jansen4c1e56c1996-08-06 16:16:20 +000080dynamically loaded modules, so if you don't need a certain package it
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000081suffices to just refrain from builing the extension module.
82Here are the locations for the various things
Jack Jansen4c1e56c1996-08-06 16:16:20 +000083you need:
Jack Jansen8f2d8021996-08-05 15:34:45 +000084
85<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +000086
Jack Jansen8b41d532000-05-07 22:08:42 +000087<LI> Tcl and Tk are in a sad state on the Mac, the standard source distributions
88simply don't compile, so I have created a distribution especially for use
89with MacPython.
90See the section on <A HREF="#tcltk">building Tcl/Tk Python</A>
91below.
Jack Jansen8f2d8021996-08-05 15:34:45 +000092
Jack Jansen4c1e56c1996-08-06 16:16:20 +000093<LI> Waste, a TextEdit replacement written by Marco Piovanelli, <A
94HREF="mailto:piovanel@kagi.com">&lt;piovanel@kagi.com&gt;</A>. Python
Jack Jansena2139fe1998-02-25 15:40:35 +000095was built using version 1.3, which you can obtain from <A
96HREF="http://www.boingo.com/waste">&lt;http://www.boingo.com/waste&gt;</A>
Jack Jansen4c1e56c1996-08-06 16:16:20 +000097and various other places.
Jack Jansen8f2d8021996-08-05 15:34:45 +000098
Jack Jansen1473af71997-05-07 15:43:38 +000099<LI> Gdbm library for the Mac. Available from Jack's Mac software page at
100<A HREF="http://www.cwi.nl/~jack/macsoftware.html">
101http://www.cwi.nl/~jack/macsoftware.html</A> and <A HREF="ftp://ftp.cwi.nl/pub/jack/mac">
Jack Jansena598bc41999-02-10 23:08:24 +0000102ftp://ftp.cwi.nl/pub/jack/mac</A>. Also in the MacPython cvs repository at
103<code>lib-src/gdbm</code>.
Jack Jansen1473af71997-05-07 15:43:38 +0000104
105<LI> JPEG library by the Independent JPEG Group. A version including
106Mac projects can be found at Jack's page mentioned above.
107The most recent JPEG library can always be obtained from <A
Jack Jansena598bc41999-02-10 23:08:24 +0000108HREF="ftp://ftp.uu.net/graphics/jpeg/">ftp://ftp.uu.net/graphics/jpeg/</A>. Again,
109also in the MacPython cvs repository at <code>lib-src/jpeg</code>.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000110
Jack Jansen1473af71997-05-07 15:43:38 +0000111<LI> The netpbm/pbmplus, libtiff, zlib and png libraries. The netpbm distribution
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000112(which includes libtiff) is generally available on Internet ftp
113servers. For Python pbmplus, an older incarnation of netpbm, is
114functionally identical to netpbm, since Python only uses the library
115and not the complete applications. A distribution with correct
Jack Jansen1473af71997-05-07 15:43:38 +0000116projects and library source only is available from, you guessed it, Jack's Mac software
Jack Jansena598bc41999-02-10 23:08:24 +0000117page mentioned above. And, guessed it again, in the MacPython cvs repository
118at <code>lib-src/netpbm</code>, etc. The only gotcha is that libtiff lives in
119<code>lib-src/netpbm/libtiff</code>, for historical reasons.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000120
Jack Jansen8f2d8021996-08-05 15:34:45 +0000121</UL>
122
123<H2>Setting Up</H2>
124
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000125Now that you have collected everything you should start with building
Jack Jansen1473af71997-05-07 15:43:38 +0000126the various parts. If you don't want to fix
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000127access paths try to set things up as follows:
128
Jack Jansen8f2d8021996-08-05 15:34:45 +0000129<PRE>
130Top-level-folder:
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000131 GUSI2
Jack Jansen8f2d8021996-08-05 15:34:45 +0000132 imglibs
Jack Jansende570301998-08-27 13:39:01 +0000133 jpeg
134 netpbm
135 libtiff
Jack Jansen1473af71997-05-07 15:43:38 +0000136 zlib
Jack Jansende570301998-08-27 13:39:01 +0000137 png
Jack Jansen1473af71997-05-07 15:43:38 +0000138 gdbm
Jack Jansen8f2d8021996-08-05 15:34:45 +0000139 Python
Jack Jansen90cf4912000-02-11 23:14:46 +0000140 Modules
141 ...
142 Mac
143 Modules
144 Build
145 ...
Jack Jansen32617191997-08-19 14:01:16 +0000146 Tcl/Tk Folder
147 tcl8.0
148 tk8.0
Jack Jansena2139fe1998-02-25 15:40:35 +0000149 MoreFiles 1.4.3
150 Waste 1.3 distribution (if you want waste)
Jack Jansen8f2d8021996-08-05 15:34:45 +0000151</PRE>
152
Jack Jansende570301998-08-27 13:39:01 +0000153If your setup of the libraries is exactly the same as mine (which is
154not very likely, unless you happen to work from the same CVS
155repository) you can use the project <code>buildlibs.prj</code> in the
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000156<code>:Mac:Build</code> folder to build all needed libraries in one
Jack Jansende570301998-08-27 13:39:01 +0000157fell swoop, otherwise you will have to build the libraries one by
158one. <p>
159
Jack Jansen1473af71997-05-07 15:43:38 +0000160First build GUSI. If you didn't get the python-specific GUSI you have to
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000161massage some of the Python code (missing routines) and you'll miss the
162functionality of "delay console".
163 <p>
Jack Jansen95375861999-03-10 15:51:56 +0000164
Jack Jansen16e99c01996-09-07 17:11:26 +0000165Next, in
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000166<code>libjpeg</code>, <code>pbmplus</code>,
Jack Jansen1473af71997-05-07 15:43:38 +0000167<code>zlib</code>, <code>libpng</code>, <code>gdbm</code>,
Jack Jansena2139fe1998-02-25 15:40:35 +0000168and<code>libtiff</code> you build all projects. Usually the projects are in "mac"
Jack Jansen1473af71997-05-07 15:43:38 +0000169subfolders, sometimes they are in the main folder. Tcl/tk is a special
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000170case, see below.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000171
172<H2><A NAME="tcltk">Building Tcl/Tk</H2>
173
Jack Jansen8b41d532000-05-07 22:08:42 +0000174The Tcl/Tk 8.3.0 source distribution does not work on the Mac. I have created
175an archive of the sources that I used to build _tkinter for MacPython,
176you can obtain this from <a
177href="ftp://ftp.cwi.nl/pub/jack/python/mac/tcltk830src-for-python.sit">
178ftp://ftp.cwi.nl/pub/jack/python/mac/tcltk830src-for-python.sit</a>. Only the
179libraries needed to build _tkinter for PPC have been fixed. <P>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000180
Jack Jansen8b41d532000-05-07 22:08:42 +0000181Note that if you use a different release of Tcl and Tk than the ones
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000182I have used you may have to adapt the Python <code>tkresources.rsrc</code> file.
183This is easiest done by building <code>SimpleTk</code> and copying the TEXT, ICON
184and CRSR resources from it to <code>tkresources.rsrc</code>. This allows
185the <code>_tkinter</code> module to work without an installed Tk/Tcl on your
Jack Jansen8b41d532000-05-07 22:08:42 +0000186machine. <P>
187
188Also note that the <code>_tkinter.ppc.slb</code> that is normally distributed
189in the <code>PlugIns</code> folder is the one from the Imaging extension,
190which has some extra features needed by PIL (and which features should not
191hinder normal operation).
Jack Jansen27b10ec1996-08-23 15:44:18 +0000192
Jack Jansen8f2d8021996-08-05 15:34:45 +0000193</UL>
194
Jack Jansenf3dd5aa1996-12-23 17:29:51 +0000195Build first the Tcl library, then
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000196SimpleTcl (test it by typing <code>ls -l</code> in the window you get)
197then the Tk library, then SimpleTk (which can again be tested with
198<code>ls -l</code>). If this all worked you are all set to try
Jack Jansen8f2d8021996-08-05 15:34:45 +0000199building Python.
200
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000201<H2>Building Waste</H2>
202
203You do not need to build the Waste libraries, as Python includes the
Jack Jansena2139fe1998-02-25 15:40:35 +0000204source modules themselves.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000205
Jack Jansen8f2d8021996-08-05 15:34:45 +0000206<H2>The organization of the Python source tree</H2>
207
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000208Time for a short break, while we have a look at the organization of
209the Python source tree. At the top level, we find the following
210folders:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000211
212<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000213<DT> Demo
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000214<DD> Demo programs that are not Mac-specific. Some of these may not
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000215work.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000216
217<DT> Extensions
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000218<DD> Extensions to the interpreter that are not Mac-specific. Contains
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000219the <code>img</code>, <code>Imaging</code> and <code>Numerical</code> extensions
220in this distribution.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000221
222<DT> Grammar
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000223<DD> The Python grammar. Included for reference only, you cannot build
224the parser on a Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000225
226<DT> Include
227<DD> Machine-independent header files.
228
229<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000230<DD> Machine-independent optional modules. Not all of these will work
231on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000232
233<DT> Objects
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000234<DD> Machine-independent code for various object types. Most of these are
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000235not really optional: the interpreter will not function without them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000236
237<DT> Parser
238<DD> The Python parser (machine-independent).
239
Jack Jansen8f2d8021996-08-05 15:34:45 +0000240<DT> Python
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000241<DD> The core interpreter. Most files are machine-independent, some
242are unix-specific and not used on the Mac.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000243
244<DT> Tools
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000245<DD> Tools for python developers. Contains <code>modulator</code> which
246builds skeleton C extension modules, <code>bgen</code> which generates
247complete interface modules from information in C header files and
248<code>freeze</code> which is used to turn Python scripts into real
249applications (used by MacFreeze and BuildApplication) There are some
250readme files, but more documentation is sorely needed.
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000251
Jack Jansen8f2d8021996-08-05 15:34:45 +0000252</DL>
253
254All the mac-specific stuff lives in the <code>Mac</code> folder:
255<DL>
Jack Jansenc256ece1999-02-03 13:09:27 +0000256<DT> Build
257<DD> This is where the project files live and where you build the
258libraries, shared libraries, executables and plugin modules. All the
259resulting binaries, except for intermedeate results, are deposited in
Jack Jansena598bc41999-02-10 23:08:24 +0000260the toplevel folder or the Mac:PlugIns folder (for plugin modules).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000261
262<DT> Compat
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000263<DD> Unix-compatability routines. Most of these are not used anymore,
264since GUSI provides a rather complete emulation, but you may need
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000265these if you are trying to build a non-GUSI python.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000266
267<DT> Demo
268<DD> Mac-specific demo programs, some of them annotated.
269
270<DT> Include
271<DD> Mac-specific but compiler-independent include files.
272
273<DT> Lib
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000274<DD> Mac-specific standard modules. The <code>toolbox</code> folder
275contains modules specifically needed with various MacOS toolbox
276interface modules.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000277
278<DT> Modules
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000279<DD> Mac-specific builtin modules. Theoretically these are all
280optional, but some are rather essential (like
281<code>macmodule</code>). A lot of these modules are generated with
282<code>bgen</code>, in which case the bgen input files are included so
283you can attempt to regenerate them or extend them.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000284
285<DT> MPW
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000286<DD> MPW-specific files. These have not been used or kept up-to-date
287for a long time, so use at your own risk.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000288
289<DT> mwerks
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000290<DD> Mwerks-specific sources and headers. Contains glue code for
291Pythons shared-library architecture, a replacement for
292<code>malloc</code> and a directory with various projects for building
293variations on the Python interpreter. The <code>mwerks_*.h</code>
294files here are the option-setting files for the various interpreters
295and such, comparable to the unix command-line <code>-D</code> options
296to the compiler. Each project uses the correct option file as its
297"prefix file" in the "C/C++ language" settings. Disabling optional
298modules (for the 68K interpreter), building non-GUSI interpreters and
299various other things are accomplished by modifying these files (and
300possibly changing the list of files included in the project window, of
301course).
Jack Jansen8f2d8021996-08-05 15:34:45 +0000302
Jack Jansenc256ece1999-02-03 13:09:27 +0000303<DT> PlugIns
304<DD> This is where the PPC and CFM68K dynamically-loaded plugin modules live.
305
Jack Jansen8f2d8021996-08-05 15:34:45 +0000306<DT> Python
307<DD> Mac-specific parts of the core interpreter.
308
309<DT> Resources
310<DD> Resource files needed to build the interpreter.
311
312<DT> Scripts
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000313<DD> A collection of various mac-specific Python scripts. Some are
314essential, some are useful but few are documented, so you will have to
315use your imagination to work them out.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000316
Jack Jansenc256ece1999-02-03 13:09:27 +0000317<DT> Tools
318<DD> A collection of tools, usually bigger than those in the scripts
319folder. The important ones here are the IDE and macfreeze. The IDE is built
320with the buildIDE.py script, which puts the resulting applet in the toplevel
321folder. Macfreeze is usually invoked through the BuildApplication script,
322but for more control over the freezing process you can run the main script here.
323
324
Jack Jansen8f2d8021996-08-05 15:34:45 +0000325<DT> Unsupported
326<DD> Modules that are not supported any longer but may still work with a little effort.
327</DL>
328
329<H2>Building the 68K interpreter</H2>
330
Jack Jansen8a6cdcc2000-09-10 12:02:28 +000033168K Python is no longer supported, and the projects are not included in the
332source distirbution anymore. If you really want to build Python for the 68K
333your best bet is to check the sources out of the CVS repository. The latest
334projects (in :Mac:build:) that support 68K development are tagged as such,
335and are dated around August 2000. If you plan on doing this announce it on
336the SIG, please. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000337
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000338<H2>Building the PPC interpreter</H2>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000339
Jack Jansenc256ece1999-02-03 13:09:27 +0000340First you optionally build the external libraries with buildlibs.prj. Next,
341the projects for
342interpreter, core library and applet skeleton are all linked together, so
Jack Jansen3b805261999-02-14 23:12:06 +0000343building the fat target in <code>PythonEngine.prj</code>
344will result in everything being built. The
Jack Jansen3412c5d1997-08-27 14:08:22 +0000345resulting applications and fat shared library are deposited in the main
Jack Jansenc256ece1999-02-03 13:09:27 +0000346Python folder. Finally, you build all the plugins with the plugins.prj project.
347
348For completeness sake here is a breakdown of the projects:
Jack Jansen8f2d8021996-08-05 15:34:45 +0000349
350<DL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000351
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000352<DT> PythonCore (with subproject PythonCorePPC)
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000353<DD> The shared library that contains the bulk of the interpreter and
354its resources. It is a good idea to immedeately put an alias to this
355shared library in the <code>Extensions</code> folder of your system
356folder. Do exactly that: put an <em>alias</em> there, copying or
Jack Jansen3412c5d1997-08-27 14:08:22 +0000357moving the file will cause you grief later if you rebuild the library and
Jack Jansenc256ece1999-02-03 13:09:27 +0000358forget to copy it to the extensions folder again. The InstallPython applet
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000359will also do this, along with creating the plugin aliases. <br>
360Note that the subproject looks a bit silly nowadays (with no more CFM68K
361support) but you will have to live with that for this release.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000362
Jack Jansen3b805261999-02-14 23:12:06 +0000363<DT> PythonInterpeter
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000364<DD> The interpreter. This is basically a routine to call out to the
Jack Jansen3b805261999-02-14 23:12:06 +0000365shared library. Unlike in previous releases the same program is used for
366creating applets (for which formerly PythonApplet was used). <p>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000367
Jack Jansenc256ece1999-02-03 13:09:27 +0000368<DT> Plugin projects
Jack Jansena598bc41999-02-10 23:08:24 +0000369<DD> Each plugin module has a separate project. The <code>Plugins.prj</code>
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000370project tries to build them all, but is known to be flakey. See <code>fullbuild</code>
371below for a better way to build everything.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000372</DL>
373
Jack Jansen3412c5d1997-08-27 14:08:22 +0000374After creating the alias to <code>PythonCore</code> you remove any old
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000375<code>Python 2.0b1 Preferences</code> file from the <code>Preferences</code> folder
Jack Jansen061ac501996-10-22 15:27:56 +0000376(if you had python installed on your system before) and run the interpreter once
Jack Jansen3412c5d1997-08-27 14:08:22 +0000377to create the correct preferences file. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000378
Jack Jansenc256ece1999-02-03 13:09:27 +0000379Next, you have to build the extension modules.
380The <code>PlugIns.ppc</code> project has all the
Jack Jansena598bc41999-02-10 23:08:24 +0000381other projects as subprojects and builds everything (but see the gotcha above).
382<p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000383
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000384Finally, you must build the standard applets:
Jack Jansen3412c5d1997-08-27 14:08:22 +0000385<code>EditPythonPrefs</code>, <code>BuildApplet</code>, etc. This is
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000386easiest done with the <code>fullbuild</code> script from
Jack Jansen3412c5d1997-08-27 14:08:22 +0000387<code>Mac:scripts</code>. <p>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000388
389<BLOCKQUOTE>
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000390Actually, the <code>fullbuild</code> script can be used to build
391everything, but you need a fully-functional interpreter before you can
392use it (and one that isn't rebuilt in the process: you cannot rebuild
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000393a running program). You could copy the interpreter to a different
394place and use that to run fullbuild. The <code>PythonStandSmall.prj</code>
395project builds an interpreter that is suited to this, and it can also come
396in handy if you need to debug things (which is easier in a static program). <p>
Jack Jansene66b8c81997-05-29 14:57:07 +0000397
Jack Jansen8f2d8021996-08-05 15:34:45 +0000398</BLOCKQUOTE>
399
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000400You are all set now, and should read the release notes and
Jack Jansen3412c5d1997-08-27 14:08:22 +0000401<code>ReadMe</code> file from the <code>Mac</code> folder.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000402
Jack Jansen27b10ec1996-08-23 15:44:18 +0000403<H2>Rebuilding <code>.exp</code> files for PPC and CFM68K</H2>
404
405Occasionally it may be necessary to rebuild your PythonCore <code>.exp</code>
406file, a file that controls which symbols are exported by your PythonCore
407shared library. Rebuild it if you get unexpected undefined symbols when you
408are building a plugin module. <p>
409
410Rebuilding the .exp file is done by first removing the file and removing the
411reference to it in the project (in the "config" section). Next, build PythonCore.
412This will create a new .exp file. Edit this file to remove the references to
413the symbols <code>__initialize</code>, <code>__terminate</code>, <code>setjmp</code>,
Jack Jansen2afc2c71999-09-30 19:48:49 +0000414<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 +0000415CFM68K) <code>__start</code> and <code>dummy_init_routine</code>.
416Next, add the .exp file to the project
Jack Jansen27b10ec1996-08-23 15:44:18 +0000417again and rebuild PythonCore. <p>
418
419This rather convoluted procedure is needed to ensure that plugin modules don't
420accidentally link with those entrypoints from PythonCore, which will not work because
421those routines have to be in the same code fragment as they are used from.
422
Jack Jansen95375861999-03-10 15:51:56 +0000423<H2><a name="cvs">Using the CVS source archive</a></H2>
Jack Jansenc256ece1999-02-03 13:09:27 +0000424
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000425It is possible (and probably best) to access the Python sources through remote CVS. The
Jack Jansen65f685b1999-04-12 09:25:23 +0000426advantage of this is that you get the very latest sources, so any bug
427fixed or new features will be immedeately available. This is also the
428disadvantage, of course: as this is the same tree as is used for
429development it may sometimes be a little less stable. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000430
431The CVS client of choice is Alexandre Parenteau's MacCVS. It can be
Jack Jansen65f685b1999-04-12 09:25:23 +0000432obtained through the <a href="http://www.wincvs.org">WinCVS
433homepage</a>. MacCVS uses Internet Config to set file types correctly
434based on the filename extension. In the maccvs preferences you should
435also set (in the "binary files" section) "use mac encoding:
436applesingle" and (in the "text files" section) "use ISO latin 1
Jack Jansenc256ece1999-02-03 13:09:27 +0000437conversion". <p>
438
Jack Jansen8b41d532000-05-07 22:08:42 +0000439It is also a good idea to disable Quicktime Exchange in the Quicktime
440control panel. Quicktime Exchange will magically map some extensions to
441filetypes, and this can seriously hinder you if, for instance, <code>.bmp</code>
442is not a Windows bitmap file. <p>
443
Jack Jansen95375861999-03-10 15:51:56 +0000444The machine-independent Python sources are checked out from the main
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000445Python CVS archive on sourceforge.net, see the <a
Jack Jansen65f685b1999-04-12 09:25:23 +0000446href="http://www.python.org/download/cvs.html">Source access via
447CVS</a> page for details. When you check the sources out you will get
Jack Jansen95375861999-03-10 15:51:56 +0000448something like <code>Python:dist:src</code>, and under that the
449<code>Modules</code>, <code>Lib</code>, etc hierarchy. The
450<code>src</code> folder should be renamed to <code>Python</code>, and
451is what this document refers to as the "toplevel Python folder". <P>
Jack Jansenc256ece1999-02-03 13:09:27 +0000452
Jack Jansen90cf4912000-02-11 23:14:46 +0000453Next, <em>in a separate folder</em>, you check out the
454mac-specific sources. You then move the <code>Mac</code> folder from this
455checkout (the only folder with anything in it) to the Python source folder.
456Note that the checking out in a separate folder and moving is necessary,
457due to the way cvs works.
458
459The CVS path to use for the mac stuff can be found
Jack Jansen95375861999-03-10 15:51:56 +0000460at the <a href="http://www.cwi.nl/~jack/macpython.html">MacPython
461homepage</a>. Finally, you check out the external libraries needed in
Jack Jansen90cf4912000-02-11 23:14:46 +0000462the parent of the toplevel Python folder. The CVS path for these libraries is
Jack Jansen95375861999-03-10 15:51:56 +0000463also mentioned at the MacPython homepage. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000464
Jack Jansen95375861999-03-10 15:51:56 +0000465Neither of the pages mentioned above contains the passwords for the
466CVS sites, for obvious reasons, but they do contain instructions on
467how to obtain the passwords. <p>
Jack Jansenc256ece1999-02-03 13:09:27 +0000468
Jack Jansen90cf4912000-02-11 23:14:46 +0000469You should end up with a folder structure as described at the top of this
470document. <p>
471
Jack Jansendae108c2000-02-11 23:17:14 +0000472Note that while the Mac folder is now a subfolder of your toplevel Python
473folder this does not mean that they "act as one" as far as CVS is concerned.
474To update all your sources you have to do a "cvs update" in the toplevel
475Python folder and another one in the Mac folder. This is again a cvs problem:
476it cannot deal with subpackages coming from different repositories. <p>
477
Jack Jansen8f2d8021996-08-05 15:34:45 +0000478<H2>Odds and ends</H2>
479
480Some remarks that I could not fit in elsewhere:
481
482<UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000483
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000484<LI> It may be possible to use the <code>PythonCore</code> shared
485library to embed Python in another program, if your program can live
Jack Jansen1473af71997-05-07 15:43:38 +0000486with using GUSI for I/O. Use PythonCore in stead of your MSL C library
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000487(or, at the very least, link it before the normal C library).
Jack Jansen4c1e56c1996-08-06 16:16:20 +0000488
489<LI> It is possible to build PPC extension modules without building a
Jack Jansenc256ece1999-02-03 13:09:27 +0000490complete Python. The binary distribution installer can optionally install
Jack Jansen8a6cdcc2000-09-10 12:02:28 +0000491all the needed folders (the develop option). A template for a dynamic module can be found in
Jack Jansen3412c5d1997-08-27 14:08:22 +0000492<code>xx.prj</code>.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000493
494<LI> The Python shared library architecture is a variant of the architecture
495described as "application with shared libraries and dropins" in the MetroWerks
496"Targeting MacOS" documentation. The Python Application and applet-template use
Jack Jansen1473af71997-05-07 15:43:38 +0000497the <code>MSL AppRuntime.Lib</code> runtime library (with properly set CFM
498initialization and termination routines). PythonCore uses <code>MSL Runtime.Lib</code>,
499which is really intended for standalone programs but which we fool into working by
500providing a dummy main program.
Jack Jansen27b10ec1996-08-23 15:44:18 +0000501It is linked statically into PythonCore (and exported to the applications and plugins)
502so we do not have to distribute yet another shared library. Plugin modules use
Jack Jansen1473af71997-05-07 15:43:38 +0000503<code>MSL ShlibRuntime.Lib</code> (not the dropin runtime: modules are never unloaded)
504and obtain the rest from PythonCore. PythonCore uses a
Jack Jansen27b10ec1996-08-23 15:44:18 +0000505non-standard initialization entry point, <code>__initialize_with_resources</code>, to
Jack Jansen1473af71997-05-07 15:43:38 +0000506be able to obtain resources from the library file later on. Plugins can do the same
507(_tkinter does) or use the standard <code>__initialize</code> entry point.
Jack Jansen8f2d8021996-08-05 15:34:45 +0000508
509
Jack Jansen6ad8d131997-01-15 16:53:37 +0000510</UL>
Jack Jansen8f2d8021996-08-05 15:34:45 +0000511</BODY>
512</HTML>