blob: cf18d2b09a688ca4361217c6f3bb223ad55cb006 [file] [log] [blame]
Ronald Oussoren73612362006-05-26 12:23:20 +00001============
2MacOSX Notes
3============
Jack Jansen0fdaee72002-08-02 21:45:27 +00004
Ronald Oussoren73612362006-05-26 12:23:20 +00005This document provides a quick overview of some Mac OS X specific features in
6the Python distribution.
7
Ronald Oussoren9ebd2422009-09-29 13:00:44 +00008Mac-specific arguments to configure
9===================================
10
11* ``--enable-framework``
12
13 If this argument is specified the build will create a Python.framework rather
14 than a traditional Unix install. See the section
15 _`Building and using a framework-based Python on Mac OS X` for more
16 information on frameworks.
17
18* ``--with-framework-name=NAME``
19
20 Specify the name for the python framework, defaults to ``Python``. This option
21 is only valid when ``--enable-framework`` is specified.
22
23* ``--enable-universalsdk[=PATH]``
24
25 Create a universal binary build of of Python. This can be used with both
26 regular and framework builds.
27
Ronald Oussoren92919a62009-12-24 13:30:58 +000028 The optional argument specifies which OSX SDK should be used to perform the
Ronald Oussoren9ebd2422009-09-29 13:00:44 +000029 build. This defaults to ``/Developer/SDKs/MacOSX.10.4u.sdk``, specify
30 ``/`` when building on a 10.5 system, especially when building 64-bit code.
31
32 See the section _`Building and using a universal binary of Python on Mac OS X`
33 for more information.
34
35* ``--with-univeral-archs=VALUE``
36
37 Specify the kind of universal binary that should be created. This option is
38 only valid when ``--enable-universalsdk`` is specified.
39
40
Ronald Oussoren73612362006-05-26 12:23:20 +000041
42Building and using a universal binary of Python on Mac OS X
43===========================================================
44
451. What is a universal binary
46-----------------------------
47
48A universal binary build of Python contains object code for both PPC and i386
49and can therefore run at native speed on both classic powerpc based macs and
50the newer intel based macs.
51
522. How do I build a universal binary
53------------------------------------
54
55You can enable universal binaries by specifying the "--enable-universalsdk"
56flag to configure::
57
58 $ ./configure --enable-universalsdk
59 $ make
60 $ make install
61
62This flag can be used a framework build of python, but also with a classic
63unix build. Either way you will have to build python on Mac OS X 10.4 (or later)
64with Xcode 2.1 (or later). You also have to install the 10.4u SDK when
65installing Xcode.
66
Ronald Oussoren9ebd2422009-09-29 13:00:44 +000067The option ``--enable-universalsdk`` has an optional argument to specify an
68SDK, which defaults to the 10.4u SDK. When you build on OSX 10.5 or later
69you can use the system headers instead of an SDK::
70
71 $ ./configure --enable-universalsdk=/
72
732.1 Flavours of universal binaries
74..................................
75
76It is possible to build a number of flavours of the universal binary build,
77the default is a 32-bit only binary (i386 and ppc). The flavour can be
78specified using the option ``--with-universal-archs=VALUE``. The following
79values are available:
80
81 * ``32-bit``: ``ppc``, ``i386``
82
83 * ``64-bit``: ``ppc64``, ``x86_64``
84
85 * ``all``: ``ppc``, ``ppc64``, ``i386``, ``x86_64``
86
87 * ``3-way``: ``ppc``, ``i386`` and ``x86_64``
88
89 * ``intel``: ``i386``, ``x86_64``
90
Ronald Oussoren92919a62009-12-24 13:30:58 +000091To build a universal binary that includes a 64-bit architecture, you must build
92on a system running OSX 10.5 or later. The ``all`` flavour can only be built on
Ronald Oussoren9ebd2422009-09-29 13:00:44 +000093OSX 10.5.
94
Ronald Oussoren92919a62009-12-24 13:30:58 +000095The makefile for a framework build will install ``python32`` and ``pythonw32``
96binaries when the universal architecures includes at least one 32-bit architecture
97(that is, for all flavours but ``64-bit``).
98
99Running a specific archicture
100.............................
101
102You can run code using a specific architecture using the ``arch`` command::
103
104 $ arch -i386 python
105
106Or to explicitly run in 32-bit mode, regardless of the machine hardware::
107
108 $ arch -i386 -ppc python
109
110NOTE: When you're using a framework install of Python this requires at least
111Python 2.7 or 3.2, in earlier versions the python (and pythonw) commands are
112wrapper tools that execute the real interpreter without ensuring that the
113real interpreter runs with the same architecture.
Ronald Oussoren73612362006-05-26 12:23:20 +0000114
115Building and using a framework-based Python on Mac OS X.
116========================================================
117
Jack Jansen0fdaee72002-08-02 21:45:27 +0000118
Brett Cannon98809b72004-12-06 06:01:13 +00001191. Why would I want a framework Python instead of a normal static Python?
Jack Jansen0fdaee72002-08-02 21:45:27 +0000120--------------------------------------------------------------------------
121
Jack Jansen1f74ed82002-09-06 21:00:55 +0000122The main reason is because you want to create GUI programs in Python. With the
Ronald Oussoren73612362006-05-26 12:23:20 +0000123exception of X11/XDarwin-based GUI toolkits all GUI programs need to be run
124from a fullblown MacOSX application (a ".app" bundle).
Jack Jansen0fdaee72002-08-02 21:45:27 +0000125
Jack Jansen1f74ed82002-09-06 21:00:55 +0000126While it is technically possible to create a .app without using frameworks you
127will have to do the work yourself if you really want this.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000128
Jack Jansen1f74ed82002-09-06 21:00:55 +0000129A second reason for using frameworks is that they put Python-related items in
Ronald Oussoren73612362006-05-26 12:23:20 +0000130only two places: "/Library/Framework/Python.framework" and
Ronald Oussoren63083c32006-09-07 12:03:10 +0000131"/Applications/MacPython 2.6". This simplifies matters for users installing
Ronald Oussoren73612362006-05-26 12:23:20 +0000132Python from a binary distribution if they want to get rid of it again. Moreover,
133due to the way frameworks work a user without admin privileges can install a
134binary distribution in his or her home directory without recompilation.
Jack Jansen7c0d7ba2003-06-20 15:14:08 +0000135
Jack Jansen0fdaee72002-08-02 21:45:27 +00001362. How does a framework Python differ from a normal static Python?
137------------------------------------------------------------------
138
139In everyday use there is no difference, except that things are stored in
140a different place. If you look in /Library/Frameworks/Python.framework
141you will see lots of relative symlinks, see the Apple documentation for
142details. If you are used to a normal unix Python file layout go down to
143Versions/Current and you will see the familiar bin and lib directories.
144
1453. Do I need extra packages?
146----------------------------
147
Ronald Oussoren73612362006-05-26 12:23:20 +0000148Yes, probably. If you want Tkinter support you need to get the OSX AquaTk
149distribution, this is installed by default on Mac OS X 10.4 or later. If
Jack Jansen1f74ed82002-09-06 21:00:55 +0000150you want wxPython you need to get that. If you want Cocoa you need to get
Ronald Oussoren73612362006-05-26 12:23:20 +0000151PyObjC.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000152
1534. How do I build a framework Python?
154-------------------------------------
155
Jack Jansen21ed16a2002-08-02 14:11:24 +0000156This directory contains a Makefile that will create a couple of python-related
Jack Jansen1f74ed82002-09-06 21:00:55 +0000157applications (fullblown OSX .app applications, that is) in
Ronald Oussoren63083c32006-09-07 12:03:10 +0000158"/Applications/MacPython 2.6", and a hidden helper application Python.app
Ronald Oussoren73612362006-05-26 12:23:20 +0000159inside the Python.framework, and unix tools "python" and "pythonw" into
160/usr/local/bin. In addition it has a target "installmacsubtree" that installs
161the relevant portions of the Mac subtree into the Python.framework.
Jack Jansen0511b762001-09-06 16:36:42 +0000162
Jack Jansen21ed16a2002-08-02 14:11:24 +0000163It is normally invoked indirectly through the main Makefile, as the last step
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000164in the sequence::
Ronald Oussoren73612362006-05-26 12:23:20 +0000165
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000166 $ ./configure --enable-framework
167 $ make
168 $ make install
Jack Jansen0fdaee72002-08-02 21:45:27 +0000169
Jack Jansen1f74ed82002-09-06 21:00:55 +0000170This sequence will put the framework in /Library/Framework/Python.framework,
Ronald Oussoren63083c32006-09-07 12:03:10 +0000171the applications in "/Applications/MacPython 2.6" and the unix tools in
Ronald Oussoren73612362006-05-26 12:23:20 +0000172/usr/local/bin.
Jack Jansen7a1703d2002-08-12 20:46:18 +0000173
Ronald Oussoren9ebd2422009-09-29 13:00:44 +0000174It is possible to select a different name for the framework using the configure
175option ``--with-framework-name=NAME``. This makes it possible to have several
176parallel installs of a Python framework.
177
Jack Jansen7c0d7ba2003-06-20 15:14:08 +0000178Installing in another place, for instance $HOME/Library/Frameworks if you have
Jack Jansen1f74ed82002-09-06 21:00:55 +0000179no admin privileges on your machine, has only been tested very lightly. This
180can be done by configuring with --enable-framework=$HOME/Library/Frameworks.
Ronald Oussoren63083c32006-09-07 12:03:10 +0000181The other two directories, "/Applications/MacPython-2.6" and /usr/local/bin,
182will then also be deposited in $HOME. This is sub-optimal for the unix tools,
183which you would want in $HOME/bin, but there is no easy way to fix this right
184now.
Jack Jansen7a1703d2002-08-12 20:46:18 +0000185
Ronald Oussoren73612362006-05-26 12:23:20 +0000186What do all these programs do?
187===============================
Jack Jansen7a1703d2002-08-12 20:46:18 +0000188
Ronald Oussoren73612362006-05-26 12:23:20 +0000189"IDLE.app" is an integrated development environment for Python: editor,
Jack Jansen0fdaee72002-08-02 21:45:27 +0000190debugger, etc.
191
Ronald Oussoren73612362006-05-26 12:23:20 +0000192"PythonLauncher.app" is a helper application that will handle things when you
Jack Jansen0fdaee72002-08-02 21:45:27 +0000193double-click a .py, .pyc or .pyw file. For the first two it creates a Terminal
Jack Jansen1f74ed82002-09-06 21:00:55 +0000194window and runs the scripts with the normal command-line Python. For the
195latter it runs the script in the Python.app interpreter so the script can do
196GUI-things. Keep the "alt" key depressed while dragging or double-clicking a
197script to set runtime options. These options can be set once and for all
198through PythonLauncher's preferences dialog.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000199
Ronald Oussoren73612362006-05-26 12:23:20 +0000200"BuildApplet.app" creates an applet from a Python script. Drop the script on it
Jack Jansen1f74ed82002-09-06 21:00:55 +0000201and out comes a full-featured MacOS application. There is much more to this,
202to be supplied later. Some useful (but outdated) info can be found in
203Mac/Demo.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000204
Jack Jansen1f74ed82002-09-06 21:00:55 +0000205The commandline scripts /usr/local/bin/python and pythonw can be used to run
206non-GUI and GUI python scripts from the command line, respectively.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000207
Ronald Oussoren73612362006-05-26 12:23:20 +0000208How do I create a binary distribution?
209======================================
Jack Jansen8ba42202002-09-06 20:24:51 +0000210
Ronald Oussoren73612362006-05-26 12:23:20 +0000211Go to the directory "Mac/OSX/BuildScript". There you'll find a script
212"build-installer.py" that does all the work. This will download and build
213a number of 3th-party libaries, configures and builds a framework Python,
214installs it, creates the installer pacakge files and then packs this in a
215DMG image.
Jack Jansen4f901372004-07-15 21:30:41 +0000216
Ronald Oussoren73612362006-05-26 12:23:20 +0000217The script will build a universal binary, you'll therefore have to run this
218script on Mac OS X 10.4 or later and with Xcode 2.1 or later installed.
Jack Jansen8ba42202002-09-06 20:24:51 +0000219
Jack Jansen7c0d7ba2003-06-20 15:14:08 +0000220All of this is normally done completely isolated in /tmp/_py, so it does not
221use your normal build directory nor does it install into /.
Jack Jansen8ba42202002-09-06 20:24:51 +0000222
Ronald Oussoren73612362006-05-26 12:23:20 +0000223Because of the way the script locates the files it needs you have to run it
224from within the BuildScript directory. The script accepts a number of
225command-line arguments, run it with --help for more information.
Jack Jansen8ba42202002-09-06 20:24:51 +0000226
Ronald Oussoren724c5b22010-01-17 12:38:11 +0000227Configure warnings
228==================
229
230The configure script sometimes emits warnings like the one below::
231
232 configure: WARNING: libintl.h: present but cannot be compiled
233 configure: WARNING: libintl.h: check for missing prerequisite headers?
234 configure: WARNING: libintl.h: see the Autoconf documentation
235 configure: WARNING: libintl.h: section "Present But Cannot Be Compiled"
236 configure: WARNING: libintl.h: proceeding with the preprocessor's result
237 configure: WARNING: libintl.h: in the future, the compiler will take precedence
238 configure: WARNING: ## -------------------------------------- ##
239 configure: WARNING: ## Report this to http://bugs.python.org/ ##
240 configure: WARNING: ## -------------------------------------- ##
241
242This almost always means you are trying to build a universal binary for
243Python and have libaries in ``/usr/local`` that don't contain the required
244architectures. Temporarily move ``/usr/local`` aside to finish the build.
245
Ronald Oussoren73612362006-05-26 12:23:20 +0000246Odds and ends
247=============
Jack Jansen408c16f2001-09-11 11:30:02 +0000248
Jack Jansen1f74ed82002-09-06 21:00:55 +0000249Something to take note of is that the ".rsrc" files in the distribution are
250not actually resource files, they're AppleSingle encoded resource files. The
251macresource module and the Mac/OSX/Makefile cater for this, and create
252".rsrc.df.rsrc" files on the fly that are normal datafork-based resource
253files.
Jack Jansen0511b762001-09-06 16:36:42 +0000254
Brett Cannon98809b72004-12-06 06:01:13 +0000255 Jack Jansen, Jack.Jansen@cwi.nl, 15-Jul-2004.
Ronald Oussoren73612362006-05-26 12:23:20 +0000256 Ronald Oussoren, RonaldOussoren@mac.com, 26-May-2006