blob: 1e58b02aa0a742f3530285497c8c6259df6fd19a [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
8
9Building and using a universal binary of Python on Mac OS X
10===========================================================
11
121. What is a universal binary
13-----------------------------
14
15A universal binary build of Python contains object code for both PPC and i386
16and can therefore run at native speed on both classic powerpc based macs and
17the newer intel based macs.
18
192. How do I build a universal binary
20------------------------------------
21
22You can enable universal binaries by specifying the "--enable-universalsdk"
23flag to configure::
24
25 $ ./configure --enable-universalsdk
26 $ make
27 $ make install
28
29This flag can be used a framework build of python, but also with a classic
30unix build. Either way you will have to build python on Mac OS X 10.4 (or later)
31with Xcode 2.1 (or later). You also have to install the 10.4u SDK when
32installing Xcode.
33
34
35Building and using a framework-based Python on Mac OS X.
36========================================================
37
Jack Jansen0fdaee72002-08-02 21:45:27 +000038
Brett Cannon98809b72004-12-06 06:01:13 +0000391. Why would I want a framework Python instead of a normal static Python?
Jack Jansen0fdaee72002-08-02 21:45:27 +000040--------------------------------------------------------------------------
41
Jack Jansen1f74ed82002-09-06 21:00:55 +000042The main reason is because you want to create GUI programs in Python. With the
Ronald Oussoren73612362006-05-26 12:23:20 +000043exception of X11/XDarwin-based GUI toolkits all GUI programs need to be run
44from a fullblown MacOSX application (a ".app" bundle).
Jack Jansen0fdaee72002-08-02 21:45:27 +000045
Jack Jansen1f74ed82002-09-06 21:00:55 +000046While it is technically possible to create a .app without using frameworks you
47will have to do the work yourself if you really want this.
Jack Jansen0fdaee72002-08-02 21:45:27 +000048
Jack Jansen1f74ed82002-09-06 21:00:55 +000049A second reason for using frameworks is that they put Python-related items in
Ronald Oussoren73612362006-05-26 12:23:20 +000050only two places: "/Library/Framework/Python.framework" and
51"/Applications/MacPython 2.5". This simplifies matters for users installing
52Python from a binary distribution if they want to get rid of it again. Moreover,
53due to the way frameworks work a user without admin privileges can install a
54binary distribution in his or her home directory without recompilation.
Jack Jansen7c0d7ba2003-06-20 15:14:08 +000055
Jack Jansen0fdaee72002-08-02 21:45:27 +0000562. How does a framework Python differ from a normal static Python?
57------------------------------------------------------------------
58
59In everyday use there is no difference, except that things are stored in
60a different place. If you look in /Library/Frameworks/Python.framework
61you will see lots of relative symlinks, see the Apple documentation for
62details. If you are used to a normal unix Python file layout go down to
63Versions/Current and you will see the familiar bin and lib directories.
64
653. Do I need extra packages?
66----------------------------
67
Ronald Oussoren73612362006-05-26 12:23:20 +000068Yes, probably. If you want Tkinter support you need to get the OSX AquaTk
69distribution, this is installed by default on Mac OS X 10.4 or later. If
Jack Jansen1f74ed82002-09-06 21:00:55 +000070you want wxPython you need to get that. If you want Cocoa you need to get
Ronald Oussoren73612362006-05-26 12:23:20 +000071PyObjC.
Jack Jansen0fdaee72002-08-02 21:45:27 +000072
734. How do I build a framework Python?
74-------------------------------------
75
Jack Jansen21ed16a2002-08-02 14:11:24 +000076This directory contains a Makefile that will create a couple of python-related
Jack Jansen1f74ed82002-09-06 21:00:55 +000077applications (fullblown OSX .app applications, that is) in
Ronald Oussoren73612362006-05-26 12:23:20 +000078"/Applications/MacPython 2.3", and a hidden helper application Python.app
79inside the Python.framework, and unix tools "python" and "pythonw" into
80/usr/local/bin. In addition it has a target "installmacsubtree" that installs
81the relevant portions of the Mac subtree into the Python.framework.
Jack Jansen0511b762001-09-06 16:36:42 +000082
Jack Jansen21ed16a2002-08-02 14:11:24 +000083It is normally invoked indirectly through the main Makefile, as the last step
84in the sequence
Ronald Oussoren73612362006-05-26 12:23:20 +000085
86 1. ./configure --enable-framework
87
88 2. make
89
90 3. make install
Jack Jansen0fdaee72002-08-02 21:45:27 +000091
Jack Jansen1f74ed82002-09-06 21:00:55 +000092This sequence will put the framework in /Library/Framework/Python.framework,
Ronald Oussoren73612362006-05-26 12:23:20 +000093the applications in /Applications/MacPython 2.5 and the unix tools in
94/usr/local/bin.
Jack Jansen7a1703d2002-08-12 20:46:18 +000095
Jack Jansen7c0d7ba2003-06-20 15:14:08 +000096Installing in another place, for instance $HOME/Library/Frameworks if you have
Jack Jansen1f74ed82002-09-06 21:00:55 +000097no admin privileges on your machine, has only been tested very lightly. This
98can be done by configuring with --enable-framework=$HOME/Library/Frameworks.
Ronald Oussoren73612362006-05-26 12:23:20 +000099The other two directories, /Applications/MacPython-2.3 and /usr/local/bin, will
100then also be deposited in $HOME. This is sub-optimal for the unix tools, which
101you would want in $HOME/bin, but there is no easy way to fix this right now.
Jack Jansen7a1703d2002-08-12 20:46:18 +0000102
Jack Jansen1f74ed82002-09-06 21:00:55 +0000103Note that there are no references to the actual locations in the code or
104resource files, so you are free to move things around afterwards. For example,
105you could use --enable-framework=/tmp/newversion/Library/Frameworks and use
106/tmp/newversion as the basis for an installer or something.
Jack Jansen7a1703d2002-08-12 20:46:18 +0000107
108If you want to install some part, but not all, read the main Makefile. The
Jack Jansen1f74ed82002-09-06 21:00:55 +0000109frameworkinstall is composed of a couple of sub-targets that install the
110framework itself, the Mac subtree, the applications and the unix tools.
Jack Jansen7a1703d2002-08-12 20:46:18 +0000111
Jack Jansen7c0d7ba2003-06-20 15:14:08 +0000112There is an extra target frameworkinstallextras that is not part of the
113normal frameworkinstall which installs the Demo and Tools directories
114into /Applications/MacPython-2.3, this is useful for binary distributions.
115
Ronald Oussoren73612362006-05-26 12:23:20 +0000116What do all these programs do?
117===============================
Jack Jansen7a1703d2002-08-12 20:46:18 +0000118
Ronald Oussoren73612362006-05-26 12:23:20 +0000119"IDLE.app" is an integrated development environment for Python: editor,
Jack Jansen0fdaee72002-08-02 21:45:27 +0000120debugger, etc.
121
Ronald Oussoren73612362006-05-26 12:23:20 +0000122"PythonLauncher.app" is a helper application that will handle things when you
Jack Jansen0fdaee72002-08-02 21:45:27 +0000123double-click a .py, .pyc or .pyw file. For the first two it creates a Terminal
Jack Jansen1f74ed82002-09-06 21:00:55 +0000124window and runs the scripts with the normal command-line Python. For the
125latter it runs the script in the Python.app interpreter so the script can do
126GUI-things. Keep the "alt" key depressed while dragging or double-clicking a
127script to set runtime options. These options can be set once and for all
128through PythonLauncher's preferences dialog.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000129
Ronald Oussoren73612362006-05-26 12:23:20 +0000130"BuildApplet.app" creates an applet from a Python script. Drop the script on it
Jack Jansen1f74ed82002-09-06 21:00:55 +0000131and out comes a full-featured MacOS application. There is much more to this,
132to be supplied later. Some useful (but outdated) info can be found in
133Mac/Demo.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000134
Jack Jansen1f74ed82002-09-06 21:00:55 +0000135The commandline scripts /usr/local/bin/python and pythonw can be used to run
136non-GUI and GUI python scripts from the command line, respectively.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000137
Ronald Oussoren73612362006-05-26 12:23:20 +0000138How do I create a binary distribution?
139======================================
Jack Jansen8ba42202002-09-06 20:24:51 +0000140
Ronald Oussoren73612362006-05-26 12:23:20 +0000141Go to the directory "Mac/OSX/BuildScript". There you'll find a script
142"build-installer.py" that does all the work. This will download and build
143a number of 3th-party libaries, configures and builds a framework Python,
144installs it, creates the installer pacakge files and then packs this in a
145DMG image.
Jack Jansen4f901372004-07-15 21:30:41 +0000146
Ronald Oussoren73612362006-05-26 12:23:20 +0000147The script will build a universal binary, you'll therefore have to run this
148script on Mac OS X 10.4 or later and with Xcode 2.1 or later installed.
Jack Jansen8ba42202002-09-06 20:24:51 +0000149
Jack Jansen7c0d7ba2003-06-20 15:14:08 +0000150All of this is normally done completely isolated in /tmp/_py, so it does not
151use your normal build directory nor does it install into /.
Jack Jansen8ba42202002-09-06 20:24:51 +0000152
Ronald Oussoren73612362006-05-26 12:23:20 +0000153Because of the way the script locates the files it needs you have to run it
154from within the BuildScript directory. The script accepts a number of
155command-line arguments, run it with --help for more information.
Jack Jansen8ba42202002-09-06 20:24:51 +0000156
Ronald Oussoren73612362006-05-26 12:23:20 +0000157Odds and ends
158=============
Jack Jansen408c16f2001-09-11 11:30:02 +0000159
Jack Jansen1f74ed82002-09-06 21:00:55 +0000160Something to take note of is that the ".rsrc" files in the distribution are
161not actually resource files, they're AppleSingle encoded resource files. The
162macresource module and the Mac/OSX/Makefile cater for this, and create
163".rsrc.df.rsrc" files on the fly that are normal datafork-based resource
164files.
Jack Jansen0511b762001-09-06 16:36:42 +0000165
Brett Cannon98809b72004-12-06 06:01:13 +0000166 Jack Jansen, Jack.Jansen@cwi.nl, 15-Jul-2004.
Ronald Oussoren73612362006-05-26 12:23:20 +0000167 Ronald Oussoren, RonaldOussoren@mac.com, 26-May-2006