1- ============
2- MacOSX Notes
3- ============
1+ =========================
2+ Python 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+
10+ :Version: 3.3.0
411
512This document provides a quick overview of some Mac OS X specific features in
613the Python distribution.
@@ -12,11 +19,11 @@ the Python distribution.
1219 _`Building and using a framework-based Python on Mac OS X` for more
1320 information on frameworks.
1421
15- If the optional directory argument is specified the framework it installed
22+ If the optional directory argument is specified the framework is installed
1623 into that directory. This can be used to install a python framework into
1724 your home directory::
1825
19- $ configure --enable-framework=/Users/ronald/Library/Frameworks
26+ $ ./ configure --enable-framework=/Users/ronald/Library/Frameworks
2027 $ make && make install
2128
2229 This will install the framework itself in ``/Users/ronald/Library/Frameworks``,
@@ -33,17 +40,20 @@ the Python distribution.
3340 Create a universal binary build of of Python. This can be used with both
3441 regular and framework builds.
3542
36- The optional argument specifies which OSX SDK should be used to perform the
37- build. This defaults to ``/Developer/SDKs/MacOSX.10.4u.sdk``, specify
38- ``/`` when building on a 10.5 system, especially when building 64-bit code.
43+ The optional argument specifies which OS X SDK should be used to perform the
44+ build. If xcodebuild is available and configured, this defaults to
45+ the Xcode default MacOS X SDK, otherwise ``/Developer/SDKs/MacOSX.10.4u.sdk``
46+ if available or ``/`` if not.
3947
4048 See the section _`Building and using a universal binary of Python on Mac OS X`
4149 for more information.
4250
4351* ``--with-univeral-archs=VALUE``
4452
4553 Specify the kind of universal binary that should be created. This option is
46- only valid when ``--enable-universalsdk`` is specified.
54+ only valid when ``--enable-universalsdk`` is specified. The default is
55+ ``32-bit`` if a building with a SDK that supports PPC, otherwise defaults
56+ to ``intel``.
4757
4858
4959Building and using a universal binary of Python on Mac OS X
@@ -52,9 +62,14 @@ Building and using a universal binary of Python on Mac OS X
52621. What is a universal binary
5363-----------------------------
5464
55- A universal binary build of Python contains object code for both PPC and i386
56- and can therefore run at native speed on both classic powerpc based macs and
57- the newer intel based macs.
65+ A universal binary build of Python contains object code for more than one
66+ CPU architecture. A universal OS X executable file or library combines the
67+ architecture-specific code into one file and can therefore run at native
68+ speed on all supported architectures. Universal files were introduced in
69+ OS X 10.4 to add support for Intel-based Macs to the existing PowerPC (PPC)
70+ machines. In OS X 10.5 support was extended to 64-bit Intel and 64-bit PPC
71+ architectures. It is possible to build Python with various combinations
72+ of architectures depending on the build tools and OS X version in use.
5873
59742. How do I build a universal binary
6075------------------------------------
@@ -67,35 +82,52 @@ flag to configure::
6782 $ make install
6883
6984This flag can be used with a framework build of python, but also with a classic
70- unix build. Either way you will have to build python on Mac OS X 10.4 (or later)
71- with Xcode 2.1 (or later). You also have to install the 10.4u SDK when
72- installing Xcode.
73-
74- 2.1 Flavours of universal binaries
75- ..................................
76-
77- It is possible to build a number of flavours of the universal binary build,
78- the default is a 32-bit only binary (i386 and ppc). The flavour can be
79- specified using the option ``--with-universal-archs=VALUE``. The following
85+ unix build. Universal builds were first supported with OS X 10.4 with Xcode 2.1
86+ and the 10.4u SDK. Starting with Xcode 3 and OS X 10.5, more configurations are
87+ available.
88+
89+ 2.1 Flavors of universal binaries
90+ .................................
91+
92+ It is possible to build a number of flavors of the universal binary build,
93+ the default is a 32-bit only binary (i386 and ppc) in build environments that
94+ support ppc (10.4 with Xcode 2, 10.5 and 10.6 with Xcode 3) or an
95+ Intel-32/-64-bit binary (i386 and X86_64) in build environments that do not
96+ support ppc (Xcode 4 on 10.6 and later systems). The flavor can be specified
97+ using the configure option ``--with-universal-archs=VALUE``. The following
8098values are available:
8199
100+ * ``intel``: ``i386``, ``x86_64``
101+
82102 * ``32-bit``: ``ppc``, ``i386``
83103
104+ * ``3-way``: ``i386``, ``x86_64``, ``ppc``
105+
84106 * ``64-bit``: ``ppc64``, ``x86_64``
85107
86108 * ``all``: ``ppc``, ``ppc64``, ``i386``, ``x86_64``
87109
88- * ``3-way``: ``ppc``, ``i386`` and ``x86_64``
110+ To build a universal binary that includes a 64-bit architecture, you must build
111+ on a system running OS X 10.5 or later. The ``all`` and ``64-bit`` flavors can
112+ only be built with an 10.5 SDK because ``ppc64`` support was only included with
113+ OS X 10.5. Although legacy ``ppc`` support was included with Xcode 3 on OS X
114+ 10.6, it was removed in Xcode 4, versions of which were released on OS X 10.6
115+ and which is the current standard for OS X 10.7 and 10.8. To summarize, the
116+ following combinations of SDKs and universal-archs flavors are available:
89117
90- * ``intel``: ``i386``, ``x86_64``
118+ * 10.4u SDK with Xcode 2 supports ``32-bit`` only
91119
92- To build a universal binary that includes a 64-bit architecture, you must build
93- on a system running OSX 10.5 or later. The ``all`` flavour can only be built on
94- OSX 10.5.
120+ * 10.5 SDK with Xcode 3.1.x supports all flavors
121+
122+ * 10.6 SDK with Xcode 3.2.x supports ``intel``, ``3-way``, and ``32-bit``
123+
124+ * 10.6 SDK with Xcode 4 supports ``intel`` only
95125
96- The makefile for a framework build will install ``python32`` and ``pythonw32``
97- binaries when the universal architecures includes at least one 32-bit architecture
98- (that is, for all flavours but ``64-bit``).
126+ * 10.7 and 10.8 SDKs with Xcode 4 support ``intel`` only
127+
128+ The makefile for a framework build will also install ``python3.3-32``
129+ binaries when the universal architecture includes at least one 32-bit
130+ architecture (that is, for all flavors but ``64-bit``).
99131
100132Running a specific archicture
101133.............................
@@ -122,17 +154,17 @@ Building and using a framework-based Python on Mac OS X.
122154
123155The main reason is because you want to create GUI programs in Python. With the
124156exception of X11/XDarwin-based GUI toolkits all GUI programs need to be run
125- from a fullblown MacOSX application (a ".app" bundle ).
157+ from a Mac OSX application bundle ( ".app").
126158
127159While it is technically possible to create a .app without using frameworks you
128160will have to do the work yourself if you really want this.
129161
130162A second reason for using frameworks is that they put Python-related items in
131163only two places: "/Library/Framework/Python.framework" and
132- "/Applications/MacPython <VERSION>" where ``<VERSION>`` can be e.g. "2.6 ",
133- "3.1 ", etc.. This simplifies matters for users installing
164+ "/Applications/Python <VERSION>" where ``<VERSION>`` can be e.g. "3.3 ",
165+ "2.7 ", etc. This simplifies matters for users installing
134166Python from a binary distribution if they want to get rid of it again. Moreover,
135- due to the way frameworks work a user without admin privileges can install a
167+ due to the way frameworks work, a user without admin privileges can install a
136168binary distribution in his or her home directory without recompilation.
137169
1381702. How does a framework Python differ from a normal static Python?
@@ -156,10 +188,10 @@ PyObjC.
156188-------------------------------------
157189
158190This directory contains a Makefile that will create a couple of python-related
159- applications (fullblown OSX .app applications, that is) in
160- "/Applications/MacPython <VERSION>", and a hidden helper application Python.app
161- inside the Python.framework, and unix tools "python" and "pythonw" into
162- /usr/local/bin. In addition it has a target "installmacsubtree" that installs
191+ applications (full-blown OSX .app applications, that is) in
192+ "/Applications/Python <VERSION>", and a hidden helper application Python.app
193+ inside the Python.framework, and unix tools "python" and "pythonw" into
194+ /usr/local/bin. In addition it has a target "installmacsubtree" that installs
163195the relevant portions of the Mac subtree into the Python.framework.
164196
165197It is normally invoked indirectly through the main Makefile, as the last step
@@ -171,25 +203,23 @@ in the sequence
171203
172204 3. make install
173205
174- This sequence will put the framework in /Library/Framework/Python.framework,
175- the applications in " /Applications/MacPython <VERSION>" and the unix tools in
176- /usr/local/bin.
206+ This sequence will put the framework in `` /Library/Framework/Python.framework`` ,
207+ the applications in `` /Applications/Python <VERSION>`` and the unix tools in
208+ `` /usr/local/bin`` .
177209
178- Installing in another place, for instance $HOME/Library/Frameworks if you have
179- no admin privileges on your machine, has only been tested very lightly. This
180- can be done by configuring with --enable-framework=$HOME/Library/Frameworks.
181- The other two directories, "/Applications/MacPython-<VERSION>" and
182- /usr/local/bin, will then also be deposited in $HOME. This is sub-optimal for
183- the unix tools, which you would want in $HOME/bin, but there is no easy way to
184- fix this right now.
210+ Installing in another place, for instance ``$HOME/Library/Frameworks`` if you
211+ have no admin privileges on your machine, is possible. This can be accomplished
212+ by configuring with ``--enable-framework=$HOME/Library/Frameworks``.
213+ The other two directories will then also be installed in your home directory,
214+ at ``$HOME/Applications/Python-<VERSION>`` and ``$HOME/bin``.
185215
186216If you want to install some part, but not all, read the main Makefile. The
187217frameworkinstall is composed of a couple of sub-targets that install the
188218framework itself, the Mac subtree, the applications and the unix tools.
189219
190220There is an extra target frameworkinstallextras that is not part of the
191221normal frameworkinstall which installs the Tools directory into
192- "/Applications/MacPython <VERSION>", this is useful for binary
222+ "/Applications/Python <VERSION>", this is useful for binary
193223distributions.
194224
195225What do all these programs do?
@@ -202,24 +232,35 @@ debugger, etc.
202232double-click a .py, .pyc or .pyw file. For the first two it creates a Terminal
203233window and runs the scripts with the normal command-line Python. For the
204234latter it runs the script in the Python.app interpreter so the script can do
205- GUI-things. Keep the "alt" key depressed while dragging or double-clicking a
206- script to set runtime options. These options can be set once and for all
235+ GUI-things. Keep the ``Option`` key depressed while dragging or double-clicking
236+ a script to set runtime options. These options can be set persistently
207237through PythonLauncher's preferences dialog.
208238
209- The commandline scripts /usr/local/bin/python and pythonw can be used to run
210- non-GUI and GUI python scripts from the command line, respectively.
239+ The program ``pythonx.x`` runs python scripts from the command line. Various
240+ compatibility aliases are also installed, including ``pythonwx.x`` which
241+ in early releases of Python on OS X was required to run GUI programs. In
242+ current releases, the ``pythonx.x`` and ``pythonwx.x`` commands are identical.
211243
212244How do I create a binary distribution?
213245======================================
214246
215- Go to the directory "Mac/OSX/BuildScript". There you'll find a script
216- "build-installer.py" that does all the work. This will download and build
247+ Download and unpack the source release from http://www.python.org/download/.
248+ Go to the directory ``Mac/BuildScript``. There you will find a script
249+ ``build-installer.py`` that does all the work. This will download and build
217250a number of 3rd-party libaries, configures and builds a framework Python,
218251installs it, creates the installer package files and then packs this in a
219- DMG image.
252+ DMG image. The script also builds an HTML copy of the current Python
253+ documentation set for this release for inclusion in the framework. The
254+ installer package will create links to the documentation for use by IDLE,
255+ pydoc, shell users, and Finder user.
220256
221- The script will build a universal binary, you'll therefore have to run this
257+ The script will build a universal binary so you'll therefore have to run this
222258script on Mac OS X 10.4 or later and with Xcode 2.1 or later installed.
259+ However, the Python build process itself has several build dependencies not
260+ available out of the box with OS X 10.4 so you may have to install
261+ additional software beyond what is provided with Xcode 2. OS X 10.5
262+ provides a recent enough system Python (in ``/usr/bin``) to build
263+ the Python documentation set.
223264
224265All of this is normally done completely isolated in /tmp/_py, so it does not
225266use your normal build directory nor does it install into /.
@@ -253,7 +294,7 @@ Uninstalling a framework install, including the binary installer
253294
254295Uninstalling a framework can be done by manually removing all bits that got installed.
255296That's true for both installations from source and installations using the binary installer.
256- Sadly enough OSX does not have a central uninstaller.
297+ OS X does not provide a central uninstaller.
257298
258299The main bit of a framework install is the framework itself, installed in
259300``/Library/Frameworks/Python.framework``. This can contain multiple versions
@@ -267,14 +308,12 @@ A framework install also installs some applications in ``/Applications/Python X.
267308And lastly a framework installation installs files in ``/usr/local/bin``, all of
268309them symbolic links to files in ``/Library/Frameworks/Python.framework/Versions/X.Y/bin``.
269310
270- Odds and ends
271- =============
272311
273- Something to take note of is that the ".rsrc" files in the distribution are
274- not actually resource files, they're AppleSingle encoded resource files. The
275- macresource module and the Mac/OSX/Makefile cater for this, and create
276- ".rsrc.df.rsrc" files on the fly that are normal datafork-based resource
277- files.
312+ Resources
313+ =========
314+
315+ * http://www.python.org/download/mac/
316+
317+ * http://www.python.org/community/sigs/current/pythonmac-sig/
278318
279- Jack Jansen,
[email protected] , 15-Jul-2004.
280- Ronald Oussoren,
[email protected] , 30-April-2010
319+ * http://docs.python.org/devguide/
0 commit comments