blob: bfb9dde9d432643c245f92de5caf52054fec6cc5 [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,
53and a hidden helper application Python.app inside the Python.framework. In addition
54it has a target "installmacsubtree" that installs the relevant portions of the
55Mac subtree into the Python.framework.
Jack Jansen0511b762001-09-06 16:36:42 +000056
Jack Jansen21ed16a2002-08-02 14:11:24 +000057It is normally invoked indirectly through the main Makefile, as the last step
58in the sequence
591. configure --enable-framework
602. make
613. make frameworkinstall
624. make osxapps
Jack Jansen0fdaee72002-08-02 21:45:27 +0000635. [optional] in Mac/OSX do "make installunixprograms", see below.
64
65This sequence will put the framework in /Library/Framework/Python.framework and
66the 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
68been tested very lightly.
69
705. What do all these programs do?
71---------------------------------
72
73PythonIDE.app is an integrated development environment for Python: editor,
74debugger, etc.
75
76PythonLauncher.app is a helper application that will handle things when you
77double-click a .py, .pyc or .pyw file. For the first two it creates a Terminal
78window and runs the scripts with the normal command-line Python. For the latter
79it runs the script in the Python.app interpreter so the script can do GUI-things.
80Keep the "alt" key depressed while dragging or double-clicking a script to set
81runtime options. These options can be set once and for all through PythonLauncher's
82preferences dialog.
83
84BuildApplet.app creates an applet from a Python script. Drop the script on it
85and out comes a full-featured MacOS application. There is much more to this, to
86be supplied later. Some useful (but outdated) info can be found in Mac/Demo.
87
88If you install the commandline scripts /usr/local/bin/python and pythonw these
89can be used to run non-GUI and GUI python scripts from the command line, respectively.
90
916. Odds and ends.
92-----------------
Jack Jansen0511b762001-09-06 16:36:42 +000093
Jack Jansen21ed16a2002-08-02 14:11:24 +000094The interesting targets in the makefile are:
95installmacsubtree - explained above,
96dontinstallmacsubtree - Put only a .pth file into the framework (pointing to this
97 sourcetree), which may be easier for development,
98install_all - install all three .app applications,
99install_Python - install the hidden interpreter .app into the framework,
100install_PythonLauncher - install the user-visible script launch helper
101install_IDE - install the IDE
102installunixprograms - install symlinks/scripts mimicking normal unix Python into
103 /usr/local.
Jack Jansen0fdaee72002-08-02 21:45:27 +0000104
105The PythonLauncher is actually an Objective C Cocoa app built with Project Builder.
106It could be a Python program, except for the fact that pyobjc is not a part of
107the core distribution, and is not completely finished yet as of this writing.
Jack Jansen408c16f2001-09-11 11:30:02 +0000108
Jack Jansen0511b762001-09-06 16:36:42 +0000109Something to take note of is that the ".rsrc" files in the distribution are not
Jack Jansen0fdaee72002-08-02 21:45:27 +0000110actually resource files, they're AppleSingle encoded resource files. The macresource
111module and the Mac/OSX/Makefile cater for this, and create ".rsrc.df.rsrc" files
112on the fly that are normal datafork-based resource files.
Jack Jansen0511b762001-09-06 16:36:42 +0000113
Jack Jansen21ed16a2002-08-02 14:11:24 +0000114 Jack Jansen, jack@oratrix.com, 02-Aug-02