| 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 | 
|  | 35 | HREF="ftp://ftp.cwi.nl/pub/jack/python/mac">ftp://ftp.cwi.nl/pub/jack/python/mac</A>, | 
|  | 36 | and possibly also from the standard <A | 
|  | 37 | HREF="ftp://ftp.python.org/pub/python/mac">python.org ftp | 
|  | 38 | site</A>. Everything you need is also included in the standard Python | 
|  | 39 | source distribution, but the organization is different. Look in | 
|  | 40 | directory <code>Mac/mwerks/projects</code> for the project files and | 
|  | 41 | related stuff. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 42 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 43 | <LI> You need MetroWerks CodeWarrior. The current distribution has | 
| Jack Jansen | abc2db7 | 1996-11-09 18:48:49 +0000 | [diff] [blame] | 44 | been built with version 10 of CodeWarrior. Ordering information is | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 45 | available on the <A HREF="http://www.metrowerks.com/">MetroWerks | 
|  | 46 | homepage</A>. You might still be able to build Python with MPW or | 
|  | 47 | Think/Symantec C but you are basically on your own. | 
|  | 48 |  | 
|  | 49 | <LI> You need GUSI, the Grand Unified Socket Interface, by Matthias | 
| Jack Jansen | 16e99c0 | 1996-09-07 17:11:26 +0000 | [diff] [blame] | 50 | Neeracher. The current distribution has been built with a modified version of | 
| Jack Jansen | 061ac50 | 1996-10-22 15:27:56 +0000 | [diff] [blame] | 51 | CWGUSI 1.8.0. CWGUSI is | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 52 | obtainable from <A | 
| Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 53 | HREF="ftp://sunsite.cnlab-switch.ch/software/platform/macos/src"> | 
|  | 54 | ftp://sunsite.cnlab-switch.ch/software/platform/macos/src</A>. | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 55 | It is possible to build a non-GUSI Python, see below. | 
|  | 56 |  | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 57 | </UL> | 
|  | 58 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 59 | <A NAME="optional">The MacPython project files are configured to | 
|  | 60 | include a plethora of optional modules</A>, and these modules need a | 
|  | 61 | 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] | 62 | 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] | 63 | 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] | 64 | suffices to just refrain from builing the extension module. For static 68K | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 65 | Python things are a bit more complicated: you have to edit the | 
|  | 66 | interpreter project file to remove the reference to the module (and | 
| Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 67 | the libraries it uses), and edit the <code>Mac:mwerks:mwerks_nonshared_config.h</code> | 
|  | 68 | 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] | 69 | you need: | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 70 |  | 
|  | 71 | <UL> | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 72 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 73 | <LI> Tcl and Tk can be obtained from <A | 
|  | 74 | 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] | 75 | 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] | 76 | see the section on <A HREF="#tcltk">building Tcl/Tk Python</A> | 
|  | 77 | below. Get the "full source" distribution, which includes MoreFiles. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 78 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 79 | <LI> Waste, a TextEdit replacement written by Marco Piovanelli, <A | 
|  | 80 | HREF="mailto:piovanel@kagi.com"><piovanel@kagi.com></A>.  Python | 
|  | 81 | was built using version 1.2, which you can obtain from <A | 
|  | 82 | HREF="ftp://rhino.harvard.edu/pub/dan/WASTE"><ftp://rhino.harvard.edu/pub/dan/WASTE></A> | 
|  | 83 | and various other places. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 84 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 85 | <LI> JPEG library by the Independent JPEG Group. Python is still built | 
|  | 86 | using an archaic version of the library, version 4. It can be obtained | 
|  | 87 | from the <A HREF="ftp://ftp.cwi.nl/pub/jack/python/mac"> | 
|  | 88 | ftp://ftp.cwi.nl/pub/jack/python/mac</A> directory, complete with CW8 | 
|  | 89 | projects. If someone manages to build Python with the version 6 | 
|  | 90 | library I would be grateful if they sent me the changes needed.  The | 
|  | 91 | most recent JPEG library can always be obtained from <A | 
|  | 92 | HREF="ftp://ftp.uu.net/graphics/jpeg/">ftp://ftp.uu.net/graphics/jpeg/</A>. | 
|  | 93 |  | 
|  | 94 | <LI> The netpbm/pbmplus and libtiff libraries. The netpbm distribution | 
|  | 95 | (which includes libtiff) is generally available on Internet ftp | 
|  | 96 | servers. For Python pbmplus, an older incarnation of netpbm, is | 
|  | 97 | functionally identical to netpbm, since Python only uses the library | 
|  | 98 | and not the complete applications. A distribution with correct | 
|  | 99 | projects and library source only is available from, you guessed it, <A | 
|  | 100 | HREF="ftp://ftp.cwi.nl/pub/jack/python/mac">ftp://ftp.cwi.nl/pub/jack/python/mac</A>. | 
|  | 101 |  | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 102 | </UL> | 
|  | 103 |  | 
|  | 104 | <H2>Setting Up</H2> | 
|  | 105 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 106 | Now that you have collected everything you should start with building | 
|  | 107 | the various parts. Everything is independent, with the single | 
|  | 108 | exception that Tcl and Tk depend on CWGUSI. If you don't want to fix | 
|  | 109 | access paths try to set things up as follows: | 
|  | 110 |  | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 111 | <PRE> | 
|  | 112 | Top-level-folder: | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 113 | CWGUSI | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 114 | imglibs | 
|  | 115 | libjpeg | 
|  | 116 | pbmplus | 
|  | 117 | libtiff | 
| Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 118 | MoreFiles 1.4.3 (not needed by Python, only by tcl/tk) | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 119 | Python | 
| Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 120 | Tcl 7.6 | 
|  | 121 | Tk 4.2 | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 122 | Waste 1.2 distribution (if you want waste) | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 123 | </PRE> | 
|  | 124 |  | 
| Jack Jansen | 16e99c0 | 1996-09-07 17:11:26 +0000 | [diff] [blame] | 125 | First build GUSI. Move the files from the "CWGUSI-mods" to the right | 
|  | 126 | place in the CWGUSI distribution folder, and build the | 
| Jack Jansen | abc2db7 | 1996-11-09 18:48:49 +0000 | [diff] [blame] | 127 | projects <code>GUSI.68K.µ</code>, <code>GUSI.CFM68K.µ</code> and | 
|  | 128 | <code>GUSI.PPC.µ</code>. | 
|  | 129 | Two notes: | 
|  | 130 | <ul> | 
|  | 131 | <li> The projects as distributed have a slightly incorrect access path, due | 
|  | 132 | to which they cannot find their <code>GUSICWFile.???</code> files. Change | 
|  | 133 | the access path to <code>{project folder}::</code> to fix this. | 
|  | 134 | <li> The Gusi CFM68K project is | 
|  | 135 | distributed without "far data": you should set this option before building. | 
|  | 136 | </ul> | 
| Jack Jansen | 319f1a2 | 1996-10-16 15:28:30 +0000 | [diff] [blame] | 137 | If you have a CWGUSI version more recent than | 
| Jack Jansen | abc2db7 | 1996-11-09 18:48:49 +0000 | [diff] [blame] | 138 | 1.8 it could be that the fixes are already included, check it. Alternatively, | 
| Jack Jansen | 16e99c0 | 1996-09-07 17:11:26 +0000 | [diff] [blame] | 139 | you can forget about the fixes and remove the one reference to GUSILoadPreferences | 
|  | 140 | in the Python sources. This will disable the "default file creator/type" and | 
|  | 141 | "Delay Sioux window" preferences in Python. | 
|  | 142 |  | 
|  | 143 | Next, in | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 144 | <code>MoreFiles</code>, <code>libjpeg</code>, <code>pbmplus</code> | 
|  | 145 | and<code>libtiff</code> you build all projects. Tcl/tk is a special | 
| Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 146 | case, see below. Of course, if you are only interested in one of | 
|  | 147 | static 68K, CFM68K or PPC you can skip building the other libraries. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 148 |  | 
|  | 149 | <H2><A NAME="tcltk">Building Tcl/Tk</H2> | 
|  | 150 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 151 | You need to make a minor organizational change to the Tcl/Tk | 
|  | 152 | distribution. The current instructions are for the | 
| Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 153 | <code>tcl7.6</code> and <code>tk4.2</code> distribution: | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 154 |  | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 155 | <UL> | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 156 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 157 | <LI> Rename the <code>compat</code> folders to <code>(compat)</code> | 
|  | 158 | in both the Tcl and Tk folders. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 159 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 160 | <LI> In the Tcl folder, move <code>strncasecmp.c</code> and | 
|  | 161 | <code>tclErrno.h</code> from <code>(compat)</code> to the main Tcl | 
|  | 162 | folder. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 163 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 164 | <LI> Fix <code>dnr.c</code> as provided by MetroWerks by inserting | 
|  | 165 | <pre><code> #pragma ANSI_strict off </code></pre> at the | 
|  | 166 | beginning. The tcl library is built with strict ANSI on, and this file | 
|  | 167 | uses C++ style comments. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 168 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 169 | <LI> If you want to build <code>SimpleTcl</code> and | 
| Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 170 | <code>SimpleTk</code> you may  have to remove the references | 
|  | 171 | to <code>libmoto</code> from the project, not everyone has this library. | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 172 |  | 
| Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 173 | <LI> If you want to build for CFM68K you have to create the projects | 
|  | 174 | for the libraries yourself. Take the 68K library projects, set the C++ header | 
|  | 175 | file to "MW_TclHeaderCFM68K", the project type to "cfm68K library" and the | 
|  | 176 | filename to "Tcl-CFM68K.Lib" (and similarly for Tk). | 
|  | 177 | You may also have to modify <code>TclMacNotify.c</code> | 
| Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 178 | because there is an error in the Apple Universal headers (sic!). Read the | 
|  | 179 | comments at the beginning of <code>Mac:Python:macglue.c</code> and copy the | 
|  | 180 | 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] | 181 | you have not done this correctly. <em>XXXX Is this still needed?</em> | 
|  | 182 |  | 
|  | 183 | <LI> Note that if you use a different release of Tcl and Tk than the ones | 
|  | 184 | I have used you may have to adapt the Python <code>tkresources.rsrc</code> file. | 
|  | 185 | This is easiest done by building <code>SimpleTk</code> and copying the TEXT, ICON | 
|  | 186 | and CRSR resources from it to <code>tkresources.rsrc</code>. This allows | 
|  | 187 | the <code>_tkinter</code> module to work without an installed Tk/Tcl on your | 
|  | 188 | machine. | 
| Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 189 |  | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 190 | </UL> | 
|  | 191 |  | 
| Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 192 | Build first the Tcl library, then | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 193 | SimpleTcl (test it by typing <code>ls -l</code> in the window you get) | 
|  | 194 | then the Tk library, then SimpleTk (which can again be tested with | 
|  | 195 | <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] | 196 | building Python. | 
|  | 197 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 198 | <H2>Building Waste</H2> | 
|  | 199 |  | 
|  | 200 | You do not need to build the Waste libraries, as Python includes the | 
|  | 201 | source modules themselves. You have to make one modification, | 
|  | 202 | though. In file <code>ICCFMGlue.c</code> in folder <code>Minimal IC | 
|  | 203 | APIs</code>, add the following lines: | 
|  | 204 |  | 
|  | 205 | <blockquote><pre><code> | 
|  | 206 | #include <Gestalt.h> | 
|  | 207 | #include <Errors.h> | 
|  | 208 | </code></pre></blockquote> | 
|  | 209 |  | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 210 | <H2>The organization of the Python source tree</H2> | 
|  | 211 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 212 | Time for a short break, while we have a look at the organization of | 
|  | 213 | the Python source tree.  At the top level, we find the following | 
|  | 214 | folders: | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 215 |  | 
|  | 216 | <DL> | 
|  | 217 | <DT> build.mac68k.stand | 
| Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 218 | <DD> This is where you will build static 68K interpreters. | 
|  | 219 |  | 
|  | 220 | <DT> build.mac68k.shared | 
|  | 221 | <DD> This is where you build the CFM68K shared library, interpreter | 
|  | 222 | and applet framework. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 223 |  | 
|  | 224 | <DT> build.macppc.shared | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 225 | <DD> This is where you build the PPC shared library, interpreter and | 
| Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 226 | applet framework. You can also build the fat applet framework here. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 227 |  | 
|  | 228 | <DT> build.macppc.stand | 
|  | 229 | <DD> This is where you build a nonshared PPC interpreter (optional). | 
|  | 230 |  | 
|  | 231 | <DT> Demo | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 232 | <DD> Demo programs that are not Mac-specific. Some of these may not | 
|  | 233 | work, the file <code>README-Mac</code> has some details. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 234 |  | 
|  | 235 | <DT> Extensions | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 236 | <DD> Extensions to the interpreter that are not Mac-specific. Contains | 
|  | 237 | only the <code>img</code> extension in this distribution. Extensions | 
|  | 238 | are <em>not</em> built here, as they are on Unix, but incorporated in | 
|  | 239 | the core interpreter or built as plugin modules. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 240 |  | 
|  | 241 | <DT> Grammar | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 242 | <DD> The Python grammar. Included for reference only, you cannot build | 
|  | 243 | the parser on a Mac. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 244 |  | 
|  | 245 | <DT> Include | 
|  | 246 | <DD> Machine-independent header files. | 
|  | 247 |  | 
|  | 248 | <DT> Modules | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 249 | <DD> Machine-independent optional modules. Not all of these will work | 
|  | 250 | on the Mac. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 251 |  | 
|  | 252 | <DT> Objects | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 253 | <DD> Machine-independent code for various objects. Most of these are | 
|  | 254 | not really optional: the interpreter will not function without them. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 255 |  | 
|  | 256 | <DT> Parser | 
|  | 257 | <DD> The Python parser (machine-independent). | 
|  | 258 |  | 
|  | 259 | <DT> PlugIns | 
| Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 260 | <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] | 261 |  | 
|  | 262 | <DT> Python | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 263 | <DD> The core interpreter. Most files are machine-independent, some | 
|  | 264 | are unix-specific and not used on the Mac. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 265 |  | 
|  | 266 | <DT> Tools | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 267 | <DD> Tools for python developers. Contains <code>modulator</code> | 
|  | 268 | which builds skeleton C extension modules and <code>bgen</code> which | 
|  | 269 | generates complete interface modules from information in C header | 
|  | 270 | files. There are some readme files, but more documentation is sorely | 
|  | 271 | needed. | 
|  | 272 |  | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 273 | </DL> | 
|  | 274 |  | 
|  | 275 | All the mac-specific stuff lives in the <code>Mac</code> folder: | 
|  | 276 | <DL> | 
|  | 277 |  | 
|  | 278 | <DT> Compat | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 279 | <DD> Unix-compatability routines. Some of these are not used anymore, | 
|  | 280 | since CWGUSI provides a rather complete emulation, but you may need | 
|  | 281 | these if you are trying to build a non-GUSI python. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 282 |  | 
|  | 283 | <DT> Demo | 
|  | 284 | <DD> Mac-specific demo programs, some of them annotated. | 
|  | 285 |  | 
|  | 286 | <DT> Include | 
|  | 287 | <DD> Mac-specific but compiler-independent include files. | 
|  | 288 |  | 
|  | 289 | <DT> Lib | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 290 | <DD> Mac-specific standard modules. The <code>toolbox</code> folder | 
|  | 291 | contains modules specifically needed with various MacOS toolbox | 
|  | 292 | interface modules. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 293 |  | 
|  | 294 | <DT> Modules | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 295 | <DD> Mac-specific builtin modules. Theoretically these are all | 
|  | 296 | optional, but some are rather essential (like | 
|  | 297 | <code>macmodule</code>). A lot of these modules are generated with | 
|  | 298 | <code>bgen</code>, in which case the bgen input files are included so | 
|  | 299 | you can attempt to regenerate them or extend them. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 300 |  | 
|  | 301 | <DT> MPW | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 302 | <DD> MPW-specific files. These have not been used or kept up-to-date | 
|  | 303 | for a long time, so use at your own risk. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 304 |  | 
|  | 305 | <DT> mwerks | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 306 | <DD> Mwerks-specific sources and headers. Contains glue code for | 
|  | 307 | Pythons shared-library architecture, a replacement for | 
|  | 308 | <code>malloc</code> and a directory with various projects for building | 
|  | 309 | variations on the Python interpreter. The <code>mwerks_*.h</code> | 
|  | 310 | files here are the option-setting files for the various interpreters | 
|  | 311 | and such, comparable to the unix command-line <code>-D</code> options | 
|  | 312 | to the compiler. Each project uses the correct option file as its | 
|  | 313 | "prefix file" in the "C/C++ language" settings. Disabling optional | 
|  | 314 | modules (for the 68K interpreter), building non-GUSI interpreters and | 
|  | 315 | various other things are accomplished by modifying these files (and | 
|  | 316 | possibly changing the list of files included in the project window, of | 
|  | 317 | course). | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 318 |  | 
|  | 319 | <DT> Python | 
|  | 320 | <DD> Mac-specific parts of the core interpreter. | 
|  | 321 |  | 
|  | 322 | <DT> Resources | 
|  | 323 | <DD> Resource files needed to build the interpreter. | 
|  | 324 |  | 
|  | 325 | <DT> Scripts | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 326 | <DD> A collection of various mac-specific Python scripts. Some are | 
|  | 327 | essential, some are useful but few are documented, so you will have to | 
|  | 328 | use your imagination to work them out. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 329 |  | 
|  | 330 | <DT> Unsupported | 
|  | 331 | <DD> Modules that are not supported any longer but may still work with a little effort. | 
|  | 332 | </DL> | 
|  | 333 |  | 
|  | 334 | <H2>Building the 68K interpreter</H2> | 
|  | 335 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 336 | If you have all the optional libraries mentioned <A | 
|  | 337 | HREF="#optional">above</A> loaded buildin Python for 68K macs is a | 
|  | 338 | breeze: open the project in the folder <code>build.mac68k.stand</code> | 
|  | 339 | and build it.  Do <em>not</em> run it yet, this will possibly result | 
|  | 340 | in a garbled preferences file. <p> | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 341 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 342 | First remove the <code>Python preferences</code> file from your | 
|  | 343 | preference folder, only if you had an older version of Python | 
|  | 344 | installed.  (this is also what you do if you did not heed the last | 
|  | 345 | sentence of the preceeding paragraph). Next, move the interpreter to | 
|  | 346 | the main Python folder (up one level) and run it there. This will | 
|  | 347 | create a correct initial preferences file. You are now all set, and | 
|  | 348 | your tree should be completely compatible with a binary-only | 
|  | 349 | distribution. Read the release notes | 
|  | 350 | (<code>Relnotes-somethingorother</code>) and | 
|  | 351 | <code>ReadMeOrSuffer</code> in the <code>Mac</code> folder. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 352 |  | 
| Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 353 | <H2>Building the CFM68K interpreter</H2> | 
|  | 354 |  | 
|  | 355 | Building the CFM68K interpreter is as almost exactly the same as building | 
|  | 356 | the PPC interpreter, with the exception that you should read "CFM68K" | 
|  | 357 | for "PPC" every time. Continue reading with the next section. | 
|  | 358 |  | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 359 | <H2>Building the PPC interpreter</H2> | 
|  | 360 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 361 | First you build the interpreter, core library and applet skeleton in | 
|  | 362 | folder <code>build.macppc.stand</code>.  The order to build things is | 
|  | 363 | the following: | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 364 |  | 
|  | 365 | <DL> | 
| Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 366 | <DT> MWRuntimeStaticLib | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 367 | <DD> A modified version of the MetroWerks runtime library that is | 
|  | 368 | suitable for Pythons' shared library architecture. The sources all | 
|  | 369 | come from the MW distribution. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 370 |  | 
| Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 371 | <DT> PythonCorePPC | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 372 | <DD> The shared library that contains the bulk of the interpreter and | 
|  | 373 | its resources. It is a good idea to immedeately put an alias to this | 
|  | 374 | shared library in the <code>Extensions</code> folder of your system | 
|  | 375 | folder.  Do exactly that: put an <em>alias</em> there, copying or | 
|  | 376 | moving the file will cause you grief later. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 377 |  | 
|  | 378 | <DT> PythonPPC | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 379 | <DD> The interpreter. This is basically a routine to call out to the | 
|  | 380 | shared library. Because of the organization of GUSI it also contains | 
|  | 381 | the Gusi settings resource (together with a ResEdit template, so you | 
|  | 382 | can change the gusi settings should you feel like doing so).  Do | 
|  | 383 | <em>not</em> run it yet, this will possibly result in a garbled | 
|  | 384 | preferences file. <p> | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 385 |  | 
| Jack Jansen | 061ac50 | 1996-10-22 15:27:56 +0000 | [diff] [blame] | 386 | <DT> PythonAppletPPC | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 387 | <DD> The applet skeleton application. Very similar to | 
|  | 388 | <code>PythonPPC</code>, but it calls to a different entrypoint in the | 
|  | 389 | core library. The <code>mkapplet</code> script will copy this complete | 
|  | 390 | file, and add a <code>'PYC '</code> with the module to generate an | 
|  | 391 | applet. <p> | 
|  | 392 |  | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 393 | </DL> | 
|  | 394 |  | 
| Jack Jansen | 061ac50 | 1996-10-22 15:27:56 +0000 | [diff] [blame] | 395 | After creating the alias to <code>PythonCorePPC</code> you should move | 
|  | 396 | <code>PythonPPC</code> to the main Python folder. Next you remove any old | 
|  | 397 | <code>Python XXX Preferences</code> file from the <code>Preferences</code> folder | 
|  | 398 | (if you had python installed on your system before) and run the interpreter once | 
|  | 399 | to create the correct preferences file. You should also make an alias | 
|  | 400 | <code>PythonApplet</code> pointing to <code>PythonAppletPPC</code> in the main | 
|  | 401 | Python folder. (again: making an alias is preferrable to copying or moving the | 
|  | 402 | file, since this will cause the correct file to be used if you ever rebuild | 
|  | 403 | PythonAppletPPC). <p> | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 404 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 405 | Next, you have to build the extension modules in the | 
| Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 406 | <code>PlugIns</code> folder. Open each project with <code>.ppc</code> in the | 
|  | 407 | name and build it. After all | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 408 | the dynamically loaded modules are built you have to create a number | 
|  | 409 | of aliases: some modules live together in a single dynamic | 
| Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 410 | library. Run the <code>MkPluginAliases.py</code> script from | 
|  | 411 | <code>Mac:scripts</code> to create the aliases. <p> | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 412 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 413 | Finally, you must build the standard applets: | 
|  | 414 | <code>EditPythonPrefs</code>, <code>mkapplet</code>, etc. This is | 
|  | 415 | easiest done with the <code>fullbuild</code> script from | 
|  | 416 | <code>Mac:scripts</code>. Answer <em>no</em> to all questions except | 
|  | 417 | when it asks whether to build the applets. <p> | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 418 |  | 
|  | 419 | <BLOCKQUOTE> | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 420 | Actually, the <code>fullbuild</code> script can be used to build | 
|  | 421 | everything, but you need a fully-functional interpreter before you can | 
|  | 422 | use it (and one that isn't rebuilt in the process: you cannot rebuild | 
|  | 423 | a running program). You could copy the 68K interpreter to a different | 
|  | 424 | place and use that to run fullbuild, or use the standalone PPC python | 
|  | 425 | for this. I tend to keep a standalone interpreter in a safe place for | 
|  | 426 | this use only. | 
| 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>, | 
|  | 443 | <code>longjmp</code> and <code>__ptmf_null</code>. Next, add the .exp file to the project | 
|  | 444 | again and rebuild PythonCore. <p> | 
|  | 445 |  | 
|  | 446 | This rather convoluted procedure is needed to ensure that plugin modules don't | 
|  | 447 | accidentally link with those entrypoints from PythonCore, which will not work because | 
|  | 448 | those routines have to be in the same code fragment as they are used from. | 
|  | 449 |  | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 450 | <H2>Odds and ends</H2> | 
|  | 451 |  | 
|  | 452 | Some remarks that I could not fit in elsewhere: | 
|  | 453 |  | 
|  | 454 | <UL> | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 455 |  | 
| Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 456 | <LI> It may be possible to use the <code>PythonCore</code> shared | 
|  | 457 | library to embed Python in another program, if your program can live | 
|  | 458 | with using GUSI for I/O. Use PythonCore in stead of your C library | 
|  | 459 | (or, at the very least, link it before the normal C library). Let me | 
|  | 460 | know whether this works. | 
|  | 461 |  | 
|  | 462 | <LI> It is possible to build PPC extension modules without building a | 
|  | 463 | complete Python. Take the binary distribution, add folders | 
|  | 464 | <code>Include</code>, <code>Mac:Include</code> and | 
|  | 465 | <code>Mac:mwerks</code> from the source distribution and you should be | 
|  | 466 | all set. A template for a dynamic module can be found in | 
| Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 467 | <code>xx.ppc.µ</code> or <code>xx.CFM68K.µ</code>. | 
|  | 468 |  | 
|  | 469 | <LI> The Python shared library architecture is a variant of the architecture | 
|  | 470 | described as "application with shared libraries and dropins" in the MetroWerks | 
|  | 471 | "Targeting MacOS" documentation. The Python Application and applet-template use | 
|  | 472 | the <code>AppRuntime.Lib</code> runtime library (with properly set CFM | 
|  | 473 | initialization and termination routines). PythonCore uses <code>ShlibRuntime.Lib</code> | 
|  | 474 | and <code>MWRuntimeStaticLib.Lib</code>, which is almost identical to the MW | 
|  | 475 | standard <code>MWRuntimeLib</code>, but not dynamically loaded. This library contains | 
|  | 476 | the part of the runtime that can (or must) be shared between all modules in the program. | 
|  | 477 | It is linked statically into PythonCore (and exported to the applications and plugins) | 
|  | 478 | so we do not have to distribute yet another shared library. Plugin modules use | 
|  | 479 | <code>ShlibRuntime.Lib</code> and obtain the rest from PythonCore. PythonCore uses a | 
|  | 480 | non-standard initialization entry point, <code>__initialize_with_resources</code>, to | 
|  | 481 | be able to obtain resources from the library file lateron. Plugins can do the same or | 
|  | 482 | use the standard <code>__initialize</code> entry point. | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 483 |  | 
|  | 484 |  | 
| Jack Jansen | 6ad8d13 | 1997-01-15 16:53:37 +0000 | [diff] [blame] | 485 | </UL> | 
| Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 486 | </BODY> | 
|  | 487 | </HTML> |