source: python/vendor/Python-2.7.6/Mac/README

Last change on this file was 388, checked in by dmik, 11 years ago

python: Update vendor to 2.7.6.

  • Property svn:eol-style set to native
File size: 12.0 KB
Line 
1============
2MacOSX Notes
3============
4
5This document provides a quick overview of some Mac OS X specific features in
6the Python distribution.
7
8Mac-specific arguments to configure
9===================================
10
11* ``--enable-framework[=DIR]``
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 If the optional directory argument is specified the framework it installed
19 into that directory. This can be used to install a python framework into
20 your home directory::
21
22 $ configure --enable-framework=/Users/ronald/Library/Frameworks
23 $ make && make install
24
25 This will install the framework itself in ``/Users/ronald/Library/Frameworks``,
26 the applications in a subdirectory of ``/Users/ronald/Applications`` and the
27 command-line tools in ``/Users/ronald/bin``.
28
29* ``--with-framework-name=NAME``
30
31 Specify the name for the python framework, defaults to ``Python``. This option
32 is only valid when ``--enable-framework`` is specified.
33
34* ``--enable-universalsdk[=PATH]``
35
36 Create a universal binary build of Python. This can be used with both
37 regular and framework builds.
38
39 The optional argument specifies which OSX SDK should be used to perform the
40 build. This defaults to ``/Developer/SDKs/MacOSX.10.4u.sdk``, specify
41 ``/`` when building on a 10.5 system, especially when building 64-bit code.
42
43 See the section _`Building and using a universal binary of Python on Mac OS X`
44 for more information.
45
46* ``--with-univeral-archs=VALUE``
47
48 Specify the kind of universal binary that should be created. This option is
49 only valid when ``--enable-universalsdk`` is specified.
50
51
52
53Building and using a universal binary of Python on Mac OS X
54===========================================================
55
561. What is a universal binary
57-----------------------------
58
59A universal binary build of Python contains object code for both PPC and i386
60and can therefore run at native speed on both classic powerpc based macs and
61the newer intel based macs.
62
632. How do I build a universal binary
64------------------------------------
65
66You can enable universal binaries by specifying the "--enable-universalsdk"
67flag to configure::
68
69 $ ./configure --enable-universalsdk
70 $ make
71 $ make install
72
73This flag can be used with a framework build of python, but also with a classic
74unix build. Either way you will have to build python on Mac OS X 10.4 (or later)
75with Xcode 2.1 (or later). You also have to install the 10.4u SDK when
76installing Xcode.
77
78The option ``--enable-universalsdk`` has an optional argument to specify an
79SDK, which defaults to the 10.4u SDK. When you build on OSX 10.5 or later
80you can use the system headers instead of an SDK::
81
82 $ ./configure --enable-universalsdk=/
83
842.1 Flavours of universal binaries
85..................................
86
87It is possible to build a number of flavours of the universal binary build,
88the default is a 32-bit only binary (i386 and ppc). The flavour can be
89specified using the option ``--with-universal-archs=VALUE``. The following
90values are available:
91
92 * ``32-bit``: ``ppc``, ``i386``
93
94 * ``64-bit``: ``ppc64``, ``x86_64``
95
96 * ``all``: ``ppc``, ``ppc64``, ``i386``, ``x86_64``
97
98 * ``3-way``: ``ppc``, ``i386`` and ``x86_64``
99
100 * ``intel``: ``i386``, ``x86_64``
101
102To build a universal binary that includes a 64-bit architecture, you must build
103on a system running OSX 10.5 or later. The ``all`` flavour can only be built on
104OSX 10.5.
105
106The makefile for a framework build will install ``python32`` and ``pythonw32``
107binaries when the universal architecures includes at least one 32-bit architecture
108(that is, for all flavours but ``64-bit``).
109
110Running a specific archicture
111.............................
112
113You can run code using a specific architecture using the ``arch`` command::
114
115 $ arch -i386 python
116
117Or to explicitly run in 32-bit mode, regardless of the machine hardware::
118
119 $ arch -i386 -ppc python
120
121NOTE: When you're using a framework install of Python this requires at least
122Python 2.7 or 3.2, in earlier versions the python (and pythonw) commands are
123wrapper tools that execute the real interpreter without ensuring that the
124real interpreter runs with the same architecture.
125
126Building and using a framework-based Python on Mac OS X.
127========================================================
128
129
1301. Why would I want a framework Python instead of a normal static Python?
131--------------------------------------------------------------------------
132
133The main reason is because you want to create GUI programs in Python. With the
134exception of X11/XDarwin-based GUI toolkits all GUI programs need to be run
135from a fullblown MacOSX application (a ".app" bundle).
136
137While it is technically possible to create a .app without using frameworks you
138will have to do the work yourself if you really want this.
139
140A second reason for using frameworks is that they put Python-related items in
141only two places: "/Library/Framework/Python.framework" and
142"/Applications/MacPython 2.6". This simplifies matters for users installing
143Python from a binary distribution if they want to get rid of it again. Moreover,
144due to the way frameworks work a user without admin privileges can install a
145binary distribution in his or her home directory without recompilation.
146
1472. How does a framework Python differ from a normal static Python?
148------------------------------------------------------------------
149
150In everyday use there is no difference, except that things are stored in
151a different place. If you look in /Library/Frameworks/Python.framework
152you will see lots of relative symlinks, see the Apple documentation for
153details. If you are used to a normal unix Python file layout go down to
154Versions/Current and you will see the familiar bin and lib directories.
155
1563. Do I need extra packages?
157----------------------------
158
159Yes, probably. If you want Tkinter support you need to get the OSX AquaTk
160distribution, this is installed by default on Mac OS X 10.4 or later. If
161you want wxPython you need to get that. If you want Cocoa you need to get
162PyObjC.
163
1644. How do I build a framework Python?
165-------------------------------------
166
167This directory contains a Makefile that will create a couple of python-related
168applications (fullblown OSX .app applications, that is) in
169"/Applications/MacPython 2.6", and a hidden helper application Python.app
170inside the Python.framework, and unix tools "python" and "pythonw" into
171/usr/local/bin. In addition it has a target "installmacsubtree" that installs
172the relevant portions of the Mac subtree into the Python.framework.
173
174It is normally invoked indirectly through the main Makefile, as the last step
175in the sequence::
176
177 $ ./configure --enable-framework
178 $ make
179 $ make install
180
181This sequence will put the framework in /Library/Framework/Python.framework,
182the applications in "/Applications/MacPython 2.6" and the unix tools in
183/usr/local/bin.
184
185It is possible to select a different name for the framework using the configure
186option ``--with-framework-name=NAME``. This makes it possible to have several
187parallel installs of a Python framework.
188
189Installing in another place, for instance $HOME/Library/Frameworks if you have
190no admin privileges on your machine, has only been tested very lightly. This
191can be done by configuring with --enable-framework=$HOME/Library/Frameworks.
192The other two directories, "/Applications/MacPython-2.6" and /usr/local/bin,
193will then also be deposited in $HOME. This is sub-optimal for the unix tools,
194which you would want in $HOME/bin, but there is no easy way to fix this right
195now.
196
197What do all these programs do?
198===============================
199
200"IDLE.app" is an integrated development environment for Python: editor,
201debugger, etc.
202
203"PythonLauncher.app" is a helper application that will handle things when you
204double-click a .py, .pyc or .pyw file. For the first two it creates a Terminal
205window and runs the scripts with the normal command-line Python. For the
206latter it runs the script in the Python.app interpreter so the script can do
207GUI-things. Keep the "alt" key depressed while dragging or double-clicking a
208script to set runtime options. These options can be set once and for all
209through PythonLauncher's preferences dialog.
210
211"BuildApplet.app" creates an applet from a Python script. Drop the script on it
212and out comes a full-featured MacOS application. BuildApplet.app is now
213deprecated and has been removed in Python 3. As of OS X 10.8, Xcode 4 no
214longer supplies the headers for the deprecated QuickDraw APIs used by
215the EasyDialogs module making BuildApplet unusable as an app. It will
216not be built by the Mac/Makefile in this case.
217
218The commandline scripts /usr/local/bin/python and pythonw can be used to run
219non-GUI and GUI python scripts from the command line, respectively.
220
221How do I create a binary distribution?
222======================================
223
224Go to the directory "Mac/OSX/BuildScript". There you'll find a script
225"build-installer.py" that does all the work. This will download and build
226a number of 3rd-party libaries, configures and builds a framework Python,
227installs it, creates the installer package files and then packs this in a
228DMG image.
229
230The script will build a universal binary, you'll therefore have to run this
231script on Mac OS X 10.4 or later and with Xcode 2.1 or later installed.
232
233All of this is normally done completely isolated in /tmp/_py, so it does not
234use your normal build directory nor does it install into /.
235
236Because of the way the script locates the files it needs you have to run it
237from within the BuildScript directory. The script accepts a number of
238command-line arguments, run it with --help for more information.
239
240Configure warnings
241==================
242
243The configure script sometimes emits warnings like the one below::
244
245 configure: WARNING: libintl.h: present but cannot be compiled
246 configure: WARNING: libintl.h: check for missing prerequisite headers?
247 configure: WARNING: libintl.h: see the Autoconf documentation
248 configure: WARNING: libintl.h: section "Present But Cannot Be Compiled"
249 configure: WARNING: libintl.h: proceeding with the preprocessor's result
250 configure: WARNING: libintl.h: in the future, the compiler will take precedence
251 configure: WARNING: ## -------------------------------------- ##
252 configure: WARNING: ## Report this to http://bugs.python.org/ ##
253 configure: WARNING: ## -------------------------------------- ##
254
255This almost always means you are trying to build a universal binary for
256Python and have libaries in ``/usr/local`` that don't contain the required
257architectures. Temporarily move ``/usr/local`` aside to finish the build.
258
259
260Uninstalling a framework install, including the binary installer
261================================================================
262
263Uninstalling a framework can be done by manually removing all bits that got installed.
264That's true for both installations from source and installations using the binary installer.
265Sadly enough OSX does not have a central uninstaller.
266
267The main bit of a framework install is the framework itself, installed in
268``/Library/Frameworks/Python.framework``. This can contain multiple versions
269of Python, if you want to remove just one version you have to remove the
270version-specific subdirectory: ``/Library/Frameworks/Python.framework/Versions/X.Y``.
271If you do that, ensure that ``/Library/Frameworks/Python.framework/Versions/Current``
272is a symlink that points to an installed version of Python.
273
274A framework install also installs some applications in ``/Applications/Python X.Y``,
275
276And lastly a framework installation installs files in ``/usr/local/bin``, all of
277them symbolic links to files in ``/Library/Frameworks/Python.framework/Versions/X.Y/bin``.
278
279Odds and ends
280=============
281
282Something to take note of is that the ".rsrc" files in the distribution are
283not actually resource files, they're AppleSingle encoded resource files. The
284macresource module and the Mac/OSX/Makefile cater for this, and create
285".rsrc.df.rsrc" files on the fly that are normal datafork-based resource
286files.
287
288 Jack Jansen, Jack.Jansen@cwi.nl, 15-Jul-2004.
289 Ronald Oussoren, RonaldOussoren@mac.com, 30-April-2010
Note: See TracBrowser for help on using the repository browser.