Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 1 | <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 Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 8 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 9 | This document explains how to build MacPython from source. This is |
| 10 | necessary if you want to write extension modules for 68K Python, and |
| 11 | currently also probably the easiest way to build PPC extension |
| 12 | modules. Building Python is not something to be undertaken lightly, |
| 13 | the process is not very streamlined so you need a reasonable working |
| 14 | knowledge of the CodeWarrior development environment, a good net |
| 15 | connection and probably quite some time too. <p> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 16 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 17 | The information density in this file is high, so you should probably |
| 18 | print it and read it at your leasure. Most things are explained only |
| 19 | once (and probably in the wrong place:-). <p> |
| 20 | |
| 21 | I am very interested in feedback on this document, contact me at <A |
| 22 | HREF="mailto:jack@cwi.nl"><jack@cwi.nl></A> or send your |
| 23 | comments to the <A |
| 24 | HREF="http://www.python.org/sigs/pythonmac-sig/">Mac Python Special |
| 25 | Interest Group</A>. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 26 | |
| 27 | <H2>What you need.</H2> |
| 28 | |
| 29 | The following things you definitely need: |
| 30 | |
| 31 | <UL> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 32 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 33 | <LI> You need a MacPython source distribution, of course. You can |
| 34 | obtain one from <A |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 35 | HREF="ftp://ftp.cwi.nl/pub/jack/python/mac">ftp://ftp.cwi.nl/pub/jack/python/mac</A> |
| 36 | or from the companion webpage at <A HREF="http://www.cwi.nl/~jack/macpython.html"> |
| 37 | http://www.cwi.nl/~jack/macpython.html</A> (which has up-to-date links to the other |
| 38 | packages needed too) |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 39 | and possibly also from the standard <A |
| 40 | HREF="ftp://ftp.python.org/pub/python/mac">python.org ftp |
| 41 | site</A>. Everything you need is also included in the standard Python |
| 42 | source distribution, but the organization is different. Look in |
| 43 | directory <code>Mac/mwerks/projects</code> for the project files and |
| 44 | related stuff. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 45 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 46 | <LI> You need MetroWerks CodeWarrior. The current distribution has |
Jack Jansen | a2139fe | 1998-02-25 15:40:35 +0000 | [diff] [blame] | 47 | been built with CodeWarrior Pro 2. Ordering information is |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 48 | available on the <A HREF="http://www.metrowerks.com/">MetroWerks |
Jack Jansen | a2139fe | 1998-02-25 15:40:35 +0000 | [diff] [blame] | 49 | homepage</A>. Building Python with MPW or Think/Symantec C is |
| 50 | probably impossible without major surgery. |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 51 | |
| 52 | <LI> You need GUSI, the Grand Unified Socket Interface, by Matthias |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 53 | Neeracher. The original CWGUSI is |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 54 | obtainable from <A |
Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 55 | HREF="ftp://sunsite.cnlab-switch.ch/software/platform/macos/src"> |
Jack Jansen | e66b8c8 | 1997-05-29 14:57:07 +0000 | [diff] [blame] | 56 | ftp://sunsite.cnlab-switch.ch/software/platform/macos/src</A>. |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 57 | At the moment Python is built with a slightly modified version of GUSI, |
Jack Jansen | e66b8c8 | 1997-05-29 14:57:07 +0000 | [diff] [blame] | 58 | these modifications are available in folder <code>Python:Mac:GUSI-mods</code>. |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 59 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 60 | </UL> |
| 61 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 62 | <A NAME="optional">The MacPython project files are configured to |
| 63 | include a plethora of optional modules</A>, and these modules need a |
Jack Jansen | a2139fe | 1998-02-25 15:40:35 +0000 | [diff] [blame] | 64 | number of extra packages. To use the project files as-is you have to |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 65 | download these packages too. PPC and CFM68K Python have all such modules as |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 66 | dynamically loaded modules, so if you don't need a certain package it |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 67 | suffices to just refrain from builing the extension module. For static 68K |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 68 | Python things are a bit more complicated: you have to edit the |
| 69 | interpreter project file to remove the reference to the module (and |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 70 | the libraries it uses), and edit the <code>Mac:mwerks:mwerks_nonshared_config.h</code> |
| 71 | file to remove the <code>USE_...</code> line. Here are the locations for the various things |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 72 | you need: |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 73 | |
| 74 | <UL> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 75 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 76 | <LI> Tcl and Tk can be obtained from <A |
| 77 | HREF="ftp://ftp.smli.com/pub/tcl/mac/">ftp://ftp.smli.com/pub/tcl/mac/</A>. |
Jack Jansen | 44a8931 | 1997-12-23 22:56:25 +0000 | [diff] [blame] | 78 | The current distributions, Tcl 8.0p2 and Tk 8.0p2 need a bit of work, |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 79 | see the section on <A HREF="#tcltk">building Tcl/Tk Python</A> |
| 80 | below. Get the "full source" distribution, which includes MoreFiles. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 81 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 82 | <LI> Waste, a TextEdit replacement written by Marco Piovanelli, <A |
| 83 | HREF="mailto:piovanel@kagi.com"><piovanel@kagi.com></A>. Python |
Jack Jansen | a2139fe | 1998-02-25 15:40:35 +0000 | [diff] [blame] | 84 | was built using version 1.3, which you can obtain from <A |
| 85 | HREF="http://www.boingo.com/waste"><http://www.boingo.com/waste></A> |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 86 | and various other places. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 87 | |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 88 | <LI> Gdbm library for the Mac. Available from Jack's Mac software page at |
| 89 | <A HREF="http://www.cwi.nl/~jack/macsoftware.html"> |
| 90 | http://www.cwi.nl/~jack/macsoftware.html</A> and <A HREF="ftp://ftp.cwi.nl/pub/jack/mac"> |
| 91 | ftp://ftp.cwi.nl/pub/jack/mac</A>. |
| 92 | |
| 93 | <LI> JPEG library by the Independent JPEG Group. A version including |
| 94 | Mac projects can be found at Jack's page mentioned above. |
| 95 | The most recent JPEG library can always be obtained from <A |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 96 | HREF="ftp://ftp.uu.net/graphics/jpeg/">ftp://ftp.uu.net/graphics/jpeg/</A>. |
| 97 | |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 98 | <LI> The netpbm/pbmplus, libtiff, zlib and png libraries. The netpbm distribution |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 99 | (which includes libtiff) is generally available on Internet ftp |
| 100 | servers. For Python pbmplus, an older incarnation of netpbm, is |
| 101 | functionally identical to netpbm, since Python only uses the library |
| 102 | and not the complete applications. A distribution with correct |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 103 | projects and library source only is available from, you guessed it, Jack's Mac software |
| 104 | page mentioned above. |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 105 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 106 | </UL> |
| 107 | |
| 108 | <H2>Setting Up</H2> |
| 109 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 110 | Now that you have collected everything you should start with building |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 111 | the various parts. If you don't want to fix |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 112 | access paths try to set things up as follows: |
| 113 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 114 | <PRE> |
| 115 | Top-level-folder: |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 116 | CWGUSI |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 117 | imglibs |
| 118 | libjpeg |
| 119 | pbmplus |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 120 | libtiff |
| 121 | zlib |
| 122 | libpng |
| 123 | gdbm |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 124 | Python |
Jack Jansen | 3261719 | 1997-08-19 14:01:16 +0000 | [diff] [blame] | 125 | Tcl/Tk Folder |
| 126 | tcl8.0 |
| 127 | tk8.0 |
Jack Jansen | a2139fe | 1998-02-25 15:40:35 +0000 | [diff] [blame] | 128 | MoreFiles 1.4.3 |
| 129 | Waste 1.3 distribution (if you want waste) |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 130 | </PRE> |
| 131 | |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 132 | First build GUSI. If you didn't get the python-specific GUSI you have to |
| 133 | move the files from the "CWGUSI-mods" to the right |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 134 | place in the CWGUSI distribution folder. Build the MSL version for your |
| 135 | platform (ppc, 68k, cfm68k). <p> |
Jack Jansen | 16e99c0 | 1996-09-07 17:11:26 +0000 | [diff] [blame] | 136 | |
| 137 | Next, in |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 138 | <code>MoreFiles</code>, <code>libjpeg</code>, <code>pbmplus</code>, |
| 139 | <code>zlib</code>, <code>libpng</code>, <code>gdbm</code>, |
Jack Jansen | a2139fe | 1998-02-25 15:40:35 +0000 | [diff] [blame] | 140 | and<code>libtiff</code> you build all projects. Usually the projects are in "mac" |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 141 | subfolders, sometimes they are in the main folder. Tcl/tk is a special |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 142 | case, see below. Of course, if you are only interested in one of |
| 143 | static 68K, CFM68K or PPC you can skip building the other libraries. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 144 | |
| 145 | <H2><A NAME="tcltk">Building Tcl/Tk</H2> |
| 146 | |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 147 | You need to make some minor changes to the Tcl/Tk 8.0 |
| 148 | distribution. You should make the CW Pro projects (in the mac subfolders). |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 149 | <UL> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 150 | |
Jack Jansen | 3261719 | 1997-08-19 14:01:16 +0000 | [diff] [blame] | 151 | <LI> There are no cfm68k targets. You make these by copying the 68k targets, |
| 152 | setting the "68k target" to "cfm68k library" and changing the output filename, |
| 153 | and changing the prefix |
| 154 | header filename in the C/C++ settings panel to "MW_???HeaderCFM68K". |
Jack Jansen | e66b8c8 | 1997-05-29 14:57:07 +0000 | [diff] [blame] | 155 | |
Jack Jansen | 3261719 | 1997-08-19 14:01:16 +0000 | [diff] [blame] | 156 | <LI> I had to add Search.c (from MoreFiles) to the tcl library projects. I don't |
| 157 | understand why this is, but it seemed to cure the problems I had. |
Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 158 | |
| 159 | <LI> Note that if you use a different release of Tcl and Tk than the ones |
| 160 | I have used you may have to adapt the Python <code>tkresources.rsrc</code> file. |
| 161 | This is easiest done by building <code>SimpleTk</code> and copying the TEXT, ICON |
| 162 | and CRSR resources from it to <code>tkresources.rsrc</code>. This allows |
| 163 | the <code>_tkinter</code> module to work without an installed Tk/Tcl on your |
| 164 | machine. |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 165 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 166 | </UL> |
| 167 | |
Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 168 | Build first the Tcl library, then |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 169 | SimpleTcl (test it by typing <code>ls -l</code> in the window you get) |
| 170 | then the Tk library, then SimpleTk (which can again be tested with |
| 171 | <code>ls -l</code>). If this all worked you are all set to try |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 172 | building Python. |
| 173 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 174 | <H2>Building Waste</H2> |
| 175 | |
| 176 | You do not need to build the Waste libraries, as Python includes the |
Jack Jansen | a2139fe | 1998-02-25 15:40:35 +0000 | [diff] [blame] | 177 | source modules themselves. |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 178 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 179 | <H2>The organization of the Python source tree</H2> |
| 180 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 181 | Time for a short break, while we have a look at the organization of |
| 182 | the Python source tree. At the top level, we find the following |
| 183 | folders: |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 184 | |
| 185 | <DL> |
Jack Jansen | a2139fe | 1998-02-25 15:40:35 +0000 | [diff] [blame] | 186 | <DT> build.macstand |
| 187 | <DD> This is where you build static 68K interpreter, and possibly (if |
| 188 | you want them) static PPC and fat interpreters. There is also a project |
| 189 | here that builds smaller versions of the static interpreter. |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 190 | |
Jack Jansen | a2139fe | 1998-02-25 15:40:35 +0000 | [diff] [blame] | 191 | <DT> build.mac |
| 192 | <DD> This is where you build the CFM68K, PPC and fat shared library, |
| 193 | interpreter and applet framework. The fat targets are deposited in the |
| 194 | main folder (one level up), the others, which are intermediate results |
| 195 | really, are left here. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 196 | |
| 197 | <DT> Demo |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 198 | <DD> Demo programs that are not Mac-specific. Some of these may not |
| 199 | work, the file <code>README-Mac</code> has some details. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 200 | |
| 201 | <DT> Extensions |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 202 | <DD> Extensions to the interpreter that are not Mac-specific. Contains |
| 203 | only the <code>img</code> extension in this distribution. Extensions |
Jack Jansen | a2139fe | 1998-02-25 15:40:35 +0000 | [diff] [blame] | 204 | are not always built here, as they are on Unix, but sometimes incorporated in |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 205 | the core interpreter or built as plugin modules. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 206 | |
| 207 | <DT> Grammar |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 208 | <DD> The Python grammar. Included for reference only, you cannot build |
| 209 | the parser on a Mac. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 210 | |
| 211 | <DT> Include |
| 212 | <DD> Machine-independent header files. |
| 213 | |
| 214 | <DT> Modules |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 215 | <DD> Machine-independent optional modules. Not all of these will work |
| 216 | on the Mac. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 217 | |
| 218 | <DT> Objects |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 219 | <DD> Machine-independent code for various objects. Most of these are |
| 220 | not really optional: the interpreter will not function without them. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 221 | |
| 222 | <DT> Parser |
| 223 | <DD> The Python parser (machine-independent). |
| 224 | |
| 225 | <DT> PlugIns |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 226 | <DD> This is where you build the PPC and CFM68K dynamically-loaded plugin modules. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 227 | |
| 228 | <DT> Python |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 229 | <DD> The core interpreter. Most files are machine-independent, some |
| 230 | are unix-specific and not used on the Mac. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 231 | |
| 232 | <DT> Tools |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 233 | <DD> Tools for python developers. Contains <code>modulator</code> |
| 234 | which builds skeleton C extension modules and <code>bgen</code> which |
| 235 | generates complete interface modules from information in C header |
| 236 | files. There are some readme files, but more documentation is sorely |
| 237 | needed. |
| 238 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 239 | </DL> |
| 240 | |
| 241 | All the mac-specific stuff lives in the <code>Mac</code> folder: |
| 242 | <DL> |
| 243 | |
| 244 | <DT> Compat |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 245 | <DD> Unix-compatability routines. Some of these are not used anymore, |
| 246 | since CWGUSI provides a rather complete emulation, but you may need |
| 247 | these if you are trying to build a non-GUSI python. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 248 | |
| 249 | <DT> Demo |
| 250 | <DD> Mac-specific demo programs, some of them annotated. |
| 251 | |
| 252 | <DT> Include |
| 253 | <DD> Mac-specific but compiler-independent include files. |
| 254 | |
| 255 | <DT> Lib |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 256 | <DD> Mac-specific standard modules. The <code>toolbox</code> folder |
| 257 | contains modules specifically needed with various MacOS toolbox |
| 258 | interface modules. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 259 | |
| 260 | <DT> Modules |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 261 | <DD> Mac-specific builtin modules. Theoretically these are all |
| 262 | optional, but some are rather essential (like |
| 263 | <code>macmodule</code>). A lot of these modules are generated with |
| 264 | <code>bgen</code>, in which case the bgen input files are included so |
| 265 | you can attempt to regenerate them or extend them. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 266 | |
| 267 | <DT> MPW |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 268 | <DD> MPW-specific files. These have not been used or kept up-to-date |
| 269 | for a long time, so use at your own risk. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 270 | |
| 271 | <DT> mwerks |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 272 | <DD> Mwerks-specific sources and headers. Contains glue code for |
| 273 | Pythons shared-library architecture, a replacement for |
| 274 | <code>malloc</code> and a directory with various projects for building |
| 275 | variations on the Python interpreter. The <code>mwerks_*.h</code> |
| 276 | files here are the option-setting files for the various interpreters |
| 277 | and such, comparable to the unix command-line <code>-D</code> options |
| 278 | to the compiler. Each project uses the correct option file as its |
| 279 | "prefix file" in the "C/C++ language" settings. Disabling optional |
| 280 | modules (for the 68K interpreter), building non-GUSI interpreters and |
| 281 | various other things are accomplished by modifying these files (and |
| 282 | possibly changing the list of files included in the project window, of |
| 283 | course). |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 284 | |
| 285 | <DT> Python |
| 286 | <DD> Mac-specific parts of the core interpreter. |
| 287 | |
| 288 | <DT> Resources |
| 289 | <DD> Resource files needed to build the interpreter. |
| 290 | |
| 291 | <DT> Scripts |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 292 | <DD> A collection of various mac-specific Python scripts. Some are |
| 293 | essential, some are useful but few are documented, so you will have to |
| 294 | use your imagination to work them out. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 295 | |
| 296 | <DT> Unsupported |
| 297 | <DD> Modules that are not supported any longer but may still work with a little effort. |
| 298 | </DL> |
| 299 | |
| 300 | <H2>Building the 68K interpreter</H2> |
| 301 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 302 | If you have all the optional libraries mentioned <A |
| 303 | HREF="#optional">above</A> loaded buildin Python for 68K macs is a |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 304 | breeze: open the project in the folder <code>build.macstand</code> and |
| 305 | build the 68K target. Do <em>not</em> run it yet, this will possibly |
| 306 | result in a garbled preferences file. <p> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 307 | |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 308 | First remove the <code>Python XXX preferences</code> file from your |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 309 | preference folder, only if you had an older version of Python |
| 310 | installed. (this is also what you do if you did not heed the last |
| 311 | sentence of the preceeding paragraph). Next, move the interpreter to |
| 312 | the main Python folder (up one level) and run it there. This will |
| 313 | create a correct initial preferences file. You are now all set, and |
| 314 | your tree should be completely compatible with a binary-only |
| 315 | distribution. Read the release notes |
| 316 | (<code>Relnotes-somethingorother</code>) and |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 317 | <code>ReadMe</code> in the <code>Mac</code> folder. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 318 | |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 319 | <H2>Building the PPC and CFM68K interpreter</H2> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 320 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 321 | First you build the interpreter, core library and applet skeleton in |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 322 | folder <code>build.mac</code>. The projects are all linked together, so |
| 323 | building the fat targets in <code>Python.prj</code> and |
| 324 | <code>PythonApplet.prj</code> will result in everything being built. The |
| 325 | resulting applications and fat shared library are deposited in the main |
| 326 | Python folder. For completeness sake here is a breakdown of the |
| 327 | projects: |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 328 | |
| 329 | <DL> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 330 | |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 331 | <DT> PythonCore (with subprojects PythonCorePPC and PythonCoreCFM68K) |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 332 | <DD> The shared library that contains the bulk of the interpreter and |
| 333 | its resources. It is a good idea to immedeately put an alias to this |
| 334 | shared library in the <code>Extensions</code> folder of your system |
| 335 | folder. Do exactly that: put an <em>alias</em> there, copying or |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 336 | moving the file will cause you grief later if you rebuild the library and |
| 337 | forget to copy it to the extensions folder again. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 338 | |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 339 | <DT> Python |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 340 | <DD> The interpreter. This is basically a routine to call out to the |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 341 | shared library. <p> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 342 | |
Jack Jansen | 061ac50 | 1996-10-22 15:27:56 +0000 | [diff] [blame] | 343 | <DT> PythonAppletPPC |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 344 | <DD> The applet skeleton application. Very similar to |
| 345 | <code>PythonPPC</code>, but it calls to a different entrypoint in the |
| 346 | core library. The <code>mkapplet</code> script will copy this complete |
| 347 | file, and add a <code>'PYC '</code> with the module to generate an |
| 348 | applet. <p> |
| 349 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 350 | </DL> |
| 351 | |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 352 | After creating the alias to <code>PythonCore</code> you remove any old |
Jack Jansen | 061ac50 | 1996-10-22 15:27:56 +0000 | [diff] [blame] | 353 | <code>Python XXX Preferences</code> file from the <code>Preferences</code> folder |
| 354 | (if you had python installed on your system before) and run the interpreter once |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 355 | to create the correct preferences file. <p> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 356 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 357 | Next, you have to build the extension modules in the |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 358 | <code>PlugIns</code> folder. The <code>PlugIns.ppc</code> project has all the |
| 359 | other projects as subprojects and builds everything. After all |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 360 | the dynamically loaded modules are built you have to create a number |
| 361 | of aliases: some modules live together in a single dynamic |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 362 | library. Run the <code>ConfigurePython.py</code> script from |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 363 | <code>Mac:scripts</code> to create the aliases. <p> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 364 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 365 | Finally, you must build the standard applets: |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 366 | <code>EditPythonPrefs</code>, <code>BuildApplet</code>, etc. This is |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 367 | easiest done with the <code>fullbuild</code> script from |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 368 | <code>Mac:scripts</code>. <p> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 369 | |
| 370 | <BLOCKQUOTE> |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 371 | Actually, the <code>fullbuild</code> script can be used to build |
| 372 | everything, but you need a fully-functional interpreter before you can |
| 373 | use it (and one that isn't rebuilt in the process: you cannot rebuild |
| 374 | a running program). You could copy the 68K interpreter to a different |
| 375 | place and use that to run fullbuild, or use the standalone PPC python |
| 376 | for this. I tend to keep a standalone interpreter in a safe place for |
Jack Jansen | e66b8c8 | 1997-05-29 14:57:07 +0000 | [diff] [blame] | 377 | this use only. <p> |
| 378 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 379 | </BLOCKQUOTE> |
| 380 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 381 | You are all set now, and should read the release notes and |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 382 | <code>ReadMe</code> file from the <code>Mac</code> folder. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 383 | |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 384 | <H2>Rebuilding <code>.exp</code> files for PPC and CFM68K</H2> |
| 385 | |
| 386 | Occasionally it may be necessary to rebuild your PythonCore <code>.exp</code> |
| 387 | file, a file that controls which symbols are exported by your PythonCore |
| 388 | shared library. Rebuild it if you get unexpected undefined symbols when you |
| 389 | are building a plugin module. <p> |
| 390 | |
| 391 | Rebuilding the .exp file is done by first removing the file and removing the |
| 392 | reference to it in the project (in the "config" section). Next, build PythonCore. |
| 393 | This will create a new .exp file. Edit this file to remove the references to |
| 394 | the symbols <code>__initialize</code>, <code>__terminate</code>, <code>setjmp</code>, |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 395 | <code>longjmp</code>, <code>main</code> and (for PPC) <code>__ptmf_null</code> or (for |
| 396 | CFM68K) <code>__start</code> and <code>dummy_init_routine</code>. |
| 397 | Next, add the .exp file to the project |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 398 | again and rebuild PythonCore. <p> |
| 399 | |
| 400 | This rather convoluted procedure is needed to ensure that plugin modules don't |
| 401 | accidentally link with those entrypoints from PythonCore, which will not work because |
| 402 | those routines have to be in the same code fragment as they are used from. |
| 403 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 404 | <H2>Odds and ends</H2> |
| 405 | |
| 406 | Some remarks that I could not fit in elsewhere: |
| 407 | |
| 408 | <UL> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 409 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 410 | <LI> It may be possible to use the <code>PythonCore</code> shared |
| 411 | library to embed Python in another program, if your program can live |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 412 | with using GUSI for I/O. Use PythonCore in stead of your MSL C library |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 413 | (or, at the very least, link it before the normal C library). Let me |
| 414 | know whether this works. |
| 415 | |
| 416 | <LI> It is possible to build PPC extension modules without building a |
| 417 | complete Python. Take the binary distribution, add folders |
| 418 | <code>Include</code>, <code>Mac:Include</code> and |
| 419 | <code>Mac:mwerks</code> from the source distribution and you should be |
| 420 | all set. A template for a dynamic module can be found in |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 421 | <code>xx.prj</code>. |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 422 | |
| 423 | <LI> The Python shared library architecture is a variant of the architecture |
| 424 | described as "application with shared libraries and dropins" in the MetroWerks |
| 425 | "Targeting MacOS" documentation. The Python Application and applet-template use |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 426 | the <code>MSL AppRuntime.Lib</code> runtime library (with properly set CFM |
| 427 | initialization and termination routines). PythonCore uses <code>MSL Runtime.Lib</code>, |
| 428 | which is really intended for standalone programs but which we fool into working by |
| 429 | providing a dummy main program. |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 430 | It is linked statically into PythonCore (and exported to the applications and plugins) |
| 431 | so we do not have to distribute yet another shared library. Plugin modules use |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 432 | <code>MSL ShlibRuntime.Lib</code> (not the dropin runtime: modules are never unloaded) |
| 433 | and obtain the rest from PythonCore. PythonCore uses a |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 434 | non-standard initialization entry point, <code>__initialize_with_resources</code>, to |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 435 | be able to obtain resources from the library file later on. Plugins can do the same |
| 436 | (_tkinter does) or use the standard <code>__initialize</code> entry point. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 437 | |
| 438 | |
Jack Jansen | 6ad8d13 | 1997-01-15 16:53:37 +0000 | [diff] [blame] | 439 | </UL> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 440 | </BODY> |
| 441 | </HTML> |