Last modified 20 months ago Last modified on 08/24/12 11:25:20

Building PyGAMMA


We'd like to provide prebuilt binaries for every platform, but that's not practical given the variety of operating systems, Python versions and architectures (32/64 bit) out there. Some of you will have to build the PyGAMMA binaries yourself.

If you need a custom PyGAMMA, the process to build and install it is quite simple but the setup can take some time. Once the setup is complete, the build and install takes four steps --

  1. Change to the appropriate directory for your platform (e.g. cd ~/gamma/platforms/Linux)
  2. Build (for all non-Windows platforms, make pysgdist)
  3. Change to the pygamma directory (cd ../../pygamma or cd ~/gamma/pygamma)
  4. Run (python install or sudo python install)

These steps and the setup for them are explained in detail below for building PyGAMMA on Windows, Unix and Unix-like platforms.

Building PyGAMMA (All Platforms)

Build Prerequsities (All Platforms)

First you'll need to follow the instructions for downloading the code. Once you've done that, continue with the next paragraph.

You'll need Python, a compiler (see below) and a tool called SWIG. We've had success with SWIG versions 1.3 through 2.0.

Building Binaries on Unix[-Like] Platforms (OS X, Linux, etc.)

Prerequsities (Unix[-Like] Platforms)

In addition to Python and SWIG, you'll need the gcc compiler. This build should work with any 4.x version of gcc.

Under OS X, download the XCode/Developer Tools package to get make and gcc.

Linux users, in addition to installing the packages gcc (and possibly gcc-c++), you might also need to install the development package for your version of Python. If the build complains that Python.h is missing, you need to install a package called something like python-dev.

If you're not on OS X, you might want to consider installing an optimized linear algebra library before building, although this is not essential and will complicate the build. OS X already has such a library installed, and PyGAMMA can take advantage of it.

The Build (Unix[-Like] Platforms)

Once you have the prerequisites installed, go to a command line and then change to the gamma/platforms directory. Once there, change into the subdirectory appropriate for your platform. Then, execute this command --

make pysgdist

That will build PyGAMMA and place the relevant build output files in a place where can find them. When this process completes, you're ready to run as explained above.

Building Binaries on Windows

Prerequsities (Windows)

In addition to Python and SWIG, you'll need the free C++ compiler Visual Studio Express Edition 2008.

The Build (Windows)

  1. Find the file gamma/platforms/msvc2008e/dynamic/gamma.sln and double click on it to open Visual Studio.
  2. Ensure that python.exe is in your PATH.
  3. Either ensure that swig.exe is in your PATH, or edit the build properties to supply an explicit path to swig.exe on your machine.

If you opt for the latter, open the Visual Studio Project-->Properties menu. Then select Configuration Properties --> Build Events --> Pre-Build Events and then edit the Command Line property. Change "swig" to an explicit path. The result will look something like this:

"C:\Program Files\swigwin-2.0.0\swig.exe" -c++ -python -outdir ..\..\i686-pc-msvc  -I..\..\src -o ..\..\i686-pc-msvc\pygamma_wrap.cxx pygamma.i
  1. Hit F7 to start the build.

The steps above will build PyGAMMA and place the relevant build output files in a place where can find them. When this process completes, you're ready to run as explained above.

Potential Windows Build Problems

The build may fail if built in debug mode due to a SWIG quirk and the lack of Python debug library. If you get an error like this --

LINK : fatal error LNK1104: cannot open file 'python25_d.lib'

You can work around this by building PyGAMMA in Release mode. In Visual Studio at the top of the screen, just beneath the menus, you can find a drop down that offers a choice between Release and Debug. Alternatively, you can select the Build-->Configuration Manager menu item. Visual Studio will display the Configuration Manager dialog. Under Active Solution Configuration, select Release. Close the dialog and rebuild.

Installing PyGAMMA After a Build (All Platforms)

Installing after a build works just the same as if you were using prebuilt binaries. Just follow the installation instructions above.

Testing PyGAMMA (All Platforms)

Once PyGAMMA is installed, you can run an automated test under any Unix-like operating system from the command line. Change directory to gamma/platforms and then move into the appropriate platform (Linux, OSX, etc.). From there, execute make pytest.

This runs the tests in gamma/src/pyTest. You can also run the .py files there manually.

Under Windows, you can run the automated tests from within Visual Studio. Right click on the pytest project and build it to run all the tests in the gamma/trunk/src/pyTests directory.