Personal tools
You are here: Home / CarPy / Building CarPy from source

Building CarPy from source

If a suitable binary package is not available for your system (or you need to install CarPy in a location other than /usr/local/CarPy), then you will have to build CarPy from source.  We have tried to make this as painless as possible by writing several makefiles for each CarPy sub-package.  In brief, you must download the source, edit the top-level Makefile to reflect your system, then run make.

1.  Pre-requisites.

Make sure you run CarPy in as clean an environment as possible. Other python distributions like Anaconda, Ureka, and scisoft are known to interfere with building from source. Disable all such environments in your startup scripts (.tcshrc, .bash_profile, etc) before using CarPy,.

To build CarPy, you will need the following software/libraries:

  1. C compiler, make utils.  For OSX users, make sure you have installed the latest Xcode.  You can download it for free (after registration) at the ADC. Or use the Apple Store application (for OS X 10.6 and above). There are also extra steps:
    1. In a terminal, run:
      xcode-select --install
    2. Install needed compilers and buil utilities using homebrew:
      brew install gcc automake autoconf libtool mesa
      Also, download/install latest X-quartz. You can skip 2. and 3. below.
  2. a FORTRAN compiler.  We strongly recommend the GNU fortran compiler (gfortran).  For Linux users, install using your system's package installer (yum, rpm, etc). 
  3. The Automatically Tuned Linear Algebra Software (ATLAS) package.  For Mac users, this is already installed on the system.  For Linux users, install using your system's package manager.  You can also build it from source (to get the very best performance or to install in a custom location), but this is a very lengthy process and is not for the faint of heart.

During the build process, you may encounter compiler errors having to do with missing header files.  This is most commonly encountered on Linux systems, where the dynamic libraries are packaged separately from the header files and static libraries (the *-devel RPMs).  If you encounter such an error, try to figure out which devel RPM is missing and install it.

2.  Download the CarPy Source

You can download a static tarball of the latest source release from here.  Then change to folder in which you wish to install CarPy and un-tar. For example:

% tar -zxf CarPy3src.tgz


3. Modify the Setup scripts and Makefile


Once you have the source unpacked, go to the CarPy folder.  There, you will find several startup scripts (Setup.bash, Setup.csh, and carpy).  If you put CarPy somewhere other than /usr/local/CarPy and want to use Setup.bash or Setup.csh, then you must edit them and change the environment variable PYPREFIX to point to CarPy's location.

Likewise, you may have to edit the CarPy/builds/ or CarPy/builds/ and change the PYPREFIX variable there.

Next, source the appropriate Setup script (or run carpy script to start a tcsh subshell).  Once you have done that, go to the builds folder and determine where your makefiles need to be.  As an example:

% cd $HOME/CarPy3
% source Setup.csh
% cd builds
% echo $MAKES

The result of the 'echo $MAKES' will be where CarPy expects to find the makefiles for the CarPy sub-packages.  For example, on a 64-bit Redhat Fedora 8 system, the makes would be located in:   $HOME/CarPy/builds/Fedora.8.x86_64.makes.  Likely, this folder will not exist.  In that case, you should look in the builds folder for a system/architecture that is close to your own and copy it to where CarPy expects it.  For example, if you were on a CentOS 5.6 64-bit system, you might try using the Fedora Core 13 x86_64 folder:

% echo $MAKES
% cd $HOME/CarPy3/builds
% cp -r Fedora.13.x86_64.makes $MAKES

Now that the makefiles are in the proper place, you can continue on to building CarPy.

4. Building CarPy

Go to the builds folder and type 'make all'.  If the gods are with you, the build will proceed without fatal error (you will see lots of warning messages which you can probably ignore) and you'll be done!  But in the likely event that something goes wrong, here is an explanation of what's going on and some tips.

The master Makefile is trying to build each sub-package in turn using the *.make files located in $MAKES.  Each time it does so, it creates a stub file to keep track of where it is (in case the build fails and you have to restart the make process, it will pick up from where it left off).  You can find these stub files in $BUILDS.  For each package, there will be the following files:  setup-<package>, build-<package>, install-<package> and clean-<package>.   If, for any reason, you need to re-build the package, you will have to remove these files.

If the build fails while making a particular package, the un-packed source will be located in the $BUILDS folder.  If the source of this package needs to be patched for any reason, you can do it there, and then try 'make' again.  But if possible, consider doing any necessary patching in the <package>.make file.  That way, if you ever have to re-build, it will go through without needing to be re-patched.

5. Donate your Build

Once you have successfully build CarPy for your OS/Architecture, please consider donating your binary build and $MAKES folder so that others can benefit from your pain and suffering.  Simply issue a 'make packages' command in the builds folder and send us the binary tar files that result.  Thanks!


Here are some tips regarding the building process.  Each OS has it's own peculiarities, so it's impossible to foresee every glitch ahead of time.

  • The build process halts with tons of error messages about undefined functions, but if you scroll up far enough, you find an error about not being able to find an include (*.h) file.  Likely, in this case you need to install the appropriate -devel RPM.
  • Error about not being able to find xmkmf (especially on Macs).  Seems xmkmf is no longer part of X11 (at least  On the mac, you can install it through homebrew:  brew install imake
  • There is a problem detecting the gfortran compiler or running it, even though you have it installed.  Make sure that you don't have an F77 environment variable set.  IRAF is notorious for setting this to some shell script deep down in the iraf tree.  Unset it, or set F77=gfortran
  • Build fails during setuptools with "Compression requires the (missing) zlib module". If you encounter this, you need to install the zlib (and zlib-devel) RPM. But then you have to re-build python as well, to get the zlib module. Easiest way to do that is simply run:
    source CarPy3/Setup.csh   # or . CarPy3/Setup.bash
    rm -rf $PYTHONBASE
    Then start building CarPy again with 'make all'