1+ Building and using a framework-based Python on Mac OS X.
2+ --------------------------------------------------------
3+
4+ This document provides a quick introduction to framework-based Python.
5+ It is rather terse and probably incomplete, please send me feedback.
6+
7+ 1. Why would I want a framework Python in stead of a normal static Python?
8+ --------------------------------------------------------------------------
9+
10+ The main reason is because you want to create GUI programs in Python. With
11+ the exception of X11/XDarwin-based GUI toolkits it appears that all GUI programs
12+ need to be run from a fullblown MacOSX application (a ".app" bundle).
13+
14+ While it is technically possible to create a .app without using frameworks
15+ you will have to do the work yourself if you really want this.
16+
17+ A second reason for using frameworks is that they put Python-related items
18+ in only two places: /Library/Framework/Python.framework and /Applications/Python.
19+ This simplifies matters for users installing Python from a binary distribution
20+ if they want to get rid of it again. Moreover, due to the way frameworks
21+ work a user without admin privileges can install a binary distribution in
22+ his or her home directory without recompilation.
23+
24+ 2. How does a framework Python differ from a normal static Python?
25+ ------------------------------------------------------------------
26+
27+ In everyday use there is no difference, except that things are stored in
28+ a different place. If you look in /Library/Frameworks/Python.framework
29+ you will see lots of relative symlinks, see the Apple documentation for
30+ details. If you are used to a normal unix Python file layout go down to
31+ Versions/Current and you will see the familiar bin and lib directories.
32+
33+ 3. Do I need extra packages?
34+ ----------------------------
35+
36+ Yes, probably. If you want to be able to use the PythonIDE you will need to
37+ get Waste, an all-singing-all-dancing TextEdit replacement, from www.merzwaren.com.
38+ It will unpack into a folder named something like "Waste 2.1 Distribution". Make
39+ a symlink called "waste" to this folder, somewhere beside your Python source
40+ distribution (it can be "../waste", "../../waste", etc).
41+
42+ If you want Tkinter support you need to get the OSX AquaTk distribution. If you
43+ want wxPython you need to get that. If you want Cocoa you need to get pyobjc.
44+ Because all these are currently in a state of flux please refer to
45+ http://www.cwi.nl/~jack/macpython.html, which should contain pointers to more
46+ information.
47+
48+ 4. How do I build a framework Python?
49+ -------------------------------------
50+
151This directory contains a Makefile that will create a couple of python-related
252applications (fullblown OSX .app applications, that is) in /Applications/Python,
353and a hidden helper application Python.app inside the Python.framework. In addition
@@ -10,6 +60,36 @@ in the sequence
10602. make
11613. make frameworkinstall
12624. make osxapps
63+ 5. [optional] in Mac/OSX do "make installunixprograms", see below.
64+
65+ This sequence will put the framework in /Library/Framework/Python.framework and
66+ the applications in /Applications/Python. Building in another place, for instance
67+ $HOME/Library/Frameworks if you have no admin privileges on your machine, has only
68+ been tested very lightly.
69+
70+ 5. What do all these programs do?
71+ ---------------------------------
72+
73+ PythonIDE.app is an integrated development environment for Python: editor,
74+ debugger, etc.
75+
76+ PythonLauncher.app is a helper application that will handle things when you
77+ double-click a .py, .pyc or .pyw file. For the first two it creates a Terminal
78+ window and runs the scripts with the normal command-line Python. For the latter
79+ it runs the script in the Python.app interpreter so the script can do GUI-things.
80+ Keep the "alt" key depressed while dragging or double-clicking a script to set
81+ runtime options. These options can be set once and for all through PythonLauncher's
82+ preferences dialog.
83+
84+ BuildApplet.app creates an applet from a Python script. Drop the script on it
85+ and out comes a full-featured MacOS application. There is much more to this, to
86+ be supplied later. Some useful (but outdated) info can be found in Mac/Demo.
87+
88+ If you install the commandline scripts /usr/local/bin/python and pythonw these
89+ can be used to run non-GUI and GUI python scripts from the command line, respectively.
90+
91+ 6. Odds and ends.
92+ -----------------
1393
1494The interesting targets in the makefile are:
1595installmacsubtree - explained above,
@@ -21,9 +101,14 @@ install_PythonLauncher - install the user-visible script launch helper
21101install_IDE - install the IDE
22102installunixprograms - install symlinks/scripts mimicking normal unix Python into
23103 /usr/local.
24-
104+
105+ The PythonLauncher is actually an Objective C Cocoa app built with Project Builder.
106+ It could be a Python program, except for the fact that pyobjc is not a part of
107+ the core distribution, and is not completely finished yet as of this writing.
25108
26109Something to take note of is that the ".rsrc" files in the distribution are not
27- actually resource files, they're AppleSingle encoded resource files.
110+ actually resource files, they're AppleSingle encoded resource files. The macresource
111+ module and the Mac/OSX/Makefile cater for this, and create ".rsrc.df.rsrc" files
112+ on the fly that are normal datafork-based resource files.
28113
29114 Jack Jansen,
[email protected] , 02-Aug-02
0 commit comments