blob: 0a313d178fddb2341b4122a2674e7d494569f5ab [file] [log] [blame]
Ned Deily8e5c0a72012-06-23 23:13:24 -07001=========================
2Python on Mac OS X README
3=========================
4
5:Authors:
6 Jack Jansen (2004-07),
7 Ronald Oussoren (2010-04),
8 Ned Deily (2012-06)
9
Ned Deily87adb6e2013-10-18 21:09:56 -070010:Version: 3.4.0
Jack Jansen0fdaee72002-08-02 21:45:27 +000011
Thomas Wouters477c8d52006-05-27 19:21:47 +000012This document provides a quick overview of some Mac OS X specific features in
13the Python distribution.
14
Ned Deily5d520222014-05-17 14:30:09 -070015OS X specific arguments to configure
16====================================
17
Ronald Oussoren86b33c82010-04-30 11:41:56 +000018* ``--enable-framework[=DIR]``
Ronald Oussoren6f6c5622009-12-24 14:03:19 +000019
20 If this argument is specified the build will create a Python.framework rather
21 than a traditional Unix install. See the section
22 _`Building and using a framework-based Python on Mac OS X` for more
23 information on frameworks.
24
Ned Deily8e5c0a72012-06-23 23:13:24 -070025 If the optional directory argument is specified the framework is installed
Ronald Oussoren86b33c82010-04-30 11:41:56 +000026 into that directory. This can be used to install a python framework into
27 your home directory::
28
Ned Deily8e5c0a72012-06-23 23:13:24 -070029 $ ./configure --enable-framework=/Users/ronald/Library/Frameworks
Ronald Oussoren86b33c82010-04-30 11:41:56 +000030 $ make && make install
31
32 This will install the framework itself in ``/Users/ronald/Library/Frameworks``,
33 the applications in a subdirectory of ``/Users/ronald/Applications`` and the
34 command-line tools in ``/Users/ronald/bin``.
35
Ronald Oussoren6f6c5622009-12-24 14:03:19 +000036* ``--with-framework-name=NAME``
37
38 Specify the name for the python framework, defaults to ``Python``. This option
39 is only valid when ``--enable-framework`` is specified.
40
41* ``--enable-universalsdk[=PATH]``
42
Terry Jan Reedy65e69b32013-03-11 17:23:46 -040043 Create a universal binary build of Python. This can be used with both
Ronald Oussoren6f6c5622009-12-24 14:03:19 +000044 regular and framework builds.
45
Ned Deily8e5c0a72012-06-23 23:13:24 -070046 The optional argument specifies which OS X SDK should be used to perform the
47 build. If xcodebuild is available and configured, this defaults to
48 the Xcode default MacOS X SDK, otherwise ``/Developer/SDKs/MacOSX.10.4u.sdk``
49 if available or ``/`` if not.
Ronald Oussoren6f6c5622009-12-24 14:03:19 +000050
51 See the section _`Building and using a universal binary of Python on Mac OS X`
52 for more information.
53
54* ``--with-univeral-archs=VALUE``
55
56 Specify the kind of universal binary that should be created. This option is
Ned Deily8e5c0a72012-06-23 23:13:24 -070057 only valid when ``--enable-universalsdk`` is specified. The default is
58 ``32-bit`` if a building with a SDK that supports PPC, otherwise defaults
59 to ``intel``.
Ronald Oussoren6f6c5622009-12-24 14:03:19 +000060
Thomas Wouters477c8d52006-05-27 19:21:47 +000061
62Building and using a universal binary of Python on Mac OS X
63===========================================================
64
651. What is a universal binary
66-----------------------------
67
Ned Deily8e5c0a72012-06-23 23:13:24 -070068A universal binary build of Python contains object code for more than one
69CPU architecture. A universal OS X executable file or library combines the
70architecture-specific code into one file and can therefore run at native
71speed on all supported architectures. Universal files were introduced in
72OS X 10.4 to add support for Intel-based Macs to the existing PowerPC (PPC)
73machines. In OS X 10.5 support was extended to 64-bit Intel and 64-bit PPC
74architectures. It is possible to build Python with various combinations
75of architectures depending on the build tools and OS X version in use.
Thomas Wouters477c8d52006-05-27 19:21:47 +000076
772. How do I build a universal binary
78------------------------------------
79
80You can enable universal binaries by specifying the "--enable-universalsdk"
81flag to configure::
82
83 $ ./configure --enable-universalsdk
84 $ make
85 $ make install
86
Ned Deilye742ade2012-03-17 10:29:41 -070087This flag can be used with a framework build of python, but also with a classic
Ned Deily8e5c0a72012-06-23 23:13:24 -070088unix build. Universal builds were first supported with OS X 10.4 with Xcode 2.1
89and the 10.4u SDK. Starting with Xcode 3 and OS X 10.5, more configurations are
90available.
Thomas Wouters477c8d52006-05-27 19:21:47 +000091
Ned Deily892f4f92014-02-11 17:57:37 -080092In general, universal builds depend on specific features provided by the
93Apple-supplied compilers and other build tools included in Apple's Xcode
94development tools. You should install Xcode and the command line tools
95component appropriate for the OS X release you are running on. See the
96Python Developer's Guide (http://docs.python.org/devguide/setup.html)
97for more information.
98
Ned Deily8e5c0a72012-06-23 23:13:24 -0700992.1 Flavors of universal binaries
100.................................
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000101
Ned Deily8e5c0a72012-06-23 23:13:24 -0700102It is possible to build a number of flavors of the universal binary build,
103the default is a 32-bit only binary (i386 and ppc) in build environments that
104support ppc (10.4 with Xcode 2, 10.5 and 10.6 with Xcode 3) or an
105Intel-32/-64-bit binary (i386 and X86_64) in build environments that do not
106support ppc (Xcode 4 on 10.6 and later systems). The flavor can be specified
107using the configure option ``--with-universal-archs=VALUE``. The following
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000108values are available:
109
Ned Deily8e5c0a72012-06-23 23:13:24 -0700110 * ``intel``: ``i386``, ``x86_64``
111
Ned Deily87adb6e2013-10-18 21:09:56 -0700112 * ``intel-32``: ``i386``
113
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000114 * ``32-bit``: ``ppc``, ``i386``
115
Ned Deily8e5c0a72012-06-23 23:13:24 -0700116 * ``3-way``: ``i386``, ``x86_64``, ``ppc``
117
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000118 * ``64-bit``: ``ppc64``, ``x86_64``
119
120 * ``all``: ``ppc``, ``ppc64``, ``i386``, ``x86_64``
121
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000122To build a universal binary that includes a 64-bit architecture, you must build
Ned Deily8e5c0a72012-06-23 23:13:24 -0700123on a system running OS X 10.5 or later. The ``all`` and ``64-bit`` flavors can
124only be built with an 10.5 SDK because ``ppc64`` support was only included with
125OS X 10.5. Although legacy ``ppc`` support was included with Xcode 3 on OS X
12610.6, it was removed in Xcode 4, versions of which were released on OS X 10.6
Ned Deily5d520222014-05-17 14:30:09 -0700127and which is the standard for OS X 10.7. To summarize, the
Ned Deily8e5c0a72012-06-23 23:13:24 -0700128following combinations of SDKs and universal-archs flavors are available:
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000129
Ned Deily8e5c0a72012-06-23 23:13:24 -0700130 * 10.4u SDK with Xcode 2 supports ``32-bit`` only
131
132 * 10.5 SDK with Xcode 3.1.x supports all flavors
133
134 * 10.6 SDK with Xcode 3.2.x supports ``intel``, ``3-way``, and ``32-bit``
135
136 * 10.6 SDK with Xcode 4 supports ``intel`` only
137
138 * 10.7 and 10.8 SDKs with Xcode 4 support ``intel`` only
139
Ned Deily5d520222014-05-17 14:30:09 -0700140 * 10.8 and 10.9 SDKs with Xcode 5 support ``intel`` only
141
Ned Deily87adb6e2013-10-18 21:09:56 -0700142The makefile for a framework build will also install ``python3.4-32``
Ned Deily8e5c0a72012-06-23 23:13:24 -0700143binaries when the universal architecture includes at least one 32-bit
144architecture (that is, for all flavors but ``64-bit``).
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000145
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700146Running a specific architecture
147...............................
Ronald Oussoren6f6c5622009-12-24 14:03:19 +0000148
149You can run code using a specific architecture using the ``arch`` command::
150
151 $ arch -i386 python
152
153Or to explicitly run in 32-bit mode, regardless of the machine hardware::
154
155 $ arch -i386 -ppc python
156
157NOTE: When you're using a framework install of Python this requires at least
158Python 2.7 or 3.2, in earlier versions the python (and pythonw) commands are
159wrapper tools that execute the real interpreter without ensuring that the
160real interpreter runs with the same architecture.
Thomas Wouters477c8d52006-05-27 19:21:47 +0000161
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700162Using ``arch`` is not a perfect solution as the selected architecture will
163not automatically carry through to subprocesses launched by programs and tests
164under that Python. If you want to ensure that Python interpreters launched in
165subprocesses also run in 32-bit-mode if the main interpreter does, use
Ned Deily87adb6e2013-10-18 21:09:56 -0700166a ``python3.4-32`` binary and use the value of ``sys.executable`` as the
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700167``subprocess`` ``Popen`` executable value.
168
Thomas Wouters477c8d52006-05-27 19:21:47 +0000169Building and using a framework-based Python on Mac OS X.
170========================================================
171
Jack Jansen0fdaee72002-08-02 21:45:27 +0000172
Brett Cannon98809b72004-12-06 06:01:13 +00001731. Why would I want a framework Python instead of a normal static Python?
Jack Jansen0fdaee72002-08-02 21:45:27 +0000174--------------------------------------------------------------------------
175
Jack Jansen1f74ed82002-09-06 21:00:55 +0000176The main reason is because you want to create GUI programs in Python. With the
Thomas Wouters477c8d52006-05-27 19:21:47 +0000177exception of X11/XDarwin-based GUI toolkits all GUI programs need to be run
Ned Deily5d520222014-05-17 14:30:09 -0700178from a Mac OS X application bundle (".app").
Jack Jansen0fdaee72002-08-02 21:45:27 +0000179
Jack Jansen1f74ed82002-09-06 21:00:55 +0000180While it is technically possible to create a .app without using frameworks you
181will have to do the work yourself if you really want this.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000182
Jack Jansen1f74ed82002-09-06 21:00:55 +0000183A second reason for using frameworks is that they put Python-related items in
Thomas Wouters477c8d52006-05-27 19:21:47 +0000184only two places: "/Library/Framework/Python.framework" and
Ned Deily87adb6e2013-10-18 21:09:56 -0700185"/Applications/Python <VERSION>" where ``<VERSION>`` can be e.g. "3.4",
Ned Deily8e5c0a72012-06-23 23:13:24 -0700186"2.7", etc. This simplifies matters for users installing
Thomas Wouters477c8d52006-05-27 19:21:47 +0000187Python from a binary distribution if they want to get rid of it again. Moreover,
Ned Deily8e5c0a72012-06-23 23:13:24 -0700188due to the way frameworks work, a user without admin privileges can install a
Thomas Wouters477c8d52006-05-27 19:21:47 +0000189binary distribution in his or her home directory without recompilation.
Jack Jansen7c0d7ba2003-06-20 15:14:08 +0000190
Jack Jansen0fdaee72002-08-02 21:45:27 +00001912. How does a framework Python differ from a normal static Python?
192------------------------------------------------------------------
193
194In everyday use there is no difference, except that things are stored in
195a different place. If you look in /Library/Frameworks/Python.framework
196you will see lots of relative symlinks, see the Apple documentation for
197details. If you are used to a normal unix Python file layout go down to
198Versions/Current and you will see the familiar bin and lib directories.
199
2003. Do I need extra packages?
201----------------------------
202
Ned Deily5d520222014-05-17 14:30:09 -0700203Yes, probably. If you want Tkinter support you need to get the OS X AquaTk
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700204distribution, this is installed by default on Mac OS X 10.4 or later. Be
205aware, though, that the Cocoa-based AquaTk's supplied starting with OS X
20610.6 have proven to be unstable. If possible, you should consider
207installing a newer version before building on OS X 10.6 or later, such as
208the ActiveTcl 8.5. See http://www.python.org/download/mac/tcltk/. If you
209are building with an SDK, ensure that the newer Tcl and Tk frameworks are
210seen in the SDK's ``Library/Frameworks`` directory; you may need to
211manually create symlinks to their installed location, ``/Library/Frameworks``.
212If you want wxPython you need to get that.
213If you want Cocoa you need to get PyObjC.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000214
2154. How do I build a framework Python?
216-------------------------------------
217
Jack Jansen21ed16a2002-08-02 14:11:24 +0000218This directory contains a Makefile that will create a couple of python-related
Ned Deily5d520222014-05-17 14:30:09 -0700219applications (full-blown OS X .app applications, that is) in
Ned Deily8e5c0a72012-06-23 23:13:24 -0700220"/Applications/Python <VERSION>", and a hidden helper application Python.app
Ned Deily5d520222014-05-17 14:30:09 -0700221inside the Python.framework, and unix tools including "python" into
Ned Deily8e5c0a72012-06-23 23:13:24 -0700222/usr/local/bin. In addition it has a target "installmacsubtree" that installs
Thomas Wouters477c8d52006-05-27 19:21:47 +0000223the relevant portions of the Mac subtree into the Python.framework.
Jack Jansen0511b762001-09-06 16:36:42 +0000224
Jack Jansen21ed16a2002-08-02 14:11:24 +0000225It is normally invoked indirectly through the main Makefile, as the last step
226in the sequence
Thomas Wouters477c8d52006-05-27 19:21:47 +0000227
228 1. ./configure --enable-framework
229
230 2. make
231
232 3. make install
Jack Jansen0fdaee72002-08-02 21:45:27 +0000233
Ned Deily8e5c0a72012-06-23 23:13:24 -0700234This sequence will put the framework in ``/Library/Framework/Python.framework``,
235the applications in ``/Applications/Python <VERSION>`` and the unix tools in
236``/usr/local/bin``.
Jack Jansen7a1703d2002-08-12 20:46:18 +0000237
Ned Deily8e5c0a72012-06-23 23:13:24 -0700238Installing in another place, for instance ``$HOME/Library/Frameworks`` if you
239have no admin privileges on your machine, is possible. This can be accomplished
240by configuring with ``--enable-framework=$HOME/Library/Frameworks``.
241The other two directories will then also be installed in your home directory,
242at ``$HOME/Applications/Python-<VERSION>`` and ``$HOME/bin``.
Jack Jansen7a1703d2002-08-12 20:46:18 +0000243
244If you want to install some part, but not all, read the main Makefile. The
Jack Jansen1f74ed82002-09-06 21:00:55 +0000245frameworkinstall is composed of a couple of sub-targets that install the
246framework itself, the Mac subtree, the applications and the unix tools.
Jack Jansen7a1703d2002-08-12 20:46:18 +0000247
Jack Jansen7c0d7ba2003-06-20 15:14:08 +0000248There is an extra target frameworkinstallextras that is not part of the
Georg Brandl59b44722010-12-30 22:12:40 +0000249normal frameworkinstall which installs the Tools directory into
Ned Deily8e5c0a72012-06-23 23:13:24 -0700250"/Applications/Python <VERSION>", this is useful for binary
Brett Cannon85266da2009-12-13 21:15:41 +0000251distributions.
Jack Jansen7c0d7ba2003-06-20 15:14:08 +0000252
Thomas Wouters477c8d52006-05-27 19:21:47 +0000253What do all these programs do?
254===============================
Jack Jansen7a1703d2002-08-12 20:46:18 +0000255
Thomas Wouters477c8d52006-05-27 19:21:47 +0000256"IDLE.app" is an integrated development environment for Python: editor,
Jack Jansen0fdaee72002-08-02 21:45:27 +0000257debugger, etc.
258
Ned Deily5d520222014-05-17 14:30:09 -0700259"Python Launcher.app" is a helper application that will handle things when you
Jack Jansen0fdaee72002-08-02 21:45:27 +0000260double-click a .py, .pyc or .pyw file. For the first two it creates a Terminal
Jack Jansen1f74ed82002-09-06 21:00:55 +0000261window and runs the scripts with the normal command-line Python. For the
262latter it runs the script in the Python.app interpreter so the script can do
Ned Deily8e5c0a72012-06-23 23:13:24 -0700263GUI-things. Keep the ``Option`` key depressed while dragging or double-clicking
264a script to set runtime options. These options can be set persistently
Ned Deily5d520222014-05-17 14:30:09 -0700265through Python Launcher's preferences dialog.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000266
Ned Deily5d520222014-05-17 14:30:09 -0700267The program ``pythonx.x`` runs python scripts from the command line.
268Previously, various compatibility aliases were also installed, including
269``pythonwx.x`` which in early releases of Python on OS X was required to run
270GUI programs. As of 3.4.0, the ``pythonwx.x`` aliases are no longer installed.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000271
Thomas Wouters477c8d52006-05-27 19:21:47 +0000272How do I create a binary distribution?
273======================================
Jack Jansen8ba42202002-09-06 20:24:51 +0000274
Ned Deily8e5c0a72012-06-23 23:13:24 -0700275Download and unpack the source release from http://www.python.org/download/.
276Go to the directory ``Mac/BuildScript``. There you will find a script
277``build-installer.py`` that does all the work. This will download and build
Ned Deilye742ade2012-03-17 10:29:41 -0700278a number of 3rd-party libaries, configures and builds a framework Python,
279installs it, creates the installer package files and then packs this in a
Ned Deily8e5c0a72012-06-23 23:13:24 -0700280DMG image. The script also builds an HTML copy of the current Python
281documentation set for this release for inclusion in the framework. The
282installer package will create links to the documentation for use by IDLE,
283pydoc, shell users, and Finder user.
Jack Jansen4f901372004-07-15 21:30:41 +0000284
Ned Deily8e5c0a72012-06-23 23:13:24 -0700285The script will build a universal binary so you'll therefore have to run this
Thomas Wouters477c8d52006-05-27 19:21:47 +0000286script on Mac OS X 10.4 or later and with Xcode 2.1 or later installed.
Ned Deily8e5c0a72012-06-23 23:13:24 -0700287However, the Python build process itself has several build dependencies not
288available out of the box with OS X 10.4 so you may have to install
289additional software beyond what is provided with Xcode 2. OS X 10.5
290provides a recent enough system Python (in ``/usr/bin``) to build
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700291the Python documentation set. It should be possible to use SDKs and/or older
292versions of Xcode to build installers that are compatible with older systems
293on a newer system but this may not be completely foolproof so the resulting
294executables, shared libraries, and ``.so`` bundles should be carefully
295examined and tested on all supported systems for proper dynamic linking
296dependencies. It is safest to build the distribution on a system running the
297minimum OS X version supported.
Jack Jansen8ba42202002-09-06 20:24:51 +0000298
Jack Jansen7c0d7ba2003-06-20 15:14:08 +0000299All of this is normally done completely isolated in /tmp/_py, so it does not
300use your normal build directory nor does it install into /.
Jack Jansen8ba42202002-09-06 20:24:51 +0000301
Thomas Wouters477c8d52006-05-27 19:21:47 +0000302Because of the way the script locates the files it needs you have to run it
303from within the BuildScript directory. The script accepts a number of
304command-line arguments, run it with --help for more information.
Jack Jansen8ba42202002-09-06 20:24:51 +0000305
Ronald Oussorenf9adc372010-02-07 11:46:38 +0000306Configure warnings
307==================
308
309The configure script sometimes emits warnings like the one below::
310
311 configure: WARNING: libintl.h: present but cannot be compiled
312 configure: WARNING: libintl.h: check for missing prerequisite headers?
313 configure: WARNING: libintl.h: see the Autoconf documentation
314 configure: WARNING: libintl.h: section "Present But Cannot Be Compiled"
Ned Deily5d520222014-05-17 14:30:09 -0700315 configure: WARNING: libintl.h: proceeding with the preprocessor's result
Ronald Oussorenf9adc372010-02-07 11:46:38 +0000316 configure: WARNING: libintl.h: in the future, the compiler will take precedence
317 configure: WARNING: ## -------------------------------------- ##
318 configure: WARNING: ## Report this to http://bugs.python.org/ ##
319 configure: WARNING: ## -------------------------------------- ##
320
321This almost always means you are trying to build a universal binary for
Ned Deily5c0b1ca2012-08-24 19:57:33 -0700322Python and have libraries in ``/usr/local`` that don't contain the required
Ronald Oussorenf9adc372010-02-07 11:46:38 +0000323architectures. Temporarily move ``/usr/local`` aside to finish the build.
324
Ronald Oussoren56d64102010-04-30 15:13:13 +0000325
326Uninstalling a framework install, including the binary installer
327================================================================
328
Ned Deilye742ade2012-03-17 10:29:41 -0700329Uninstalling a framework can be done by manually removing all bits that got installed.
330That's true for both installations from source and installations using the binary installer.
Ned Deily8e5c0a72012-06-23 23:13:24 -0700331OS X does not provide a central uninstaller.
Ronald Oussoren56d64102010-04-30 15:13:13 +0000332
333The main bit of a framework install is the framework itself, installed in
334``/Library/Frameworks/Python.framework``. This can contain multiple versions
335of Python, if you want to remove just one version you have to remove the
336version-specific subdirectory: ``/Library/Frameworks/Python.framework/Versions/X.Y``.
337If you do that, ensure that ``/Library/Frameworks/Python.framework/Versions/Current``
338is a symlink that points to an installed version of Python.
339
340A framework install also installs some applications in ``/Applications/Python X.Y``,
341
342And lastly a framework installation installs files in ``/usr/local/bin``, all of
343them symbolic links to files in ``/Library/Frameworks/Python.framework/Versions/X.Y/bin``.
344
Jack Jansen408c16f2001-09-11 11:30:02 +0000345
Ned Deily8e5c0a72012-06-23 23:13:24 -0700346Resources
347=========
Jack Jansen0511b762001-09-06 16:36:42 +0000348
Ned Deily8e5c0a72012-06-23 23:13:24 -0700349 * http://www.python.org/download/mac/
350
351 * http://www.python.org/community/sigs/current/pythonmac-sig/
352
353 * http://docs.python.org/devguide/