How to do a Mac OSX 10.2, 10.3? native Aqua interface VTK build and get MayaVi working with it. (Not an X11 build) Step1)
This document is mutated from instructions by Karl Garsha on the MayaVi users list 5th Sept 2003, with additional information from Adrian Umpleby, and written up after some trial and error by Dan White 21st October 2003. Edited and added to Wiki on 23012004. Information on OSX 10.3 (Panther) added by David M. Cooke on 20040309.
This guide intends to enable the novice UNIX and VTK user to get MayaVi working on MacOSX 10.2 Jaguar and 10.3 Panther.
Update your operating system to 10.2.8 (just for good measure). Find the MacOSX 10.2 Jaguar Developer tools cd that came with your MacOSX 10.2 Jaguar operating system. Or go to the apple website, click on developer, register, then go to downloads, then developer, and download the Dec 2002 developer tools. (You could also get the august 2003 gcc 3.3 updater for G5 support, but I have used the gcc3.1 compiler on the Dec 2002 developer tools on a G4 and a G3, no problem). Read the instructions and install the developer tools (and the gcc3.3 updater, not tested though). (For 10.3, update with software update, and make sure developer tools are installed)
Step2)
MayaVi uses the Python virtual machine and a graphical user interface system for Python called Tkinter. You also need Tcl/tk for scripting and the GUI etc.
You can get the latest Tcl/Tk8.4.4 installation package from (download and install the !TclTkBI-8.4.4.0.dmg)
http://www.maths.mq.edu.au/~steffen/tcltk/TclTkAqua/ You need the Batteries Included !TclTkBI version, not the other ones.
The latest macPython installation (2.3 binary installer for OSX 10.2) available at
http://homepages.cwi.nl/~jack/macpython/download.html the Apple version of python won't do, nor the fink version. (For 10.3, apple included most of MacPython into the operating system, but you still need the Panther MacPython, to get _tkinter, see below!)
Install both the MacPython2.3 and !TclTkBI packages.
Step3)
After installing Tcl/Tk and macPython2.3 you will need to edit your ~/.cshrc file to add /usr/local/bin to your $PATH environment variable. If you don't know what I'm talking about, do this: In Finder go to Applications/Utilities. There is an application caller Terminal. Double click it, and behold the wonderful world of the UNIX command line interface. A whole new and exciting world awaits you..... In your home directory, the one where you are when the terminal starts up (probably something like /Users/yourname/ you can check by typing pwd), type pico .cshrc This enters the pico text editor, you can move around with the cursor keys, and type stuff. Add a line like setenv PATH /usr/local/bin:/usr/bin:/usr/sbin:/bin:/sbin:$PATH Add another line: setenv MACOSX_DEPLOYMENT_TARGET 10.2 press ctrl-X and then y to save and exit. Type source .cshrc This reads the file you just edited and executes the commands that are in it. The .cshrc file is where you can keep things like your personal aliases and environment variables.
On Panther, you'll need to edit ~/.bashrc. To add /usr/local/bin to PATH, add export PATH=/usr/local/bin:$PATH You don't need to add the MACOSX_DEPLOYMENT_TARGET. Close and reopen your terminal window (or source ~/.bashrc).
Next, you'll need to get Tkinter. Using the Finder, go into /Applications/MacPython-2.3 and double click the PackageManager. This will open an interface through which you can simply download the Tkinter module. (I installed all the other binaries too, except wxPython.) highlight _tkinter and click on install.
Step4)
After this, all the dependencies (stuff you need) should be in place to download and install VTK. You will need to get the latest development version of VTK from CVS. The normal archived VTK package won't work on OS X with Python2.3, yet.
To do this, go to the command line in Terminal (you need to be connected to the internet), cd to the directory you want to download VTK to (eg. mkdir /Applications/VTK , cd /Applications/VTK) and then follow the instructions at
http://public.kitware.com/VTK/get-software.php#cvs
Step5)
At the VTK site you were told to get cmake...
Note, Firstly I used the Darwin command line version of cmake, but then realised that the interactive version ccmake is of course much better! So use ccmake.
You need cmake-1.8.1-darwin.tar, download this from
http://www.cmake.org/HTML/Download.html double click on it to decompress it. read the README in the newly created folder, then double click on the archive in the new folder to extract the cmake stuff with Stuffit expander.. Stuffit annoyingly adds "Folder" to the end of the new directory name. Rename the extracted folder in Finder to get rid of the "Folder" on the end. Move the renamed "cmake-1.8.1-darwin-files" folder to /usr/local. (You might not be able to do it in the finder, as unless you have played with your system these directories do not show up in the finder). In Terminal:
sudo mv cmake-1.8.1-darwin-files /usr/local
you will be prompted for the admin/login/root password, enter it, press return.
cd to the VTK directory you just did the VTK CVS download, and type ccmake . at the command line in the terminal (yes, that is 2 "c"s, and the . is required, as it will tell you if you don't use it!). A bunch of checks are done and some files are written.
Now to use the arrow keys and enter (to toggle ON / OFF) for shared ON, hybrid ON, Tcl ON and Python ON. Use X11 should be OFF (this is an Aqua build). Also, set USE_CARBON to ON, and USE_COCOA to OFF (Tcl/Tk uses the Carbon API).
Check the compiler flags. Press t to get the advanced options, then look at CMAKE_BUILD_TYPE, which selects the group of flags to use. You probably want to set this to Release. If it's set to nothing, no optimizations wil be used.
Now press c to configure. Keep pressing c until the lines at the top of the window no longer have an * before them. (this should only take 2 or 3 times) Again, more compiler checks, and more files are written which will guide the compilation process. When you have no more lines starting with * press g to generate all the make files etc. the ccmake prog will exit.
Now type make and all the VTK stuff is compiled/built etc. This can take several hours, (so go for a walk or perhaps to the pub).
After doing this, type sudo make install and then give your admin/root password to continue. The libraries should be installed into /usr/local/lib/vtk, headers in /usr/local/include/vtk, and a few programs in /usr/local/bin.
Now the compiled libraries and executables are being put in the correct places (well.. most of them, see later)
After the VTK libraries are installed, you need to install the python wrapped modules. Go into the Wrapping/Python directory (cd Wrapping/Python). Type sudo python2.3 setup.py install this will install the python wrapping stuff necessary to run MayaVi.
Step6)
Finally, you'll need to download MayaVi from the CVS snapshot
http://av.stanford.edu/~prabhu/download/mayavi/. Decompress it using stuffit expander, and cd to the mayavi directory.
(or for the actual CVS version: Quote MayaVi sourceforge CVS "This project's SourceForge.net CVS repository can be checked out through anonymous (pserver) CVS with the following instruction set. The module you wish to check out must be specified as the modulename. When prompted for a password for anonymous, simply press the Enter key. To determine the names of the modules created by this project, you may examine their CVS repository via the provided web-based CVS repository viewer." So, In the terminal, mkdir MayaVi in /usr/local or /Application or where ever you want to put the MayaVi download. then do
cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/mayavi login
password is "anonymous", then
cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/mayavi co mayavi)
cd into the newly downloaded MayaVi source tree, where you can find the mayavi file (use ls to see directory contents), in the terminal type
sudo python2.3 setup.py install
give your admin/root password, and you should be all set.
Step7)
To run Tkinter apps on OSX Aqua, you need to use the special pythonw script (which uses the GUI version of python).
To test things out type something like pythonw /Applications/MayaVi/doc/test_vtk.py use the correct path for wherever your MayaVi was downloaded to. Note! Use "pythonw" (not "python" or "python2.3")
Some dialog boxes should pop up, click OK on them. Then a window will appear with a blue cone in it, which you can interact with using the mouse. (If the cone doesn't appear click and drag in the window and it should suddenly appear) Now is a good time to find a 3 button USB mouse. (Note, logitech mouse wheel buttons seem to work but the wheel button is the "right click" and the right button is the "middle click". Make sure usb overdrive is not installed or not interfering. No need to use the logitech software either, OSX should just use it natively..hopefully). Press q to quit. You might need to force quit python (alt-apple-esc) as it doesn't seem to quit cleanly.
Step8)
Run MayaVi from your /VTK/bin directory with a command like this (use the correct mayavi path) pythonw /Applications/MayaVi/mayavi
The MayaVi GUI should launch and you can now load your data and visualise it.
Good luck!
MayaVi Wiki