ActiveGrid on Mac OS X

This HOWTO is to let those who are using Mac OS X operating system to use ActiveGrid
in a similar way to those with MS Windows and Linux. Although ActiveGrid was originally
available on the Mac platform, that has since changed with 2.x series. So what was the
big changes that caused this falling away, particularly when the application is based
around the Python language which is platform independent.

The main issues that appeared in 2.x that caused issues with the Mac platform was:

1. Python version was upgraded to 2.4 and used features only available in this version.
This meant that because Apple does not upgrade the system Python (still 2.3) very
frequently, the Python capabilities were not available;

2. Also, the frameworks used by ActiveGrid changed slightly under the Mac platform
with the Carbon library taking precedence with more mature libraries.

So how can we get around these 2 major issues? The procedure is relatively easy.

1. Update to Python2.4.

This could be done a number of ways, but so far only one method worked for me.

a. Using the FINK package management system.
Does not support Apple Framework build. Will only work in X11.
b. Updating from an Apple download.
Have not seen a release at time of writing.
c. Use the package available on www.python.org.

To follow the python.org method, the package for MacOS X 10.3 and later was:
python-2.4.4-macosx2006-10-18.dmg. This is a Universal installer so it should
work for either PPC or Intel-based machines.

$> curl http://www.python.org/ftp/python/2.4.4/python-2.4.4-macosx2006-10-18.dmg \
-o python-2.4.4-macosx2006-10-18.dmg

Open the image and let it mount.
Copy it to appropriate location.

Note: Make sure the package you install has a version of pythonw. If it does not have
the pythonw program, it will not work with the Mac system properly.

2. Upgrade to wxPython2.6

This can be obtained from the www.wxpython.org site.

$> curl http://prdownloads.sourceforge.net/wxpython/wxPython2.6-osx-ansi-2.6.3.3...
-o wxPython2.6-osx-ansi-2.6.3.3-universal10.4-py2.4.dmg

Note: There is a later package for wxPython2.8, but I have found that is causing too
many issues at time of writing. This may change with later versions of ActiveGrid,
but currently it is recommended for the 2.6 version.

3. Changes to code to fix old frameworks.

a. Get rid of the old macfs modules.

$> cd eng-dev/src/python/activegrid/utils/
$> vi appdirs.py

Go to line around line 50 and you will see to lines loading the macfs modules:

import macfs
import MACFS

Changes these to be:

import Carbon.File
import Carbon.Folder

b. Change where macfs is used in the code.

Still in appdirs.py, change the lines:

fsspec_disk, fsspec_desktop = macfs.FindFolder(MACFS.kOnSystemDisk, MACFS.kDocumentsFolderType, 0)
path = macfs.FSSpec((fsspec_disk, fsspec_desktop, '')).as_pathname()

they then become:

fsspec_disk, fsspec_desktop = Carbon.Folder.FindFolder(Carbon.File.kOnSystemDisk, Carbon.File.kDocumentsFolderType, 0)
path = Carbon.File.FSSpec((fsspec_disk, fsspec_desktop, '')).as_pathname()

4. Install the ZSI package.

$> tar zxvf ZSI-2.0-rc3.tar.gz
$> cd ZSI-2.0-rc3
$> python setup.py build
$> scp ./build/lib/ZSI /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/site-packages/

Note: Alternatively you could add the ZSI path (./build/lib/ZSI) to your PYTHONPATH environment variable.

5. Setup the logging directory.

$> cd eng-dev
$> cd src
$> cd python
$> mkdir logs

6. Test it out.

$> pythonw ActiveGridLAMPStudio.py

Check the output.

It if works, you should get a warning about logging and information that a web server has been run on a particular port on the local machine. Then the application will popup and be ready to use if all has gone well.

Troubleshooting
---------------

Q. ActiveGrid runs okay, but I can't seem to exit properly - the Quit option is always greyed out?
A. You are using the 'python' command instead of 'pythonw'. Try running it again using the 'pythonw' command instead and that should work. If it does not, it is because you are using a version of Python that does not support Apple's framework. Install a different Python packages.

Q. Can't I get it in a nice disk image (.dmg) package?
A. Certainly not at the moment. I may look at doing this at some point, but I don't have time to see how that is done and organise it. Hopefully someone else can use this HOWTO to generate a .dmg that people could use?

This HOWTO will be monitored at my website to keep track of any known issues or problems.
The url is http://www.cybersite.com.au/activegrid/mac_howto

Feel free to send comments or known problems that you may experience.

Author: Jonathon Coombes (jon@cybersite.com.au)

Noticed that Leopard has by Geert (not verified)