The installation process should be the same as on Linux. Once you have the C++ QuantLib library installed (instructions for that are on the QuantLib site, at http://quantlib.org/install/macosx.shtml) you can download the latest QuantLib-SWIG release, uncompress it and run:
./configure
make -C Python
sudo make -C Python install
Note that the above work with a release (as in, the files you get from https://sourceforge.net/projects/quantlib/files/) and contrary to popular belief, don't require you to have SWIG installed.
Instead, if you want to work from a checkout of the git repository (either because you want to modify the interfaces, or because you want a new feature which is not yet available in a release) you'll need SWIG—but not a separate command, as make
takes care of it—and you'll also need to run
./autogen.sh
before the other commands; this will require automake and autoconf to be installed. (End of note.)
There are two or three caveats I can think of. The first is that the ./configure
step will need to invoke quantlib-config
to find out what flags should be passed to the compiler and linker (they will also include the additional include directories you might have specified when you built QuantLib, so you'll be covered even if you have, say, Boost in a non-standard place).
This means that quantlib-config
must be in your path.
The second is that, unfortunately, at this time make
ignores any prefix you might pass to ./configure
and always installs to the default location, which requires you to use sudo
as I wrote above. If you don't have admin rights, you'll have to look into the Makefile and pass your prefix to setup.py
.
The third is that you'll need the Python development files (python.h
and so on). They might be available by default (and if they are, make
calls setup.py
which should find them for you); but if not, you'll have to figure out how to get them.
Finally, if you use Docker, you can pull an Ubuntu image with an installation of quantlib-python from https://hub.docker.com/r/lballabio/quantlib-python/.