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 | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 47 | been built with version 11 of CodeWarrior. 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 |
| 49 | homepage</A>. You might still be able to build Python with MPW or |
| 50 | Think/Symantec C but you are basically on your own. |
| 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>. |
| 57 | At the moment Python is built with a rather hacked-up version of GUSI, |
| 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 |
| 64 | number 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 | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 78 | The current distributions, Tcl 7.6 and Tk 4.2 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 |
| 84 | was built using version 1.2, which you can obtain from <A |
| 85 | HREF="ftp://rhino.harvard.edu/pub/dan/WASTE"><ftp://rhino.harvard.edu/pub/dan/WASTE></A> |
| 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 | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 124 | MoreFiles 1.4.3 (not needed by Python, only by tcl/tk) |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 125 | Python |
Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 126 | Tcl 7.6 |
| 127 | Tk 4.2 |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 128 | Waste 1.2 distribution (if you want waste) |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 129 | </PRE> |
| 130 | |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 131 | First build GUSI. If you didn't get the python-specific GUSI you have to |
| 132 | move the files from the "CWGUSI-mods" to the right |
Jack Jansen | e66b8c8 | 1997-05-29 14:57:07 +0000 | [diff] [blame^] | 133 | place in the CWGUSI distribution folder. Build the |
| 134 | projects <code>MSLGUSI.68K.µ</code>, <code>MSLGUSI.CFM68K.µ</code> and |
| 135 | <code>MSLGUSI.PPC.µ</code>. <p> |
Jack Jansen | 16e99c0 | 1996-09-07 17:11:26 +0000 | [diff] [blame] | 136 | |
Jack Jansen | e66b8c8 | 1997-05-29 14:57:07 +0000 | [diff] [blame^] | 137 | If you have a CWGUSI version more recent than |
| 138 | 1.8 it could be that the fixes are already included, check it. |
Jack Jansen | 16e99c0 | 1996-09-07 17:11:26 +0000 | [diff] [blame] | 139 | Next, in |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 140 | <code>MoreFiles</code>, <code>libjpeg</code>, <code>pbmplus</code>, |
| 141 | <code>zlib</code>, <code>libpng</code>, <code>gdbm</code>, |
| 142 | and<code>libtiff</code> you build all projects. Sometimes the projects are in "mac" |
| 143 | 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] | 144 | case, see below. Of course, if you are only interested in one of |
| 145 | static 68K, CFM68K or PPC you can skip building the other libraries. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 146 | |
| 147 | <H2><A NAME="tcltk">Building Tcl/Tk</H2> |
| 148 | |
Jack Jansen | e66b8c8 | 1997-05-29 14:57:07 +0000 | [diff] [blame^] | 149 | You need to make some minor changes to the Tcl/Tk |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 150 | distribution. The current instructions are for the |
Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 151 | <code>tcl7.6</code> and <code>tk4.2</code> distribution: |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 152 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 153 | <UL> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 154 | |
Jack Jansen | e66b8c8 | 1997-05-29 14:57:07 +0000 | [diff] [blame^] | 155 | <LI> You have to change the access path setting and such to use the MSL |
| 156 | libraries (this tcl/tk ditribution predates MSL). |
| 157 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 158 | <LI> Rename the <code>compat</code> folders to <code>(compat)</code> |
| 159 | in both the Tcl and Tk folders. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 160 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 161 | <LI> In the Tcl folder, move <code>strncasecmp.c</code> and |
| 162 | <code>tclErrno.h</code> from <code>(compat)</code> to the main Tcl |
| 163 | folder. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 164 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 165 | <LI> Fix <code>dnr.c</code> as provided by MetroWerks by inserting |
| 166 | <pre><code> #pragma ANSI_strict off </code></pre> at the |
| 167 | beginning. The tcl library is built with strict ANSI on, and this file |
| 168 | uses C++ style comments. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 169 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 170 | <LI> If you want to build <code>SimpleTcl</code> and |
Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 171 | <code>SimpleTk</code> you may have to remove the references |
| 172 | to <code>libmoto</code> from the project, not everyone has this library. |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 173 | |
Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 174 | <LI> If you want to build for CFM68K you have to create the projects |
| 175 | for the libraries yourself. Take the 68K library projects, set the C++ header |
| 176 | file to "MW_TclHeaderCFM68K", the project type to "cfm68K library" and the |
| 177 | filename to "Tcl-CFM68K.Lib" (and similarly for Tk). |
| 178 | You may also have to modify <code>TclMacNotify.c</code> |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 179 | because there is an error in the Apple Universal headers (sic!). Read the |
| 180 | comments at the beginning of <code>Mac:Python:macglue.c</code> and copy the |
| 181 | code to <code>TclMacNotify.c</code>. If you get linker errors on <code>GetEvQHdr</code> |
Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 182 | you have not done this correctly. <em>XXXX Is this still needed?</em> |
| 183 | |
| 184 | <LI> Note that if you use a different release of Tcl and Tk than the ones |
| 185 | I have used you may have to adapt the Python <code>tkresources.rsrc</code> file. |
| 186 | This is easiest done by building <code>SimpleTk</code> and copying the TEXT, ICON |
| 187 | and CRSR resources from it to <code>tkresources.rsrc</code>. This allows |
| 188 | the <code>_tkinter</code> module to work without an installed Tk/Tcl on your |
| 189 | machine. |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 190 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 191 | </UL> |
| 192 | |
Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 193 | Build first the Tcl library, then |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 194 | SimpleTcl (test it by typing <code>ls -l</code> in the window you get) |
| 195 | then the Tk library, then SimpleTk (which can again be tested with |
| 196 | <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] | 197 | building Python. |
| 198 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 199 | <H2>Building Waste</H2> |
| 200 | |
| 201 | You do not need to build the Waste libraries, as Python includes the |
| 202 | source modules themselves. You have to make one modification, |
| 203 | though. In file <code>ICCFMGlue.c</code> in folder <code>Minimal IC |
| 204 | APIs</code>, add the following lines: |
| 205 | |
| 206 | <blockquote><pre><code> |
| 207 | #include <Gestalt.h> |
| 208 | #include <Errors.h> |
| 209 | </code></pre></blockquote> |
| 210 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 211 | <H2>The organization of the Python source tree</H2> |
| 212 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 213 | Time for a short break, while we have a look at the organization of |
| 214 | the Python source tree. At the top level, we find the following |
| 215 | folders: |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 216 | |
| 217 | <DL> |
| 218 | <DT> build.mac68k.stand |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 219 | <DD> This is where you build static 68K interpreters. |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 220 | |
| 221 | <DT> build.mac68k.shared |
| 222 | <DD> This is where you build the CFM68K shared library, interpreter |
| 223 | and applet framework. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 224 | |
| 225 | <DT> build.macppc.shared |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 226 | <DD> This is where you build the PPC shared library, interpreter and |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 227 | applet framework. You can also build the fat applet framework here. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 228 | |
| 229 | <DT> build.macppc.stand |
| 230 | <DD> This is where you build a nonshared PPC interpreter (optional). |
| 231 | |
| 232 | <DT> Demo |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 233 | <DD> Demo programs that are not Mac-specific. Some of these may not |
| 234 | work, the file <code>README-Mac</code> has some details. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 235 | |
| 236 | <DT> Extensions |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 237 | <DD> Extensions to the interpreter that are not Mac-specific. Contains |
| 238 | only the <code>img</code> extension in this distribution. Extensions |
| 239 | are <em>not</em> built here, as they are on Unix, but incorporated in |
| 240 | the core interpreter or built as plugin modules. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 241 | |
| 242 | <DT> Grammar |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 243 | <DD> The Python grammar. Included for reference only, you cannot build |
| 244 | the parser on a Mac. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 245 | |
| 246 | <DT> Include |
| 247 | <DD> Machine-independent header files. |
| 248 | |
| 249 | <DT> Modules |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 250 | <DD> Machine-independent optional modules. Not all of these will work |
| 251 | on the Mac. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 252 | |
| 253 | <DT> Objects |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 254 | <DD> Machine-independent code for various objects. Most of these are |
| 255 | not really optional: the interpreter will not function without them. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 256 | |
| 257 | <DT> Parser |
| 258 | <DD> The Python parser (machine-independent). |
| 259 | |
| 260 | <DT> PlugIns |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 261 | <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] | 262 | |
| 263 | <DT> Python |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 264 | <DD> The core interpreter. Most files are machine-independent, some |
| 265 | are unix-specific and not used on the Mac. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 266 | |
| 267 | <DT> Tools |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 268 | <DD> Tools for python developers. Contains <code>modulator</code> |
| 269 | which builds skeleton C extension modules and <code>bgen</code> which |
| 270 | generates complete interface modules from information in C header |
| 271 | files. There are some readme files, but more documentation is sorely |
| 272 | needed. |
| 273 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 274 | </DL> |
| 275 | |
| 276 | All the mac-specific stuff lives in the <code>Mac</code> folder: |
| 277 | <DL> |
| 278 | |
| 279 | <DT> Compat |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 280 | <DD> Unix-compatability routines. Some of these are not used anymore, |
| 281 | since CWGUSI provides a rather complete emulation, but you may need |
| 282 | these if you are trying to build a non-GUSI python. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 283 | |
| 284 | <DT> Demo |
| 285 | <DD> Mac-specific demo programs, some of them annotated. |
| 286 | |
| 287 | <DT> Include |
| 288 | <DD> Mac-specific but compiler-independent include files. |
| 289 | |
| 290 | <DT> Lib |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 291 | <DD> Mac-specific standard modules. The <code>toolbox</code> folder |
| 292 | contains modules specifically needed with various MacOS toolbox |
| 293 | interface modules. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 294 | |
| 295 | <DT> Modules |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 296 | <DD> Mac-specific builtin modules. Theoretically these are all |
| 297 | optional, but some are rather essential (like |
| 298 | <code>macmodule</code>). A lot of these modules are generated with |
| 299 | <code>bgen</code>, in which case the bgen input files are included so |
| 300 | you can attempt to regenerate them or extend them. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 301 | |
| 302 | <DT> MPW |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 303 | <DD> MPW-specific files. These have not been used or kept up-to-date |
| 304 | for a long time, so use at your own risk. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 305 | |
| 306 | <DT> mwerks |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 307 | <DD> Mwerks-specific sources and headers. Contains glue code for |
| 308 | Pythons shared-library architecture, a replacement for |
| 309 | <code>malloc</code> and a directory with various projects for building |
| 310 | variations on the Python interpreter. The <code>mwerks_*.h</code> |
| 311 | files here are the option-setting files for the various interpreters |
| 312 | and such, comparable to the unix command-line <code>-D</code> options |
| 313 | to the compiler. Each project uses the correct option file as its |
| 314 | "prefix file" in the "C/C++ language" settings. Disabling optional |
| 315 | modules (for the 68K interpreter), building non-GUSI interpreters and |
| 316 | various other things are accomplished by modifying these files (and |
| 317 | possibly changing the list of files included in the project window, of |
| 318 | course). |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 319 | |
| 320 | <DT> Python |
| 321 | <DD> Mac-specific parts of the core interpreter. |
| 322 | |
| 323 | <DT> Resources |
| 324 | <DD> Resource files needed to build the interpreter. |
| 325 | |
| 326 | <DT> Scripts |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 327 | <DD> A collection of various mac-specific Python scripts. Some are |
| 328 | essential, some are useful but few are documented, so you will have to |
| 329 | use your imagination to work them out. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 330 | |
| 331 | <DT> Unsupported |
| 332 | <DD> Modules that are not supported any longer but may still work with a little effort. |
| 333 | </DL> |
| 334 | |
| 335 | <H2>Building the 68K interpreter</H2> |
| 336 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 337 | If you have all the optional libraries mentioned <A |
| 338 | HREF="#optional">above</A> loaded buildin Python for 68K macs is a |
| 339 | breeze: open the project in the folder <code>build.mac68k.stand</code> |
| 340 | and build it. Do <em>not</em> run it yet, this will possibly result |
| 341 | in a garbled preferences file. <p> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 342 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 343 | First remove the <code>Python preferences</code> file from your |
| 344 | preference folder, only if you had an older version of Python |
| 345 | installed. (this is also what you do if you did not heed the last |
| 346 | sentence of the preceeding paragraph). Next, move the interpreter to |
| 347 | the main Python folder (up one level) and run it there. This will |
| 348 | create a correct initial preferences file. You are now all set, and |
| 349 | your tree should be completely compatible with a binary-only |
| 350 | distribution. Read the release notes |
| 351 | (<code>Relnotes-somethingorother</code>) and |
| 352 | <code>ReadMeOrSuffer</code> in the <code>Mac</code> folder. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 353 | |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 354 | <H2>Building the CFM68K interpreter</H2> |
| 355 | |
| 356 | Building the CFM68K interpreter is as almost exactly the same as building |
| 357 | the PPC interpreter, with the exception that you should read "CFM68K" |
| 358 | for "PPC" every time. Continue reading with the next section. |
| 359 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 360 | <H2>Building the PPC interpreter</H2> |
| 361 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 362 | First you build the interpreter, core library and applet skeleton in |
| 363 | folder <code>build.macppc.stand</code>. The order to build things is |
| 364 | the following: |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 365 | |
| 366 | <DL> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 367 | |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 368 | <DT> PythonCorePPC |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 369 | <DD> The shared library that contains the bulk of the interpreter and |
| 370 | its resources. It is a good idea to immedeately put an alias to this |
| 371 | shared library in the <code>Extensions</code> folder of your system |
| 372 | folder. Do exactly that: put an <em>alias</em> there, copying or |
| 373 | moving the file will cause you grief later. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 374 | |
| 375 | <DT> PythonPPC |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 376 | <DD> The interpreter. This is basically a routine to call out to the |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 377 | shared library. Do |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 378 | <em>not</em> run it yet, this will possibly result in a garbled |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 379 | preferences file. See the section below on rebuilding .exp files if you |
| 380 | get funny linker errors. <p> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 381 | |
Jack Jansen | 061ac50 | 1996-10-22 15:27:56 +0000 | [diff] [blame] | 382 | <DT> PythonAppletPPC |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 383 | <DD> The applet skeleton application. Very similar to |
| 384 | <code>PythonPPC</code>, but it calls to a different entrypoint in the |
| 385 | core library. The <code>mkapplet</code> script will copy this complete |
| 386 | file, and add a <code>'PYC '</code> with the module to generate an |
| 387 | applet. <p> |
| 388 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 389 | </DL> |
| 390 | |
Jack Jansen | 061ac50 | 1996-10-22 15:27:56 +0000 | [diff] [blame] | 391 | After creating the alias to <code>PythonCorePPC</code> you should move |
| 392 | <code>PythonPPC</code> to the main Python folder. Next you remove any old |
| 393 | <code>Python XXX Preferences</code> file from the <code>Preferences</code> folder |
| 394 | (if you had python installed on your system before) and run the interpreter once |
| 395 | to create the correct preferences file. You should also make an alias |
| 396 | <code>PythonApplet</code> pointing to <code>PythonAppletPPC</code> in the main |
| 397 | Python folder. (again: making an alias is preferrable to copying or moving the |
| 398 | file, since this will cause the correct file to be used if you ever rebuild |
| 399 | PythonAppletPPC). <p> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 400 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 401 | Next, you have to build the extension modules in the |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 402 | <code>PlugIns</code> folder. Open each project with <code>.ppc</code> in the |
| 403 | name and build it. After all |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 404 | the dynamically loaded modules are built you have to create a number |
| 405 | of aliases: some modules live together in a single dynamic |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 406 | library. Run the <code>MkPluginAliases.py</code> script from |
| 407 | <code>Mac:scripts</code> to create the aliases. <p> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 408 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 409 | Finally, you must build the standard applets: |
| 410 | <code>EditPythonPrefs</code>, <code>mkapplet</code>, etc. This is |
| 411 | easiest done with the <code>fullbuild</code> script from |
| 412 | <code>Mac:scripts</code>. Answer <em>no</em> to all questions except |
| 413 | when it asks whether to build the applets. <p> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 414 | |
| 415 | <BLOCKQUOTE> |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 416 | Actually, the <code>fullbuild</code> script can be used to build |
| 417 | everything, but you need a fully-functional interpreter before you can |
| 418 | use it (and one that isn't rebuilt in the process: you cannot rebuild |
| 419 | a running program). You could copy the 68K interpreter to a different |
| 420 | place and use that to run fullbuild, or use the standalone PPC python |
| 421 | 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^] | 422 | this use only. <p> |
| 423 | |
| 424 | Using fullbuild is also the only easy way to buid the fat application and applet. |
| 425 | See the fullbuild source for details on how to build the fat binaries "by hand". |
| 426 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 427 | </BLOCKQUOTE> |
| 428 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 429 | You are all set now, and should read the release notes and |
| 430 | <code>ReadMeOrSuffer</code> file from the <code>Mac</code> folder. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 431 | |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 432 | <H2>Rebuilding <code>.exp</code> files for PPC and CFM68K</H2> |
| 433 | |
| 434 | Occasionally it may be necessary to rebuild your PythonCore <code>.exp</code> |
| 435 | file, a file that controls which symbols are exported by your PythonCore |
| 436 | shared library. Rebuild it if you get unexpected undefined symbols when you |
| 437 | are building a plugin module. <p> |
| 438 | |
| 439 | Rebuilding the .exp file is done by first removing the file and removing the |
| 440 | reference to it in the project (in the "config" section). Next, build PythonCore. |
| 441 | This will create a new .exp file. Edit this file to remove the references to |
| 442 | the symbols <code>__initialize</code>, <code>__terminate</code>, <code>setjmp</code>, |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 443 | <code>longjmp</code>, <code>main</code> and (for PPC) <code>__ptmf_null</code> or (for |
| 444 | CFM68K) <code>__start</code> and <code>dummy_init_routine</code>. |
| 445 | Next, add the .exp file to the project |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 446 | again and rebuild PythonCore. <p> |
| 447 | |
| 448 | This rather convoluted procedure is needed to ensure that plugin modules don't |
| 449 | accidentally link with those entrypoints from PythonCore, which will not work because |
| 450 | those routines have to be in the same code fragment as they are used from. |
| 451 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 452 | <H2>Odds and ends</H2> |
| 453 | |
| 454 | Some remarks that I could not fit in elsewhere: |
| 455 | |
| 456 | <UL> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 457 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 458 | <LI> It may be possible to use the <code>PythonCore</code> shared |
| 459 | library to embed Python in another program, if your program can live |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 460 | 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] | 461 | (or, at the very least, link it before the normal C library). Let me |
| 462 | know whether this works. |
| 463 | |
| 464 | <LI> It is possible to build PPC extension modules without building a |
| 465 | complete Python. Take the binary distribution, add folders |
| 466 | <code>Include</code>, <code>Mac:Include</code> and |
| 467 | <code>Mac:mwerks</code> from the source distribution and you should be |
| 468 | all set. A template for a dynamic module can be found in |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 469 | <code>xx.ppc.µ</code> or <code>xx.CFM68K.µ</code>. |
| 470 | |
| 471 | <LI> The Python shared library architecture is a variant of the architecture |
| 472 | described as "application with shared libraries and dropins" in the MetroWerks |
| 473 | "Targeting MacOS" documentation. The Python Application and applet-template use |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 474 | the <code>MSL AppRuntime.Lib</code> runtime library (with properly set CFM |
| 475 | initialization and termination routines). PythonCore uses <code>MSL Runtime.Lib</code>, |
| 476 | which is really intended for standalone programs but which we fool into working by |
| 477 | providing a dummy main program. |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 478 | It is linked statically into PythonCore (and exported to the applications and plugins) |
| 479 | 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] | 480 | <code>MSL ShlibRuntime.Lib</code> (not the dropin runtime: modules are never unloaded) |
| 481 | and obtain the rest from PythonCore. PythonCore uses a |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 482 | non-standard initialization entry point, <code>__initialize_with_resources</code>, to |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 483 | be able to obtain resources from the library file later on. Plugins can do the same |
| 484 | (_tkinter does) or use the standard <code>__initialize</code> entry point. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 485 | |
| 486 | |
Jack Jansen | 6ad8d13 | 1997-01-15 16:53:37 +0000 | [diff] [blame] | 487 | </UL> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 488 | </BODY> |
| 489 | </HTML> |