blob: 578ac2bc5390bf3fbe19f35c8b329e4ee9177498 [file] [log] [blame]
Guido van Rossumd849a481994-08-20 21:55:48 +00001BUILDING PYTHON 1.1 FOR THE MACINTOSH
2*************************************
3
4Python can be built on the Mac using either THINK C 6.0 or MPW 3.2.
5In the past it has been compiled with earlier versions of these
6compilers, but no guarantees are made that the source is still
7compatible with those versions. Likewise, new compiler versions may
8effectively change the language accepted (or the library!) and thus
9cause problems.
10
11[[MPW version and procedure must still be checked]]
12
13
141. Using Think C 6.0
15====================
16
171.1 The directory structure
18---------------------------
19
20I duplicate the UNIX directory structure from the distribution. The
21subdirectories needed to compile are: Mac, Include, Parser, Python,
22Objects, Modules. (Don't bother with Grammar and the parser
23generator, nor with the Doc subdirectory.)
24
25For running and testing, you also need Lib and its subdirectories test
26and stdwin. You could also copy some things from the Demo/stdwin
27directory (unfortunately most other demos are UNIX specific and even
28many stdwin demos are).
29
30Make sure there is no config.c file in the Modules subdirectory (if
31you copy from a directory where you have done a UNIX build this might
32occur). Also don't use the config.h generated on UNIX.
33
341.2 The project file
35--------------------
36
37I put all source files in one project, which I place in the parent
38directory of the source directories.
39
401.2.1 Project type
41
42(This is the Set Project Type... dialog in the Project menu.)
43
44Set the creator to PYTH; turn on "far data"; leave "far code" and
45"separate strs" unchecked (they just serve to bloat the application).
46A partition size of 1000K should be enough to run the standard test
47suite (which requires a lot of memory because it stress tests the
48parser quite a bit) and most demos or medium-size applications. The
49interpreter will do basic things in as little at 500K but this may
50prevent parsing larger modules.
51
521.2.2 Compiler options
53
54(This is the Options -> THINK C ... dialog in the Edit menu.)
55
56 - Start with Factory Settings.
57
58 - In the Prefix, remove #include <MacHeaders> and add
59 #define HAVE_CONFIG_H
60
61 - Choose any optimizer and debugger settings you like. - You
62 can choose 4-byte ints if you want. This requires that you
63 rebuild the ANSI and unix libraries with 4-bytes ints as well
64 (better make copies with names like ANSI 32 bit). With 4-byte
65 ints the interpreter is marginally bigger and somewhat (~10%)
66 slower, but Python programs can use strings and lists with
67 more than 32000 items (with 2-byte ints these can cause
68 crashes). The range of Python integers is not affected (these
69 are always represented as longs).
70
711.2.3 Files to add
72
73(This is the Add Files... dialog in the Source menu.)
74
75The following source files must be added to the project. I use a
76separate segment for each begin letter -- this avoids segment
77overflow, except for 'c', where you have to put either ceval.c or
78compile.c in a separate segment. You could also group them by
79subdirectory or function, but you may still have to split segments
80arbitrarily because of the 32000 bytes restriction.
81
82 - From Mac: all .c files except fopenRF.c [[which shouldn't even
83 be there]].
84
Guido van Rossum29e7af01994-08-23 13:28:34 +000085 - From Parser: acceler.c, grammar1.c, intrcheck.c, myreadline.c, node.c,
Guido van Rossumd849a481994-08-20 21:55:48 +000086 parser.c, parsetok.c, tokenizer.c.
87
88 - From Python: bltinmodule.c, ceval.c, cgensupport.c,
89 compile.c, errors.c, getopt.c, graminit.c, import.c,
90 marshal.c, modsupport.c, mystrtoul.c, pythonmain.c,
Guido van Rossum29e7af01994-08-23 13:28:34 +000091 pythonrun.c, sigcheck.c, structmember.c, sysmodule.c, traceback.c
Guido van Rossumd849a481994-08-20 21:55:48 +000092 (i.e. all .c files except dup2.c, fmod.c, frozenmain.c,
93 getcwd.c, getmtime.c, memmove.c, sigcheck.c, strerror.c,
94 strtod.c, thread.c)
95
96 - From Objects: all .c files except xxobject.c.
97
98 - From Modules: all the modules listed in config.c (in the Mac
99 subdirectory) in the initializer for inittab[], before
100 "ADDMODULE MARKER 2". Also add md5c.c if you add md5module.c,
101 and regexpr.c if you add regexmodule.c. (You'll find
102 macmodule.c in the Mac subdirectory, so it should already have
103 been added in a previous step.) Note that for most modules,
104 the source file is called <name>module.c, but for a few long
Guido van Rossum29e7af01994-08-23 13:28:34 +0000105 module names it is just <module>.c.
Guido van Rossumd849a481994-08-20 21:55:48 +0000106
107The following THINK C libraries must be added: from Standard
108Libraries, ANSI and unix; from Mac Libraries, MacTraps. I put each
109library in a separate segment. Also see my earlier remark on 4-byte
110ints.
111
1121.3 Living without STDWIN
113-------------------------
114
115Although STDWIN is really neat on the Mac, it's easier to begin
116building Python without it, so you can concentrate on the Python
117build. To this end, you have to comment out the lines defining the
118symbol USE_STDWIN in macmain.c and config.c.
119
1201.4 Adding STDWIN
121-----------------
122
123STDWIN is built in two separate projects: stdwin.pi contains the core
124STDWIN implementation from Ports/mac, textedit.pi contains the files
125from Packs/textedit. Use the same compiler options as for Python and
126the same general source setup (in a sister directory of the toplevel
127Python directory). Put all sources in the same segment. To
128stdwin.pi, also add Tools/strdup.c and Gen/wtextbreak.c.
129
130The two projects can now be added as libraries to the Python project,
131and the two lines commented out to live without STDWIN should be
132reinstated.
133
134Note that stdwinmodule.c contains an #include statement that
135references "stdwin.h" by relative path name -- if the stdwin toplevel
136directory is not a sibling of the python toplevel directory, you may
137have to adjust the number of colons in the pathname.
138
1391.5 Resources
140-------------
141
142Since I created them with ResEdit I have no text source of the
143resources needed to give the application an icon etc... You can copy
144the size, bundle, file reference and icon resources from the
145distributed Python application with ResEdit. THINK C automatically
146copies resources into the application file from a file
147<projectname>.rsrc.
148
149
1502. Using MPW
151============
152
153See the subdirectory MPW. I haven't tried this recently. You're
154supposed to merge the directory tree found here with the UNIX source
155tree. I think this is intended for use with MPW 3.2. The dynload
156stuff in not recommended.
157
158
159--Guido van Rossum, CWI, Amsterdam <Guido.van.Rossum@cwi.nl>
160<URL:http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>