1Installation 2============ 3.. _petsc4py_install: 4 5 6Install from PyPI using **pip** 7------------------------------- 8 9You can use :program:`pip` to install :mod:`petsc4py` and its 10dependencies (:mod:`mpi4py` is optional but highly recommended):: 11 12 $ python -m pip install mpi4py petsc petsc4py 13 14Install from the PETSc source tree 15---------------------------------- 16 17First `build PETSc <petsc:doc_install>`. Next :file:`cd` to the top of the 18PETSc source tree and set the `PETSC_DIR <petsc:doc_multi>` and `PETSC_ARCH 19<petsc:doc_multi>` environment variables. Run:: 20 21 $ python -m pip install src/binding/petsc4py 22 23The installation of :mod:`petsc4py` supports multiple `PETSC_ARCH 24<petsc:doc_multi>` in the form of colon separated list:: 25 26 $ PETSC_ARCH='arch-0:...:arch-N' python -m pip install src/binding/petsc4py 27 28If you are cross-compiling, and the :mod:`numpy` module cannot be loaded on 29your build host, then before invoking :file:`pip`, set the 30:envvar:`NUMPY_INCLUDE` environment variable to the path that would be returned 31by :samp:`import numpy; numpy.get_include()`:: 32 33 $ export NUMPY_INCLUDE=/usr/lib/pythonX/site-packages/numpy/core/include 34 35Building the documentation 36-------------------------- 37 38Install the documentation dependencies using the ``[doc]`` extra:: 39 40 $ python -m pip install "src/binding/petsc4py[doc]" 41 42Then:: 43 44 $ cd src/binding/petsc4py/docs/source 45 $ make html 46 47The resulting HTML files will be in :file:`_build/html`. 48 49.. note:: 50 51 Building the documentation requires Python 3.11 or later. 52 53.. note:: 54 55 All new code must include documentation in accordance with the `documentation 56 standard <documentation_standards>` 57