Personal tools
You are here: Home / Carnegie Python Distribution / 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 depending on your version of OSX:
    1. 10.7 (Lion) and 10.8 (Mountain Lion):  start Xcode, select Xcode->Preferences... from the menu, select the Downloads button, select the "Command Line Tools" from the list and click the Install button. For OS X 10.8, you will also have to download/install X-quartz. You can get it from here.
    2. 10.9 and later:  start Xcode. Then, in a terminal, run 'xcode-select --install'. Run the App Store application and upgrade the "Command Line Developer Tools for Mavericks". Download/install X-quartz.
  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).  For Mac users, download the latest from the HPC Mac site.
  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


If you have SVN installed, this is the most convenient way to proceed (it also allows you to keep up-to-date with changes made to our source).  Change directory to the location you want CarPy and run svn:

% cd $HOME
% svn co svn://svn.obs.carnegiescience.edu/CarPy/trunk CarPy

In this example, the source tree will be downloaded to your home folder.  You can put CarPy in any location you wish. The default location in the source distribution is /usr/local/CarPy.

If you do not have svn on your system, 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:

% tar -zxf CarPy_2014-05-02.tar.gz

 

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/Makefile.inc.Linux or CarPy/builds/Makefile.inc.Darwin 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/CarPy
% 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
$HOME/CarPy/builds/CentOS.5.6.x86_64.makes
% cd $HOME/CarPy/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!

Troubleshoothing:


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 X.org).  On the mac, you can install it through fink.
  • 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 CarPy/Setup.csh   # or . CarPy/Setup.bash
    rm -rf $PYTHONBASE
    
    Then start building CarPy again with 'make all'