How to build PyNIO 1.4.1 from source code

PyNIO 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, and IBMs running AIX (64-bit).

This version of PyNIO was tested with Python versions 2.6.x and 2.7.x, and NumPy versions 1.5.1 and 1.6.0. We have some precompiled binaries you can try.

PyNIO has a number of file formats that it supports for reading and/or writing. Some of these file formats are required, and some are optional:

For more information on these formats, see the main PyNIO page.


Table of Contents


Download and build non-optional external software

The software listed below is not optional if you plan to build PyNIO. Some of this software may already be installed on your system. You can use the "locate" command to find it.

Once you download and install any external software to use with PyNIO, you must comply with the license of that software, regardless of what PyNIO's license is.

HDF-EOS 2 software

If you need support for reading HDF-EOS 2 files, then you will need to download and install the following packages:

HDF-EOS 5 software

If you need support for reading HDF-EOS 5 files, then you will need to download and install the following packages:


Download the source code for PyNIO

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

To download the PyNIO source code, follow the instructions at:

http://www.pyngl.ucar.edu/Download/
The source code you download will be a single compressed tar file called something like "PyNIO-1.4.1.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 PyNIO-1.4.1.tar.gz
  tar -xvf PyNIO-1.4.1.tar
The above steps will create a directory called "PyNIO-1.4.1".


Set environment variables if necessary

To build PyNIO, you may need to set some environment variables.

First, you need to set one or more of the following environment variables to "1" if you build this software package and want to include it in PyNIO:

  setenv HAS_GDAL 1
  setenv HAS_GRIB2 1
  setenv HAS_HDFEOS 1
  setenv HAS_HDFEOS5 1

In addition, if NetCDF was built with "classic" NetCDF-4 support:

  setenv HAS_NETCDF4 1

In addition, if NetCDF was built without OPeNDAP support:

  setenv HAS_OPENDAP 0

Furthermore, to help PyNIO locate the installed software, you must set the corresponding environment variables to the root directory of that installed software:

  GDAL_PREFIX
  GRIB2_PREFIX
  HDFEOS_PREFIX
  HDFEOS5_PREFIX
  NETCDF_PREFIX
You only need to set one of these if the paths are all the same.

Finally, you may need to help the PyNIO 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, "-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 PyNIO. To test PyNIO, see the "test PyNIO" section.

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.


Test PyNIO

To quickly test if PyNIO can be imported without errors, type "python" at the UNIX prompt and then "import Nio" at the python prompt. You should get the python prompt back with no errors.

To more thorougly test PyNIO, cd to the "test" directory and execute one of:

  ./test2.6.sh

or

  ./test2.7.sh

depending on whether you are using Python 2.6.x or 2.7.x.

The output will be sent to a file called "test.yyyy-mm-dd.py2n" which you can compare with the "test_compare" file.

You can further test PyNIO by installing PyNGL and running some of the examples available through pynglex.


Where to get help

If you are having problems building or installing PyNIO, send email to pyngl-talk@ucar.edu. You need to be a member in order to post.