Installation
============


Requirements
------------

* Python_ 2.4/2.5 distribution [#]_, with Python library preferably
  compiled as a dynamic library.

* NumPy_ package (latest version).

* A working MPI distribution [#]_ for your architecture (e.g., MPICH_ or
  `Open MPI`_), compiled as a dynamic library.

* PETSc_ 2.3.3 distribution (latest patch release).

.. [#] It is highly recommendable to use a parallelized version of the
       Python interpreter.

.. [#] Unless you have appropiatelly configured and built PETSc
       without MPI.


Building
--------

Download and unpack the source distribution::

   $ tar -zxf petsc4py-X.X.X.tar.gz
   $ cd petsc4py-X.X.X

Some environmental configuration is needed to inform the location of
PETSc destribution. You can set (using ``setenv``, ``export`` or what
applies to you shell or system) the environmental variables
``PETSC_DIR`` and ``PETSC_ARCH`` indicating where you have
built/installed PETSc::

   $ setenv PETSC_DIR=/usr/local/petsc-2.3.3
   $ setenv PETSC_ARCH=linux-gnu

Alternatively, you can edit the file ``setup.cfg`` and provide the
required information below ``[config]`` section::

   [config]
   petsc_dir  = /usr/local/petsc-2.3.3
   petsc_arch = linux-gnu
   ...

Finally, you can build this distribution by typing::

   $ python setup.py build


Installing
----------

After building, this distribution is ready for installation. For a
site install type::

   $ python setup.py install

or, in case you need root privileges::

   $ su -c 'python setup.py install'

This will install the ``petsc4py`` package in the standard location
``<prefix>/lib/pythonX.X/site-packages``.

You can also do a user install at your home directory::

   $ python setup.py install --home=$HOME

This will install the ``petsc4py`` package in the standard location
``$HOME/lib/python``. This location should be listed in the
``PYTHONPATH`` environmental variable.
