Deployment for Mac Os X » History » Version 13

« Previous - Version 13/15 (diff) - Next » - Current version
pospelov, 02 Nov 2015 16:34

Deployment for Mac Os X

How to create dmg package

1. Before you build BornAgain, ensure that you do not have the 'library ambiguity'. If you have installed BornAgain libraries, they should not be in the DYLD_LIBRARY_PATH. Also ensure that QTDIR environment variable is correctly defined.
2. run cmake with an option -DBORNAGAIN_APPLE_BUNDLE=ON


Important fix for numpy library.

The problem is that Anaconda comes with numpy library which is older, then from MacPorts or Hombrew. It means, that the package compiled against our /opt/local (MacPorts) or /usr/local) Homebrew will not be possible to install into /Users/username/anaconda/lib/python2.7/site-packages.

The solution:
Install anaconda, compile BornAgain against both, /opt/local and /anaconda as shown below

cmake -DCMAKE_PREFIX_PATH="/Users/pospelov/anaconda;/usr/local" -DBORNAGAIN_APPLE_BUNDLE=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=../installed ../source

3. make -j4
4. cpack or cpack -V (if you want it verbose)
5. Rename: mv BornAgain-1.0.0-macosx64.dmg into BornAgain-1.0.0-macosx64-10.9+.dmg

cpack calls fixup_bundle utility which copies libraries to the bundle and calls install_name_tool to fix the path coded inside the library file.
dmg package created on Maverics will work only on mavericks. To deploy for other target system is also possible, but in this case all the libraries on which BornAgain depends must be recompiled.

Structure of the Mac Os X bundle.

For mac os x users BornAgain can be distributed as a mac os x bundle packed into the dmg package. Mac os x bundle for BornAgain has the following structure:
|-- Contents
|---- Frameworks
|     > Qt libraries
|---- MacOs
|     > BornAgain GUI (executable)
|---- Resources
|     > Application icon
|---- PlugIns
|     > Qt plugins
|---- bin
|     > links to executable scripts
|---- include
|     |-- BornAgain-0.9
|         > all our headers
|---- lib
|     |-- BornAgain-0.9
|     |   > libBornAgainCore, libBornAgainFit
|     |-- ThirdParty
|     |   > boost and Co
|     |-- LibPython
|         > libpython2.7.dylib
|---- libexec
|     |-- BornAgain-0.9
|         > executable modules
|---- share
|     |-- BornAgain-0.9
|         > examples, icons

How to install BornAgain from dmg package

Step 1: double click on the dmg package to unpack it.
Step 2: accept the license agreement.
Step 3: drag the BornAgain app to the Applications folder (or any other folder where do you like to have it)
Step 4: double click on the BornAgain app to run it.

You may also skip the step 3 and run BornAgain app directly from the package.

How to install libBornAgainCore, LibBornAgainFit libraries into your Python

It is possible now to install libraries which came with bundle into site-packages of your Python.

To do it run

sudo python /Applications/

and follow the instructions. 'sudo' is necessary if you want to place BornAgain libraries in python located in /opt/local.
If it is Anaconda Python, which resides normally in /Users/yourname/anaconda, the command will be

~/anaconda/bin/python /Applications/