blob: afd217315dd82e4abb8f341649eca67712ca1c7e [file] [log] [blame]
Thomas Wouters477c8d52006-05-27 19:21:47 +00001============
2MacOSX Notes
3============
Jack Jansen0fdaee72002-08-02 21:45:27 +00004
Thomas Wouters477c8d52006-05-27 19:21:47 +00005This document provides a quick overview of some Mac OS X specific features in
6the Python distribution.
7
Ronald Oussoren6f6c5622009-12-24 14:03:19 +00008* ``--enable-framework``
9
10 If this argument is specified the build will create a Python.framework rather
11 than a traditional Unix install. See the section
12 _`Building and using a framework-based Python on Mac OS X` for more
13 information on frameworks.
14
15* ``--with-framework-name=NAME``
16
17 Specify the name for the python framework, defaults to ``Python``. This option
18 is only valid when ``--enable-framework`` is specified.
19
20* ``--enable-universalsdk[=PATH]``
21
22 Create a universal binary build of of Python. This can be used with both
23 regular and framework builds.
24
25 The optional argument specifies which OSX SDK should be used to perform the
26 build. This defaults to ``/Developer/SDKs/MacOSX.10.4u.sdk``, specify
27 ``/`` when building on a 10.5 system, especially when building 64-bit code.
28
29 See the section _`Building and using a universal binary of Python on Mac OS X`
30 for more information.
31
32* ``--with-univeral-archs=VALUE``
33
34 Specify the kind of universal binary that should be created. This option is
35 only valid when ``--enable-universalsdk`` is specified.
36
Thomas Wouters477c8d52006-05-27 19:21:47 +000037
38Building and using a universal binary of Python on Mac OS X
39===========================================================
40
411. What is a universal binary
42-----------------------------
43
44A universal binary build of Python contains object code for both PPC and i386
45and can therefore run at native speed on both classic powerpc based macs and
46the newer intel based macs.
47
482. How do I build a universal binary
49------------------------------------
50
51You can enable universal binaries by specifying the "--enable-universalsdk"
52flag to configure::
53
54 $ ./configure --enable-universalsdk
55 $ make
56 $ make install
57
58This flag can be used a framework build of python, but also with a classic
59unix build. Either way you will have to build python on Mac OS X 10.4 (or later)
60with Xcode 2.1 (or later). You also have to install the 10.4u SDK when
61installing Xcode.
62
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000632.1 Flavours of universal binaries
64..................................
65
66It is possible to build a number of flavours of the universal binary build,
67the default is a 32-bit only binary (i386 and ppc). The flavour can be
68specified using the option ``--with-universal-archs=VALUE``. The following
69values are available:
70
71 * ``32-bit``: ``ppc``, ``i386``
72
73 * ``64-bit``: ``ppc64``, ``x86_64``
74
75 * ``all``: ``ppc``, ``ppc64``, ``i386``, ``x86_64``
76
77 * ``3-way``: ``ppc``, ``i386`` and ``x86_64``
78
79 * ``intel``: ``i386``, ``x86_64``
80
81To build a universal binary that includes a 64-bit architecture, you must build
82on a system running OSX 10.5 or later. The ``all`` flavour can only be built on
83OSX 10.5.
84
85The makefile for a framework build will install ``python32`` and ``pythonw32``
86binaries when the universal architecures includes at least one 32-bit architecture
87(that is, for all flavours but ``64-bit``).
88
89Running a specific archicture
90.............................
91
92You can run code using a specific architecture using the ``arch`` command::
93
94 $ arch -i386 python
95
96Or to explicitly run in 32-bit mode, regardless of the machine hardware::
97
98 $ arch -i386 -ppc python
99
100NOTE: When you're using a framework install of Python this requires at least
101Python 2.7 or 3.2, in earlier versions the python (and pythonw) commands are
102wrapper tools that execute the real interpreter without ensuring that the
103real interpreter runs with the same architecture.
Thomas Wouters477c8d52006-05-27 19:21:47 +0000104
105Building and using a framework-based Python on Mac OS X.
106========================================================
107
Jack Jansen0fdaee72002-08-02 21:45:27 +0000108
Brett Cannon98809b72004-12-06 06:01:13 +00001091. Why would I want a framework Python instead of a normal static Python?
Jack Jansen0fdaee72002-08-02 21:45:27 +0000110--------------------------------------------------------------------------
111
Jack Jansen1f74ed82002-09-06 21:00:55 +0000112The main reason is because you want to create GUI programs in Python. With the
Thomas Wouters477c8d52006-05-27 19:21:47 +0000113exception of X11/XDarwin-based GUI toolkits all GUI programs need to be run
114from a fullblown MacOSX application (a ".app" bundle).
Jack Jansen0fdaee72002-08-02 21:45:27 +0000115
Jack Jansen1f74ed82002-09-06 21:00:55 +0000116While it is technically possible to create a .app without using frameworks you
117will have to do the work yourself if you really want this.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000118
Jack Jansen1f74ed82002-09-06 21:00:55 +0000119A second reason for using frameworks is that they put Python-related items in
Thomas Wouters477c8d52006-05-27 19:21:47 +0000120only two places: "/Library/Framework/Python.framework" and
Brett Cannon85266da2009-12-13 21:15:41 +0000121"/Applications/MacPython <VERSION>" where ``<VERSION>`` can be e.g. "2.6",
122"3.1", etc.. This simplifies matters for users installing
Thomas Wouters477c8d52006-05-27 19:21:47 +0000123Python from a binary distribution if they want to get rid of it again. Moreover,
124due to the way frameworks work a user without admin privileges can install a
125binary distribution in his or her home directory without recompilation.
Jack Jansen7c0d7ba2003-06-20 15:14:08 +0000126
Jack Jansen0fdaee72002-08-02 21:45:27 +00001272. How does a framework Python differ from a normal static Python?
128------------------------------------------------------------------
129
130In everyday use there is no difference, except that things are stored in
131a different place. If you look in /Library/Frameworks/Python.framework
132you will see lots of relative symlinks, see the Apple documentation for
133details. If you are used to a normal unix Python file layout go down to
134Versions/Current and you will see the familiar bin and lib directories.
135
1363. Do I need extra packages?
137----------------------------
138
Thomas Wouters477c8d52006-05-27 19:21:47 +0000139Yes, probably. If you want Tkinter support you need to get the OSX AquaTk
140distribution, this is installed by default on Mac OS X 10.4 or later. If
Jack Jansen1f74ed82002-09-06 21:00:55 +0000141you want wxPython you need to get that. If you want Cocoa you need to get
Thomas Wouters477c8d52006-05-27 19:21:47 +0000142PyObjC.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000143
1444. How do I build a framework Python?
145-------------------------------------
146
Jack Jansen21ed16a2002-08-02 14:11:24 +0000147This directory contains a Makefile that will create a couple of python-related
Jack Jansen1f74ed82002-09-06 21:00:55 +0000148applications (fullblown OSX .app applications, that is) in
Brett Cannon85266da2009-12-13 21:15:41 +0000149"/Applications/MacPython <VERSION>", and a hidden helper application Python.app
Thomas Wouters477c8d52006-05-27 19:21:47 +0000150inside the Python.framework, and unix tools "python" and "pythonw" into
151/usr/local/bin. In addition it has a target "installmacsubtree" that installs
152the relevant portions of the Mac subtree into the Python.framework.
Jack Jansen0511b762001-09-06 16:36:42 +0000153
Jack Jansen21ed16a2002-08-02 14:11:24 +0000154It is normally invoked indirectly through the main Makefile, as the last step
155in the sequence
Thomas Wouters477c8d52006-05-27 19:21:47 +0000156
157 1. ./configure --enable-framework
158
159 2. make
160
161 3. make install
Jack Jansen0fdaee72002-08-02 21:45:27 +0000162
Jack Jansen1f74ed82002-09-06 21:00:55 +0000163This sequence will put the framework in /Library/Framework/Python.framework,
Brett Cannon85266da2009-12-13 21:15:41 +0000164the applications in "/Applications/MacPython <VERSION>" and the unix tools in
Thomas Wouters477c8d52006-05-27 19:21:47 +0000165/usr/local/bin.
Jack Jansen7a1703d2002-08-12 20:46:18 +0000166
Jack Jansen7c0d7ba2003-06-20 15:14:08 +0000167Installing in another place, for instance $HOME/Library/Frameworks if you have
Jack Jansen1f74ed82002-09-06 21:00:55 +0000168no admin privileges on your machine, has only been tested very lightly. This
169can be done by configuring with --enable-framework=$HOME/Library/Frameworks.
Brett Cannon85266da2009-12-13 21:15:41 +0000170The other two directories, "/Applications/MacPython-<VERSION>" and
171/usr/local/bin, will then also be deposited in $HOME. This is sub-optimal for
172the unix tools, which you would want in $HOME/bin, but there is no easy way to
173fix this right now.
Jack Jansen7a1703d2002-08-12 20:46:18 +0000174
175If you want to install some part, but not all, read the main Makefile. The
Jack Jansen1f74ed82002-09-06 21:00:55 +0000176frameworkinstall is composed of a couple of sub-targets that install the
177framework itself, the Mac subtree, the applications and the unix tools.
Jack Jansen7a1703d2002-08-12 20:46:18 +0000178
Jack Jansen7c0d7ba2003-06-20 15:14:08 +0000179There is an extra target frameworkinstallextras that is not part of the
180normal frameworkinstall which installs the Demo and Tools directories
Brett Cannon85266da2009-12-13 21:15:41 +0000181into "/Applications/MacPython <VERSION>", this is useful for binary
182distributions.
Jack Jansen7c0d7ba2003-06-20 15:14:08 +0000183
Thomas Wouters477c8d52006-05-27 19:21:47 +0000184What do all these programs do?
185===============================
Jack Jansen7a1703d2002-08-12 20:46:18 +0000186
Thomas Wouters477c8d52006-05-27 19:21:47 +0000187"IDLE.app" is an integrated development environment for Python: editor,
Jack Jansen0fdaee72002-08-02 21:45:27 +0000188debugger, etc.
189
Thomas Wouters477c8d52006-05-27 19:21:47 +0000190"PythonLauncher.app" is a helper application that will handle things when you
Jack Jansen0fdaee72002-08-02 21:45:27 +0000191double-click a .py, .pyc or .pyw file. For the first two it creates a Terminal
Jack Jansen1f74ed82002-09-06 21:00:55 +0000192window and runs the scripts with the normal command-line Python. For the
193latter it runs the script in the Python.app interpreter so the script can do
194GUI-things. Keep the "alt" key depressed while dragging or double-clicking a
195script to set runtime options. These options can be set once and for all
196through PythonLauncher's preferences dialog.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000197
Jack Jansen1f74ed82002-09-06 21:00:55 +0000198The commandline scripts /usr/local/bin/python and pythonw can be used to run
199non-GUI and GUI python scripts from the command line, respectively.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000200
Thomas Wouters477c8d52006-05-27 19:21:47 +0000201How do I create a binary distribution?
202======================================
Jack Jansen8ba42202002-09-06 20:24:51 +0000203
Thomas Wouters477c8d52006-05-27 19:21:47 +0000204Go to the directory "Mac/OSX/BuildScript". There you'll find a script
205"build-installer.py" that does all the work. This will download and build
206a number of 3th-party libaries, configures and builds a framework Python,
207installs it, creates the installer pacakge files and then packs this in a
208DMG image.
Jack Jansen4f901372004-07-15 21:30:41 +0000209
Thomas Wouters477c8d52006-05-27 19:21:47 +0000210The script will build a universal binary, you'll therefore have to run this
211script on Mac OS X 10.4 or later and with Xcode 2.1 or later installed.
Jack Jansen8ba42202002-09-06 20:24:51 +0000212
Jack Jansen7c0d7ba2003-06-20 15:14:08 +0000213All of this is normally done completely isolated in /tmp/_py, so it does not
214use your normal build directory nor does it install into /.
Jack Jansen8ba42202002-09-06 20:24:51 +0000215
Thomas Wouters477c8d52006-05-27 19:21:47 +0000216Because of the way the script locates the files it needs you have to run it
217from within the BuildScript directory. The script accepts a number of
218command-line arguments, run it with --help for more information.
Jack Jansen8ba42202002-09-06 20:24:51 +0000219
Thomas Wouters477c8d52006-05-27 19:21:47 +0000220Odds and ends
221=============
Jack Jansen408c16f2001-09-11 11:30:02 +0000222
Jack Jansen1f74ed82002-09-06 21:00:55 +0000223Something to take note of is that the ".rsrc" files in the distribution are
224not actually resource files, they're AppleSingle encoded resource files. The
225macresource module and the Mac/OSX/Makefile cater for this, and create
226".rsrc.df.rsrc" files on the fly that are normal datafork-based resource
227files.
Jack Jansen0511b762001-09-06 16:36:42 +0000228
Brett Cannon98809b72004-12-06 06:01:13 +0000229 Jack Jansen, Jack.Jansen@cwi.nl, 15-Jul-2004.
Thomas Wouters477c8d52006-05-27 19:21:47 +0000230 Ronald Oussoren, RonaldOussoren@mac.com, 26-May-2006