How to build PyNGL from source code

PyNGL can only be built on UNIX systems. It has been successfully built on systems running Linux (32 or 64-bit), MacOSX (PPC or Intel), Windows/Cygwin, Suns using native compilers, IBMs running AIX (32 or 64-bit), and SGIs running IRIX.

This document covers what external software packages you need for PyNGL and how to build them, and then finally how to build PyNGL.

For information on building PyNIO from source code, see the "build PyNIO from source code" document.


Install C and Fortran compilers

You need to have an ANSI C and a Fortran 77 or Fortran 90 compiler. If you are on a MacOS, Cygwin, or Linux system, "gcc" and "gfortran" should work just fine. We've known "g95" to work as well.

Usually the gcc compiler comes with your system, sometimes as an optional install. For example, with the Macs, it's available as part of the developer's tool kit.

The gfortran compiler can be downloaded from http://gcc.gnu.org/wiki/GFortran.


Download and build external software

Once you download and install any external software to use with PyNGL, you must comply with the license of that software, regardless of PyNGL's source code license.

List of external software to install:


Download the source code for PyNGL

Accessing, downloading, and/or using PyNGL implies acceptance of the PyNGL source code license.

To download the PyNGL source code, follow the instructions at the URL:

http://www.pyngl.ucar.edu/Download/
The source code you download will be a single compressed tar file called something like "PyNGL-1.3.0b1.tar.gz". Move this file to a temporary directory where you have plenty of disk space (around 250 megabytes to hold all of the source code, object files, binaries, and so on). Then, uncompress and untar the file as follows:

  gunzip PyNGL-1.3.0b1.tar.gz
  tar -xvf PyNGL-1.3.0b1.tar
The above steps will create a directory called "PyNGL-1.3.0b1".


Set environment variables if necessary

To build PyNGL, you must set the NCARG_ROOT environment variable to the root directory of where NCL was installed.

To help PyNGL locate the png and zlib software, you may need to set the corresponding environment variables to the root directory of that installed software:

PNG_PREFIX
ZLIB_PREFIX
You only need to set one of these if the paths are all the same.

You may need to help the PyNGL installation find the location of any system Fortran libraries needed to resolve symbols between C and Fortran code. For example, "-lgfortran" is needed if you built the software with gfortran, or "-lg2c" if g77 was used, and "-lf95" for g95. Use F2CLIBS to indicate the library name (don't include the "-l", and F2CLIBS_PREFIX to point to the location. For example:

setenv F2CLIBS gfortran
setenv F2CLIBS_PREFIX /usr/local/lib


Execute the 'setup.py' script

Type:
python setup.py install
to build and install PyNGL. Go back to the "test software" section in the download section for information on testing PyNGL.

If you have problems, send email to pyngl-talk (you must be a member to post). We will add a trouble-shooting guide once we see what kind of problems people have.