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 |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 10 | necessary if you want to make modifications to the Python core. Building |
| 11 | Python is not something to be undertaken lightly, you need a reasonable |
| 12 | working knowledge of the CodeWarrior development environment, a good net |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 13 | connection and probably quite some time too. <p> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 14 | |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 15 | Note that if you only want to build new extension modules you don't need to |
| 16 | build Python from source, see the <a href="#extending">note on extending Python</a>.<p> |
| 17 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 18 | The information density in this file is high, so you should probably |
| 19 | print it and read it at your leasure. Most things are explained only |
| 20 | once (and probably in the wrong place:-). <p> |
| 21 | |
Jack Jansen | 90cf491 | 2000-02-11 23:14:46 +0000 | [diff] [blame] | 22 | <blockquote> |
| 23 | First a warning: this information may become outdated if a new CodeWarrior is |
| 24 | released after MacPython. The |
| 25 | <a href="http://www.cwi.nl/~jack/macpython.html">MacPython homepage</a> will |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 26 | hopefully have updated instructions in that case. These instructions are for CW7. |
Jack Jansen | 90cf491 | 2000-02-11 23:14:46 +0000 | [diff] [blame] | 27 | </blockquote> |
| 28 | |
Jack Jansen | c256ece | 1999-02-03 13:09:27 +0000 | [diff] [blame] | 29 | I am very interested in feedback on this document, send your |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 30 | comments to the <A |
| 31 | HREF="http://www.python.org/sigs/pythonmac-sig/">Mac Python Special |
| 32 | Interest Group</A>. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 33 | |
| 34 | <H2>What you need.</H2> |
| 35 | |
| 36 | The following things you definitely need: |
| 37 | |
| 38 | <UL> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 39 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 40 | <LI> You need a MacPython source distribution, of course. You can |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 41 | obtain one via <A HREF="http://www.cwi.nl/~jack/macpython.html"> |
| 42 | http://www.cwi.nl/~jack/macpython.html</A> (which has up-to-date links |
Jack Jansen | 9537586 | 1999-03-10 15:51:56 +0000 | [diff] [blame] | 43 | to the other packages needed too) and possibly also from the standard |
| 44 | <A HREF="ftp://ftp.python.org/pub/python/mac">python.org ftp |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 45 | site</A>. <BR> |
Jack Jansen | c256ece | 1999-02-03 13:09:27 +0000 | [diff] [blame] | 46 | |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 47 | A better alternative is to check the sources straight out of the CVS |
Jack Jansen | 9537586 | 1999-03-10 15:51:56 +0000 | [diff] [blame] | 48 | repository, see below. Most of the packages mentioned here are also |
| 49 | available through CVS. Check the section on <a href="#cvs">CVS |
| 50 | repository use</a> below. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 51 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 52 | <LI> You need MetroWerks CodeWarrior. The current distribution has |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 53 | been built with CodeWarrior Pro 7.1. Ordering information is |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 54 | available on the <A HREF="http://www.metrowerks.com/">MetroWerks |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 55 | homepage</A>. Building Python with MPW, Think/Symantec C or the OSX |
| 56 | developer tools is impossible without major surgery. |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 57 | |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 58 | <LI> You need GUSI version 2, the Grand Unified Socket Interface, by |
| 59 | Matthias Neeracher. The original GUSI is obtainable from <A |
Jack Jansen | 5f884c0 | 2000-12-12 22:14:14 +0000 | [diff] [blame] | 60 | HREF="ftp://gusi.sourceforge.net/pub/gusi/"> |
| 61 | ftp://gusi.sourceforge.net/pub/gusi/</A>. At |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 62 | the moment Python is built with a modified version of GUSI |
| 63 | with Carbon adaptations, so it may be better to check the <A |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 64 | HREF="http://www.cwi.nl/~jack/macpython.html">MacPython homepage</A> |
| 65 | for a GUSI that is most easily used for building Python. |
Jack Jansen | a598bc4 | 1999-02-10 23:08:24 +0000 | [diff] [blame] | 66 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 67 | </UL> |
| 68 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 69 | <A NAME="optional">The MacPython project files are configured to |
| 70 | include a plethora of optional modules</A>, and these modules need a |
Jack Jansen | a2139fe | 1998-02-25 15:40:35 +0000 | [diff] [blame] | 71 | number of extra packages. To use the project files as-is you have to |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 72 | download these packages too. Python has all such modules as |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 73 | dynamically loaded modules, so if you don't need a certain package it |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 74 | suffices to just refrain from builing the extension module. |
| 75 | Here are the locations for the various things |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 76 | you need: |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 77 | |
| 78 | <UL> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 79 | |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 80 | <LI> Tcl and Tk are somewhat less supported on the Mac than on Unix |
| 81 | or Windows. |
Jack Jansen | 8b41d53 | 2000-05-07 22:08:42 +0000 | [diff] [blame] | 82 | See the section on <A HREF="#tcltk">building Tcl/Tk Python</A> |
| 83 | below. |
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> Waste, a TextEdit replacement written by Marco Piovanelli, <A |
| 86 | HREF="mailto:piovanel@kagi.com"><piovanel@kagi.com></A>. Python |
Jack Jansen | c1218bc | 2001-04-25 22:11:24 +0000 | [diff] [blame] | 87 | was built using version 2.0, which is included in the CodeWarrior |
| 88 | package. You can also obtain it from <A |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 89 | HREF="http://www.merzwaren.com/waste"><http://www.merzwaren.com/waste></A> |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 90 | and various other places. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 91 | |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 92 | <LI> Gdbm library for the Mac. Available from Jack's Mac software page at |
| 93 | <A HREF="http://www.cwi.nl/~jack/macsoftware.html"> |
| 94 | http://www.cwi.nl/~jack/macsoftware.html</A> and <A HREF="ftp://ftp.cwi.nl/pub/jack/mac"> |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 95 | ftp://ftp.cwi.nl/pub/jack/mac</A>. |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 96 | |
| 97 | <LI> JPEG library by the Independent JPEG Group. A version including |
| 98 | Mac projects can be found at Jack's page mentioned above. |
| 99 | The most recent JPEG library can always be obtained from <A |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 100 | HREF="ftp://ftp.uu.net/graphics/jpeg/">ftp://ftp.uu.net/graphics/jpeg/</A>. |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 101 | |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 102 | <LI> The netpbm/pbmplus, libtiff, zlib and png libraries. The netpbm distribution |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 103 | (which includes libtiff) is generally available on Internet ftp |
| 104 | servers. For Python pbmplus, an older incarnation of netpbm, is |
| 105 | functionally identical to netpbm, since Python only uses the library |
| 106 | and not the complete applications. A distribution with correct |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 107 | projects and library source only is available from, you guessed it, Jack's Mac software |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 108 | page mentioned above. |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 109 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 110 | </UL> |
| 111 | |
| 112 | <H2>Setting Up</H2> |
| 113 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 114 | Now that you have collected everything you should start with building |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 115 | the various parts. If you don't want to fix |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 116 | access paths try to set things up as follows: |
| 117 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 118 | <PRE> |
| 119 | Top-level-folder: |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 120 | GUSI2 |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 121 | imglibs |
Jack Jansen | de57030 | 1998-08-27 13:39:01 +0000 | [diff] [blame] | 122 | jpeg |
| 123 | netpbm |
| 124 | libtiff |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 125 | zlib |
Jack Jansen | de57030 | 1998-08-27 13:39:01 +0000 | [diff] [blame] | 126 | png |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 127 | gdbm |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 128 | Python |
Jack Jansen | 90cf491 | 2000-02-11 23:14:46 +0000 | [diff] [blame] | 129 | Modules |
| 130 | ... |
| 131 | Mac |
| 132 | Modules |
| 133 | Build |
| 134 | ... |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 135 | Tcl/Tk Folder 8.3.4 |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 136 | </PRE> |
| 137 | |
Jack Jansen | de57030 | 1998-08-27 13:39:01 +0000 | [diff] [blame] | 138 | If your setup of the libraries is exactly the same as mine (which is |
| 139 | not very likely, unless you happen to work from the same CVS |
| 140 | repository) you can use the project <code>buildlibs.prj</code> in the |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 141 | <code>:Mac:Build</code> folder to build all needed libraries in one |
Jack Jansen | de57030 | 1998-08-27 13:39:01 +0000 | [diff] [blame] | 142 | fell swoop, otherwise you will have to build the libraries one by |
| 143 | one. <p> |
| 144 | |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 145 | First build GUSI, both the normal one and the Carbon variant. |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 146 | <p> |
Jack Jansen | 9537586 | 1999-03-10 15:51:56 +0000 | [diff] [blame] | 147 | |
Jack Jansen | 16e99c0 | 1996-09-07 17:11:26 +0000 | [diff] [blame] | 148 | Next, in |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 149 | <code>libjpeg</code>, <code>pbmplus</code>, |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 150 | <code>zlib</code>, <code>libpng</code>, <code>gdbm</code>, |
Jack Jansen | a2139fe | 1998-02-25 15:40:35 +0000 | [diff] [blame] | 151 | 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] | 152 | subfolders, sometimes they are in the main folder. Tcl/tk is a special |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 153 | case, see below. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 154 | |
| 155 | <H2><A NAME="tcltk">Building Tcl/Tk</H2> |
| 156 | |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 157 | Tkinter has been built with Tcl/Tk 8.3.4. Load the Mac source distribution |
| 158 | from the tcl sourceforge site and build it. Build with CW7, but you will |
| 159 | need CW6 to build the MDEF resource (or copy it from a binary |
| 160 | installation). As of this writing the projects are CW6, so they need |
| 161 | massaging to build with CW7, but this is a lot less work than applying |
| 162 | all the workarounds for CW6 that the build instructions give. <P> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 163 | |
Jack Jansen | 8b41d53 | 2000-05-07 22:08:42 +0000 | [diff] [blame] | 164 | Note that if you use a different release of Tcl and Tk than the ones |
Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 165 | I have used you may have to adapt the Python <code>tkresources.rsrc</code> file. |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 166 | This is easiest done by building <code>Tk8.3.shlb</code> and copying the TEXT, ICON |
Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 167 | and CRSR resources from it to <code>tkresources.rsrc</code>. This allows |
| 168 | the <code>_tkinter</code> module to work without an installed Tk/Tcl on your |
Jack Jansen | 8b41d53 | 2000-05-07 22:08:42 +0000 | [diff] [blame] | 169 | machine. <P> |
| 170 | |
| 171 | Also note that the <code>_tkinter.ppc.slb</code> that is normally distributed |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 172 | in the <code>lib-dynload</code> folder is the one from the Imaging extension, |
Jack Jansen | 8b41d53 | 2000-05-07 22:08:42 +0000 | [diff] [blame] | 173 | which has some extra features needed by PIL (and which features should not |
| 174 | hinder normal operation). |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 175 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 176 | </UL> |
| 177 | |
Jack Jansen | f3dd5aa | 1996-12-23 17:29:51 +0000 | [diff] [blame] | 178 | Build first the Tcl library, then |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 179 | SimpleTcl (test it by typing <code>ls -l</code> in the window you get) |
| 180 | then the Tk library, then SimpleTk (which can again be tested with |
| 181 | <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] | 182 | building Python. |
| 183 | |
| 184 | <H2>The organization of the Python source tree</H2> |
| 185 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 186 | Time for a short break, while we have a look at the organization of |
| 187 | the Python source tree. At the top level, we find the following |
| 188 | folders: |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 189 | |
| 190 | <DL> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 191 | <DT> Demo |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 192 | <DD> Demo programs that are not Mac-specific. Some of these may not |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 193 | work. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 194 | |
| 195 | <DT> Extensions |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 196 | <DD> Extensions to the interpreter that are not Mac-specific. Contains |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 197 | the <code>img</code>, <code>Imaging</code> and <code>Numerical</code> extensions |
| 198 | in this distribution. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 199 | |
| 200 | <DT> Grammar |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 201 | <DD> The Python grammar. Included for reference only, you cannot build |
| 202 | the parser on a Mac. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 203 | |
| 204 | <DT> Include |
| 205 | <DD> Machine-independent header files. |
| 206 | |
| 207 | <DT> Modules |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 208 | <DD> Machine-independent optional modules. Not all of these will work |
| 209 | on the Mac. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 210 | |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 211 | <DT> Lib |
| 212 | <DD> Machine-independent modules in Python. |
| 213 | |
| 214 | <DT> Lib:lib-dynload |
| 215 | <DD> This is where the Classic and Carbon dynamically-loaded plugin modules live. |
| 216 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 217 | <DT> Objects |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 218 | <DD> Machine-independent code for various object types. Most of these are |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 219 | not really optional: the interpreter will not function without them. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 220 | |
| 221 | <DT> Parser |
| 222 | <DD> The Python parser (machine-independent). |
| 223 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 224 | <DT> Python |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 225 | <DD> The core interpreter. Most files are machine-independent, some |
| 226 | are unix-specific and not used on the Mac. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 227 | |
| 228 | <DT> Tools |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 229 | <DD> Tools for python developers. Contains <code>modulator</code> which |
| 230 | builds skeleton C extension modules, <code>bgen</code> which generates |
| 231 | complete interface modules from information in C header files and |
| 232 | <code>freeze</code> which is used to turn Python scripts into real |
| 233 | applications (used by MacFreeze and BuildApplication) There are some |
| 234 | readme files, but more documentation is sorely needed. |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 235 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 236 | </DL> |
| 237 | |
| 238 | All the mac-specific stuff lives in the <code>Mac</code> folder: |
| 239 | <DL> |
Jack Jansen | c256ece | 1999-02-03 13:09:27 +0000 | [diff] [blame] | 240 | <DT> Build |
| 241 | <DD> This is where the project files live and where you build the |
| 242 | libraries, shared libraries, executables and plugin modules. All the |
| 243 | resulting binaries, except for intermedeate results, are deposited in |
Jack Jansen | a598bc4 | 1999-02-10 23:08:24 +0000 | [diff] [blame] | 244 | the toplevel folder or the Mac:PlugIns folder (for plugin modules). |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 245 | |
| 246 | <DT> Compat |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 247 | <DD> Unix-compatability routines. Most of these are not used anymore, |
| 248 | since GUSI provides a rather complete emulation, but you may need |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 249 | these if you are trying to build a non-GUSI python. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 250 | |
| 251 | <DT> Demo |
| 252 | <DD> Mac-specific demo programs, some of them annotated. |
| 253 | |
| 254 | <DT> Include |
| 255 | <DD> Mac-specific but compiler-independent include files. |
| 256 | |
| 257 | <DT> Lib |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 258 | <DD> Mac-specific standard modules. The <code>Carbon</code> package |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 259 | contains modules specifically needed with various MacOS toolbox |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 260 | interface modules, both for Carbon and classic PPC, despite the name. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 261 | |
| 262 | <DT> Modules |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 263 | <DD> Mac-specific builtin modules. Theoretically these are all |
| 264 | optional, but some are rather essential (like |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 265 | <code>macosmodule</code>). A lot of these modules are generated with |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 266 | <code>bgen</code>, in which case the bgen input files are included so |
| 267 | you can attempt to regenerate them or extend them. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 268 | |
| 269 | <DT> MPW |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 270 | <DD> MPW-specific files. These have not been used or kept up-to-date |
| 271 | for a long time, so use at your own risk. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 272 | |
| 273 | <DT> mwerks |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 274 | <DD> Mwerks-specific sources and headers. Contains glue code for |
| 275 | Pythons shared-library architecture, a replacement for |
| 276 | <code>malloc</code> and a directory with various projects for building |
| 277 | variations on the Python interpreter. The <code>mwerks_*.h</code> |
| 278 | files here are the option-setting files for the various interpreters |
| 279 | and such, comparable to the unix command-line <code>-D</code> options |
| 280 | to the compiler. Each project uses the correct option file as its |
| 281 | "prefix file" in the "C/C++ language" settings. Disabling optional |
| 282 | modules (for the 68K interpreter), building non-GUSI interpreters and |
| 283 | various other things are accomplished by modifying these files (and |
| 284 | possibly changing the list of files included in the project window, of |
| 285 | course). |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 286 | |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 287 | <DT> OSX |
| 288 | <DD> Specific to unix-Python (also known as MachoPython) on OSX, not used |
| 289 | by MacPython. |
| 290 | |
| 291 | <DT> OSXResources |
| 292 | <DD> Specific to unix-Python (also known as MachoPython) on OSX, not used |
| 293 | by MacPython. |
Jack Jansen | c256ece | 1999-02-03 13:09:27 +0000 | [diff] [blame] | 294 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 295 | <DT> Python |
| 296 | <DD> Mac-specific parts of the core interpreter. |
| 297 | |
| 298 | <DT> Resources |
| 299 | <DD> Resource files needed to build the interpreter. |
| 300 | |
| 301 | <DT> Scripts |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 302 | <DD> A collection of various mac-specific Python scripts. Some are |
| 303 | essential, some are useful but few are documented, so you will have to |
| 304 | use your imagination to work them out. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 305 | |
Jack Jansen | c256ece | 1999-02-03 13:09:27 +0000 | [diff] [blame] | 306 | <DT> Tools |
| 307 | <DD> A collection of tools, usually bigger than those in the scripts |
| 308 | folder. The important ones here are the IDE and macfreeze. The IDE is built |
| 309 | with the buildIDE.py script, which puts the resulting applet in the toplevel |
| 310 | folder. Macfreeze is usually invoked through the BuildApplication script, |
| 311 | but for more control over the freezing process you can run the main script here. |
| 312 | |
| 313 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 314 | <DT> Unsupported |
| 315 | <DD> Modules that are not supported any longer but may still work with a little effort. |
| 316 | </DL> |
| 317 | |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 318 | <H2>Building the PPC interpreter</H2> |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 319 | <em>This is different since 2.1. You are best off using the fullbuild.py |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 320 | script, see <a href="#fullbuild">below</a>. </em><p> |
| 321 | |
Jack Jansen | c256ece | 1999-02-03 13:09:27 +0000 | [diff] [blame] | 322 | First you optionally build the external libraries with buildlibs.prj. Next, |
| 323 | the projects for |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 324 | interpreter and core library are linked together, so |
| 325 | building the PythonInterpreterClassic and/or PythonInterpreterCarbon target |
| 326 | in <code>PythonInterpreter.prj</code> |
| 327 | will result in everything being built. The result, however, is an "Application |
| 328 | template", (filetype Atmp). If you don't use fullbuild you can manually |
| 329 | turn either of these into an interpreter by copying it to PythonInterpreter |
| 330 | and setting the filetype to APPL (with ResEdit or some such). <p> |
| 331 | |
| 332 | Fullbuild does this for you, and the Atmp files is also how ConfigurePythonCarbon |
| 333 | and ConfigurePythonClassic work their magic. <p> |
Jack Jansen | c256ece | 1999-02-03 13:09:27 +0000 | [diff] [blame] | 334 | |
Jack Jansen | c7dd34b | 2002-01-30 10:42:59 +0000 | [diff] [blame^] | 335 | You will get about 100 warnings on "missing prototype" for the various module init |
| 336 | routines, ignore these. You will also get numerous warnings on functions from GUSI which |
| 337 | override functions from MSL, ignore these too. <p> |
| 338 | |
Jack Jansen | c256ece | 1999-02-03 13:09:27 +0000 | [diff] [blame] | 339 | For completeness sake here is a breakdown of the projects: |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 340 | |
| 341 | <DL> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 342 | |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 343 | <DT> PythonCore |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 344 | <DD> The shared library that contains the bulk of the interpreter and |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 345 | its resources. It has targets for PythonCore and PythonCoreCarbon. |
| 346 | It is a good idea to immedeately put an alias to this |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 347 | shared library in the <code>Extensions</code> folder of your system |
| 348 | folder. Do exactly that: put an <em>alias</em> there, copying or |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 349 | moving the file will cause you grief later if you rebuild the library and |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 350 | forget to copy it to the extensions folder again. The ConfigurePythonXXX applets |
| 351 | will also do this. <br> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 352 | |
Jack Jansen | 3b80526 | 1999-02-14 23:12:06 +0000 | [diff] [blame] | 353 | <DT> PythonInterpeter |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 354 | <DD> The interpreter. This is basically a routine to call out to the |
Jack Jansen | 3b80526 | 1999-02-14 23:12:06 +0000 | [diff] [blame] | 355 | shared library. Unlike in previous releases the same program is used for |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 356 | creating applets (for which formerly PythonApplet was used). There are 4 targets |
| 357 | in here: two for the classic and carbon templates (which are normally used, and |
| 358 | converted to PythonInterpreter by the ConfigurePython* applets) and two |
| 359 | for PythonInterpreter in it's classic and carbon version.<p> |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 360 | |
Jack Jansen | c256ece | 1999-02-03 13:09:27 +0000 | [diff] [blame] | 361 | <DT> Plugin projects |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 362 | <DD> Each plugin module has a separate project, and these can be rebuilt on |
| 363 | the fly. Fullbuild (or actually it's little helper genpluginprojects) takes |
| 364 | care of this. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 365 | </DL> |
| 366 | |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 367 | After creating the alias to <code>PythonCore</code> you remove any old |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 368 | <code>Python XXXX Preferences</code> file from the <code>Preferences</code> folder |
Jack Jansen | 061ac50 | 1996-10-22 15:27:56 +0000 | [diff] [blame] | 369 | (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] | 370 | to create the correct preferences file. <p> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 371 | |
Jack Jansen | c256ece | 1999-02-03 13:09:27 +0000 | [diff] [blame] | 372 | Next, you have to build the extension modules. |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 373 | If you don't use fullbuild simply open each project and build it. |
Jack Jansen | a598bc4 | 1999-02-10 23:08:24 +0000 | [diff] [blame] | 374 | <p> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 375 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 376 | Finally, you must build the standard applets: |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 377 | <code>EditPythonPrefs</code>, <code>BuildApplet</code>, etc. For the N-th time: |
| 378 | fullbuild does this for you, but you can also manually drag/drop them onto |
| 379 | BuildApplet. <p> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 380 | |
| 381 | <BLOCKQUOTE> |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 382 | <a name="fullbuild"></a> |
| 383 | The <code>fullbuild</code> script can be used to build |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 384 | everything, but you need a fully-functional interpreter before you can |
| 385 | use it (and one that isn't rebuilt in the process: you cannot rebuild |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 386 | a running program). You could copy the interpreter to a different |
| 387 | place and use that to run fullbuild. The <code>PythonStandSmall.prj</code> |
| 388 | project builds an interpreter that is suited to this, and it can also come |
| 389 | in handy if you need to debug things (which is easier in a static program). <p> |
Jack Jansen | e66b8c8 | 1997-05-29 14:57:07 +0000 | [diff] [blame] | 390 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 391 | </BLOCKQUOTE> |
| 392 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 393 | You are all set now, and should read the release notes and |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 394 | <code>ReadMe</code> file from the <code>Mac</code> folder. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 395 | |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 396 | Rebuilding .exp files is no longer needed since CodeWarrior 7. |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 397 | |
Jack Jansen | 9537586 | 1999-03-10 15:51:56 +0000 | [diff] [blame] | 398 | <H2><a name="cvs">Using the CVS source archive</a></H2> |
Jack Jansen | c256ece | 1999-02-03 13:09:27 +0000 | [diff] [blame] | 399 | |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 400 | It is possible (and probably best) to access the Python sources through remote CVS. The |
Jack Jansen | 65f685b | 1999-04-12 09:25:23 +0000 | [diff] [blame] | 401 | advantage of this is that you get the very latest sources, so any bug |
| 402 | fixed or new features will be immedeately available. This is also the |
| 403 | disadvantage, of course: as this is the same tree as is used for |
| 404 | development it may sometimes be a little less stable. <p> |
Jack Jansen | c256ece | 1999-02-03 13:09:27 +0000 | [diff] [blame] | 405 | |
| 406 | The CVS client of choice is Alexandre Parenteau's MacCVS. It can be |
Jack Jansen | 65f685b | 1999-04-12 09:25:23 +0000 | [diff] [blame] | 407 | obtained through the <a href="http://www.wincvs.org">WinCVS |
| 408 | homepage</a>. MacCVS uses Internet Config to set file types correctly |
| 409 | based on the filename extension. In the maccvs preferences you should |
| 410 | also set (in the "binary files" section) "use mac encoding: |
| 411 | applesingle" and (in the "text files" section) "use ISO latin 1 |
Jack Jansen | c256ece | 1999-02-03 13:09:27 +0000 | [diff] [blame] | 412 | conversion". <p> |
| 413 | |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 414 | <blockquote> |
| 415 | There is one group of people for whom MacCVS is not the best choice: people with |
| 416 | checkin rights to the Python repository. You will have to use MacCVS Pro |
| 417 | (completely unrelated) from www.maccvs.org, because it has working SSH support. |
| 418 | </blockquote> |
| 419 | |
| 420 | It is a good idea to disable Quicktime Exchange in the Quicktime |
Jack Jansen | 8b41d53 | 2000-05-07 22:08:42 +0000 | [diff] [blame] | 421 | control panel. Quicktime Exchange will magically map some extensions to |
| 422 | filetypes, and this can seriously hinder you if, for instance, <code>.bmp</code> |
| 423 | is not a Windows bitmap file. <p> |
| 424 | |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 425 | The Python sources are checked out from the main |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 426 | Python CVS archive on sourceforge.net, see the <a |
Jack Jansen | 65f685b | 1999-04-12 09:25:23 +0000 | [diff] [blame] | 427 | href="http://www.python.org/download/cvs.html">Source access via |
| 428 | CVS</a> page for details. When you check the sources out you will get |
Jack Jansen | 9537586 | 1999-03-10 15:51:56 +0000 | [diff] [blame] | 429 | something like <code>Python:dist:src</code>, and under that the |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 430 | <code>Modules</code>, <code>Lib</code>, <code>Mac</code> etc hierarchy. The |
| 431 | <code>src</code> folder can be renamed to <code>Python</code>, and |
Jack Jansen | 9537586 | 1999-03-10 15:51:56 +0000 | [diff] [blame] | 432 | is what this document refers to as the "toplevel Python folder". <P> |
Jack Jansen | c256ece | 1999-02-03 13:09:27 +0000 | [diff] [blame] | 433 | |
Jack Jansen | 1690409 | 2001-08-16 14:10:56 +0000 | [diff] [blame] | 434 | The CVS repository does not contain all the projects for the plugin modules, |
| 435 | these are built with <code>fullbuild.py</code> normally. For this reason |
| 436 | it is probably a good idea to first build <code>PythonStandSmall.prj</code>, |
| 437 | which builds a fairly minimal interpreter, and then follow the |
| 438 | <a href="#fullbuild">fullbuild instructions</a>. |
Jack Jansen | dae108c | 2000-02-11 23:17:14 +0000 | [diff] [blame] | 439 | |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 440 | <H2>Odds and ends</H2> |
| 441 | |
| 442 | Some remarks that I could not fit in elsewhere: |
| 443 | |
| 444 | <UL> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 445 | |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 446 | <LI> It may be possible to use the <code>PythonCore</code> shared |
| 447 | library to embed Python in another program, if your program can live |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 448 | with using GUSI for I/O. Use PythonCore in stead of your MSL C library |
Jack Jansen | 8a6cdcc | 2000-09-10 12:02:28 +0000 | [diff] [blame] | 449 | (or, at the very least, link it before the normal C library). |
Jack Jansen | 4c1e56c | 1996-08-06 16:16:20 +0000 | [diff] [blame] | 450 | |
Jack Jansen | e0b1e6a | 2002-01-08 23:03:45 +0000 | [diff] [blame] | 451 | <LI> <a name="extending"></a>It is possible to build PPC extension |
| 452 | modules without building a complete Python. The binary distribution |
| 453 | installer can optionally install all the needed folders (the develop |
| 454 | option). A template for a dynamic module can be found in |
Jack Jansen | 3412c5d | 1997-08-27 14:08:22 +0000 | [diff] [blame] | 455 | <code>xx.prj</code>. |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 456 | |
| 457 | <LI> The Python shared library architecture is a variant of the architecture |
| 458 | described as "application with shared libraries and dropins" in the MetroWerks |
| 459 | "Targeting MacOS" documentation. The Python Application and applet-template use |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 460 | the <code>MSL AppRuntime.Lib</code> runtime library (with properly set CFM |
| 461 | initialization and termination routines). PythonCore uses <code>MSL Runtime.Lib</code>, |
| 462 | which is really intended for standalone programs but which we fool into working by |
| 463 | providing a dummy main program. |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 464 | It is linked statically into PythonCore (and exported to the applications and plugins) |
| 465 | 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] | 466 | <code>MSL ShlibRuntime.Lib</code> (not the dropin runtime: modules are never unloaded) |
| 467 | and obtain the rest from PythonCore. PythonCore uses a |
Jack Jansen | 27b10ec | 1996-08-23 15:44:18 +0000 | [diff] [blame] | 468 | non-standard initialization entry point, <code>__initialize_with_resources</code>, to |
Jack Jansen | 1473af7 | 1997-05-07 15:43:38 +0000 | [diff] [blame] | 469 | be able to obtain resources from the library file later on. Plugins can do the same |
| 470 | (_tkinter does) or use the standard <code>__initialize</code> entry point. |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 471 | |
| 472 | |
Jack Jansen | 6ad8d13 | 1997-01-15 16:53:37 +0000 | [diff] [blame] | 473 | </UL> |
Jack Jansen | 8f2d802 | 1996-08-05 15:34:45 +0000 | [diff] [blame] | 474 | </BODY> |
| 475 | </HTML> |