★ wanayoo — archive 1999 http://www.cwi.nl/~jack/macpython.htmlNouvelle recherche | Portail wanayoo

Jack's MacPython Page


What is MacPython?

MacPython is the port of the Guido van Rossum's Python high-level object-oriented language to the Mac. Python is freely distributable and available in source form too. The motherlode of information on Python is the website, www.python.org, and the ftp site, ftp.python.org. There you will also find information on the Python newsgroup comp.lang.python and the associated mailing list, the Python Software Activity, Python Special Interest Groups and much more.

The only Special Interest Group I will mention here is the PythonMac SIG, which has discussions on Macintosh-specific aspects of Python.

Aside from the numerous extension modules available on most platforms (include the Tk windowing toolkit, sockets and many others) MacPython has a number of extension modules specifically for MacOS. MacPython programmers have access to QuickDraw, QuickTime, the Sound manager and various third party toolkits like Internet Config and Waste, to name but a few.

Also included is an integrated development environment by Just van Rossum, which includes an editor, debugger and class browser all closely integrated.

The full distributions below contain examples and some documentation on Mac-specific aspects of using Python. Documentation on the language and the standard library can be obtained at the Python website.


Current distribution

The current distribution is 1.5.2. As of 1.5 MacPython is distributed as a single installer that installs one or more of PPC, CFM68K, "classic" 68K or fat Pythons. Also, it can optionally install NumPy (libraries for numeric calculations), Tkinter (for platform-independent GUI-building), PIL (for imaging) and img (another package for imaging) and the developer addon, files needed for creating your own C extension modules for Python with CodeWarrior.

68K users should note that there are problems with the CFM68K version of MacPython (the preferred version for 68K users, giving access to dynamically loaded modules and applets), so it may be advisable to use the static 68K version. The readme file has details.

The installer is available in MacBinary format (about 9Mb) and BinHex format (about 11Mb). Use the latter installer if your browser mistreats MacBinary files (as many appear to do).

Note: The interpreter version number and the folder it installs into are rather strangely named Python1.5.2c1. Because the MacPython distribution has significantly lagged behind the general 1.5.2 release (just this once, we hope:-) fixing this would have meant a lot of work, and even more lag. Sorry for this.

Note 2: some problems have been reported reported when installing MacPython on iMacs if you have the Virex antivirus software running. Disabling Virex should help here.

Documentation

You need the standard Python documentation (tutorial, reference manual, library reference) available at www.python.org. In addition you need the Mac addendum to the library reference. This is currently available as PostScript for A4 paper size (A gzipped version is available too) and Acrobat Reader (pdf). I will try to make html and Acrobat versions with indexing available, but I currently lack the software to create them (the current pdf file was converted with MacGS by Tony Ingraldi). The mac-specific documentation is still for Python 1.5.1, but not much has changed.

Tambien, si puede leer espanol, MacWorld Espana tiene un curso de programacion en Python sobre el Mac. Esta seria comenza en el numero de julio/agosto 1998.

And if you don't read spanish you can safely ignore the paragraph above:-)

Source distributions

If you want to work with the source code and the developer install option (which allows you to embed or extend MacPython) is not good enough you can download the source distribution, which contains everything you need to build and run Python on the mac, but no prebuilt binaries whatsoever. You can pick either of two distributions: The installers live in ftp://ftp.cwi.nl/pub/jack/python/mac, by the way. Our ftp-server is rather picky about IP-addresses (reverse name lookup should work), if you have trouble accessing any of the links here you can also get at the files via the http-server, at url http://www.cwi.nl/ftp/jack/python/mac/.

Note: The version of CWGUSI which is used to build MacPython is no longer distribution by Matthias Neeracher, and the newer CWGUSI 2 has not been tested for use with Python yet. Until this is resolved please use a Python-specific CWGUSI from ftp://ftp.cwi.nl/pub/jack/python/mac/CWGUSI-for-Python152.hqx.

As Corran Webster, cwebster@nevada.edu, reported recently it is not necessary to buy the CodeWarrior C compiler to write MacPython extension modules: in many case Apple's free MPW tools work just fine. See his Compiling Python modules with MPW page for details.

If you want a more recent source distribution than the latest full distribution but you can't use CVS access (see below) for some reason: occasionally I make a dump of the source tree, which you can find in ftp://ftp.cwi.nl/pub/jack/python/mac/SourceDump. The .tgz file is gzipped tar, which you should be able to unpack with StuffIt Expander. You are also responsible for unpacking all ".bin" files yourself, and for setting the creator/type of ".prj" files to CWIE/MMPR. Send me an email if you need a more recent version of this sourcedump, and if enough people bother me I'll make them automatically every night.

CVS Source access

Note:the information in this section is for people who have read the building.html document in the source distribution and decide they want CVS access. You are not expected to understand it (or be interested in it) if you haven't read that document.

The MacPython sources are also accessible through remote CVS, at

CVSROOT: ropython@trawler.cwi.nl:/hosts/mm/CVSREMOTE
Password: geheim
Authentication: pserver
Module: python/Mac
As stated in the building.html document: please use MacCVS from www.wincvs.org, not MacCVS Pro, which does not appear to work with the Python CVS archives.

If you start using the CVS archive please send me a mail at jack@cwi.nl so I have some idea of how many people use it. It is also suggested that you subscribe to the MacPython CVS checkin mailing list.

The CVS repository for the libraries used by MacPython is currently in a flux, it is suggested you just download these in source form, as explained in building.html.

MacOS X

For MacOS X Server you are probably better off with the Unix distribution of Python, get it through the Python website. It is reported to run out of the box, with only some modules (like Tkinter) not working.

Older distributions

Older distributions are still available in ftp://ftp.cwi.nl/pub/jack/python/mac.

Alternative locations

If for some reason you cannot download stuff from here try at the general Python site, www.python.org. Everything should be available there too.

JPython

Another way to run Python programs on your Macintosh is to use JPython, the Python interpreter written in Java. Here is what Bill Dozier, dozier@abs.net, has to say on the subject:
Using JPython now is really very easy. To install, just drop JPython1.1beta4.class onto the JBindery icon (you need the MRJ SDK to do this). They now have it set up so that you can just take the defaults to get InstallAnywhere going. Unfortunately, the save dialog that pops up to ask for the installation location is a little wierd. First of all, it defaults to your Preferences folder. Next, you have to tell it to "open" a file (any file) in the directory where you want JPython installed.

Once you have JPython installed, you will want to make a JBindery app to have double-clickable file for starting the interpreter. Drop the jpython.jar file (from your chosen install directory) onto JBindery. Choose "org.python.core.jpython" for the "Class name" in the first panel. Set both stdin and stdout to be "message window." Click on "Classpath" and make sure jpython.jar is there. If not, you can either drag it in or use the "add .zip file" button to add it to the list. Click on "save settings...", choose "save as application" and you will have an icon that you can double-click to start the JPython interpreter.

To run a script, drop the JPython app you made from the instructions in the previous paragraph onto JBindery. Put the name of the file that you want to run in the "optional parameters" list and make sure that the folder containing your ".py" file is in the classpath (you can just drag your script file onto the list to get it there). Do the "save as application" again and you have a double-clickable icon that will run your script. I do this and then cycle through editing the script with the IDE or CodeWarrior or Alpha and double-clicking this icon to test my code.


[Back to Macintosh software page]

[Back to Jack's homepage]


Jack Jansen, 03-Jan-00