Skip to content

Building an OS X Distribution

bwallace edited this page Apr 9, 2012 · 40 revisions

We have moved to using cx-freeze for creating mac builds. Once cxfreeze is built and in your path, the following should do the trick:

cxfreeze path/to/meta_form.py

Be careful to use the correct paths; for whatever reason it complains otherwise. For example, on my laptop:

$ build/scripts-2.7/cxfreeze /Users/byronwallace/dev/OpenMeta-analyst-/meta_form.py

(From $HOME).

This will generate a double-clickable executable (by default in the "dist" directory of whatever directory cx_freeze is in; you can change this using --target=... (I think)). Hurray!

There's also the issue of setting a pointer to (our) R distribution. This can be done using cx-freeze's initscript argument, as follows

byronwallace$ build/scripts-2.7/cxfreeze /Users/byronwallace/dev/OpenMeta-analyst-/meta_form.py --init-script=/Users/byronwallace/dev/OpenMeta-analyst-/open_meta_mac.py

This tells cx_freeze to run open_meta_mac first -- this script sets the R_HOME variable accordingly.

There are other issues. First, the program will try to load dynamic libraries from absolute paths that don't exist on target machines (/opt/local/...), even those the libraries it's trying to load are in the "dist" directory. You can fix this by exporting the environment variable DYLD_LIBRARY_PATH to point to the dist directory, e.g.,

export DYLD_LIBRARY_PATH=/Users/issa/Desktop/dist

This has been moved to the open_meta_mac.py script, like R_HOME. It usually works, however, on some machines it doesn't seem to work for some unknown/frustrating reason. Indeed, in such cases, doing the above at the console and then launching the program does the trick. This should be exactly equivalent to doing it at the console manually. sigh.

In general, sometimes R libraries/packages rely on dylib files. In such cases, make sure you distribute the corresponding files in the dist directory! Otherwise you will get complaints that they don't exist/cannot be loaded.

**Crucially, you need to replace the "libiconv" library in the generated binary -- otherwise you will get "_iconv" errors. More recent versions of this will suffice. I resolved the issue by copying the version on my local machine (dated 6/24/10): this is saved locally in the tellingly named 'use-this-libconv' directory, or look for "libiconv.dylib" and overwrite the current version in the "dist" directory. **

Finally, you'll also need to copy the qtmenu.nib file to the "dist" directory.

To update the R library, build openmetar in the usual way (via console) and install it. then copy the built library to the R_dist directory. This is at:

/Library/Frameworks/R.framework/Versions/2.10/Resources/library

Clone this wiki locally