Making Python Packages

Python packages and wrappers to existing code has become much more prevalent. Many of these packages have a standard build mechanism which is different from the procedure above. The previous mechanism is typical of Fortran/C/C++ code.

The first thing of which to be aware, is that Python versions 2 and 3 are very different.They are almost two different languages.

There are helper applications like pip that make installation easier. However, you can do a manual install if there is a file called setup.py. Below is the standard procdure assuming that are are using python (2.7.6) and you are installing it to your_install_dir. Typically the default location is /usr/local which would require root priviledges.

mkdir your_install_dir/lib/python2.7/site-packages
export PYTHONPATH=$PYTHONPATH:your_install_dir/lib/python2.7/site-packages

python setup.py build
python setup.py install --prefix=your_install_dir

The package dependencies will also be installed e.g. NumPy so it is better to check to see if they are already available. Otherwise there is a possibility that there will be two conflicting versions of the same python package.

Supported By

File Browser Reference
Department FHERIS
University of Galway
HEA Logo