blob: 38a2370c92f48881c6c9386eeb32db841f87d710 [file] [log] [blame]
Jack Jansen0fdaee72002-08-02 21:45:27 +00001Building and using a framework-based Python on Mac OS X.
2--------------------------------------------------------
3
4This document provides a quick introduction to framework-based Python.
5It is rather terse and probably incomplete, please send me feedback.
6
71. Why would I want a framework Python in stead of a normal static Python?
8--------------------------------------------------------------------------
9
10The main reason is because you want to create GUI programs in Python. With
11the exception of X11/XDarwin-based GUI toolkits it appears that all GUI programs
12need to be run from a fullblown MacOSX application (a ".app" bundle).
13
14While it is technically possible to create a .app without using frameworks
15you will have to do the work yourself if you really want this.
16
17A second reason for using frameworks is that they put Python-related items
18in only two places: /Library/Framework/Python.framework and /Applications/Python.
19This simplifies matters for users installing Python from a binary distribution
20if they want to get rid of it again. Moreover, due to the way frameworks
21work a user without admin privileges can install a binary distribution in
22his or her home directory without recompilation.
23
242. How does a framework Python differ from a normal static Python?
25------------------------------------------------------------------
26
27In everyday use there is no difference, except that things are stored in
28a different place. If you look in /Library/Frameworks/Python.framework
29you will see lots of relative symlinks, see the Apple documentation for
30details. If you are used to a normal unix Python file layout go down to
31Versions/Current and you will see the familiar bin and lib directories.
32
333. Do I need extra packages?
34----------------------------
35
36Yes, probably. If you want to be able to use the PythonIDE you will need to
37get Waste, an all-singing-all-dancing TextEdit replacement, from www.merzwaren.com.
38It will unpack into a folder named something like "Waste 2.1 Distribution". Make
39a symlink called "waste" to this folder, somewhere beside your Python source
40distribution (it can be "../waste", "../../waste", etc).
41
42If you want Tkinter support you need to get the OSX AquaTk distribution. If you
43want wxPython you need to get that. If you want Cocoa you need to get pyobjc.
44Because all these are currently in a state of flux please refer to
45http://www.cwi.nl/~jack/macpython.html, which should contain pointers to more
46information.
47
484. How do I build a framework Python?
49-------------------------------------
50
Jack Jansen21ed16a2002-08-02 14:11:24 +000051This directory contains a Makefile that will create a couple of python-related
52applications (fullblown OSX .app applications, that is) in /Applications/Python,
Jack Jansen7a1703d2002-08-12 20:46:18 +000053and a hidden helper application Python.app inside the Python.framework, and
54unix tools "python" and "pythonw" into /usr/local/bin. In addition
Jack Jansen21ed16a2002-08-02 14:11:24 +000055it has a target "installmacsubtree" that installs the relevant portions of the
56Mac subtree into the Python.framework.
Jack Jansen0511b762001-09-06 16:36:42 +000057
Jack Jansen21ed16a2002-08-02 14:11:24 +000058It is normally invoked indirectly through the main Makefile, as the last step
59in the sequence
601. configure --enable-framework
612. make
623. make frameworkinstall
Jack Jansen0fdaee72002-08-02 21:45:27 +000063
Jack Jansen7a1703d2002-08-12 20:46:18 +000064This sequence will put the framework in /Library/Framework/Python.framework,
65the applications in /Applications/Python and the unix tools in /usr/local/bin.
66
67Building in another place, for instance $HOME/Library/Frameworks if you have no
68admin privileges on your machine, has only been tested very lightly. This can be done
69by configuring with --enable-framework=$HOME/Library/Frameworks. The other two
70directories, /Applications/Python and /usr/local/bin, will then also be deposited
71in $HOME. This is sub-optimal for the unix tools, which you would want in $HOME/bin,
72but there is no easy way to fix this right now.
73
74Note that there are no references to the actual locations in the code or resource
75files, so you are free to move things around afterwards. For example, you could
76use --enable-framework=/tmp/newversion/Library/Frameworks and use /tmp/newversion
77as the basis for an installer or something.
78
79If you want to install some part, but not all, read the main Makefile. The
80frameworkinstall is composed of a couple of sub-targets that install the framework
81itself, the Mac subtree, the applications and the unix tools.
82
83If you want to run the Makefile here directly, in stead of through the main Makefile,
84you will have to pass various variable-assignments. Read the beginning of the Makefile
85for details.
86
Jack Jansen0fdaee72002-08-02 21:45:27 +000087
885. What do all these programs do?
89---------------------------------
90
91PythonIDE.app is an integrated development environment for Python: editor,
92debugger, etc.
93
94PythonLauncher.app is a helper application that will handle things when you
95double-click a .py, .pyc or .pyw file. For the first two it creates a Terminal
96window and runs the scripts with the normal command-line Python. For the latter
97it runs the script in the Python.app interpreter so the script can do GUI-things.
98Keep the "alt" key depressed while dragging or double-clicking a script to set
99runtime options. These options can be set once and for all through PythonLauncher's
100preferences dialog.
101
102BuildApplet.app creates an applet from a Python script. Drop the script on it
103and out comes a full-featured MacOS application. There is much more to this, to
104be supplied later. Some useful (but outdated) info can be found in Mac/Demo.
105
Jack Jansen7a1703d2002-08-12 20:46:18 +0000106The commandline scripts /usr/local/bin/python and pythonw
Jack Jansen0fdaee72002-08-02 21:45:27 +0000107can be used to run non-GUI and GUI python scripts from the command line, respectively.
108
Jack Jansen8ba42202002-09-06 20:24:51 +00001096. How do I create a binary distribution?
110-----------------------------------------
111
112Note: this section is work-in-progress.
113
114First, to make sure there's no contamination, it is best to remove your existing Python
115installation (clear out /Library/Frameworks/Python.framework and /Applications/Python).
116Also, after build/install is finished check that nothing has shown up in those two locations.
117
118Create a subdirectory of the main python directory, say build-pythondist. In there, run
119 ../configure --enable-framework=/tmp/pythondist/Library/Frameworks/Python.framework \
120 LDFLAGS=-Wl,-x
121 make
122 make frameworkinstall
123This installs a complete distribution set in /tmp/pythondist: in a framework build all other
124pathnames are computed from the framework pathname.
125
126Note that the unix tools in /tmp/pythondist are wrong, these have to be removed, and the
127installer post-install script should recreate them on the target system. Also, the .pyc and
128.pyo files need to be removed:
129 rm -rf /tmp/pythondist/usr
130 python.exe ../Mac/script/zappycfiles.py /tmp/pythondist
131
132TBD: find out how to make a .pkg from here.
133
134TBD: documentation.
135
1367. Odds and ends.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000137-----------------
Jack Jansen0511b762001-09-06 16:36:42 +0000138
Jack Jansen0fdaee72002-08-02 21:45:27 +0000139The PythonLauncher is actually an Objective C Cocoa app built with Project Builder.
140It could be a Python program, except for the fact that pyobjc is not a part of
141the core distribution, and is not completely finished yet as of this writing.
Jack Jansen408c16f2001-09-11 11:30:02 +0000142
Jack Jansen0511b762001-09-06 16:36:42 +0000143Something to take note of is that the ".rsrc" files in the distribution are not
Jack Jansen0fdaee72002-08-02 21:45:27 +0000144actually resource files, they're AppleSingle encoded resource files. The macresource
145module and the Mac/OSX/Makefile cater for this, and create ".rsrc.df.rsrc" files
146on the fly that are normal datafork-based resource files.
Jack Jansen0511b762001-09-06 16:36:42 +0000147
Jack Jansen7a1703d2002-08-12 20:46:18 +0000148 Jack Jansen, jack@oratrix.com, 12-Aug-02