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 23If you are cross-compiling, and the :mod:`numpy` module cannot be loaded on 24your build host, then before invoking :file:`pip`, set the 25:envvar:`NUMPY_INCLUDE` environment variable to the path that would be returned 26by :samp:`import numpy; numpy.get_include()`:: 27 28 $ export NUMPY_INCLUDE=/usr/lib/pythonX/site-packages/numpy/core/include 29 30Building the documentation 31-------------------------- 32 33Install the documentation dependencies using the ``[doc]`` extra:: 34 35 $ python -m pip install "src/binding/petsc4py[doc]" 36 37Then:: 38 39 $ cd src/binding/petsc4py/docs/source 40 $ make html 41 42The resulting HTML files will be in :file:`_build/html`. 43 44.. note:: 45 46 Building the documentation requires Python 3.11 or later. 47 48.. note:: 49 50 All new code must include documentation in accordance with the `documentation 51 standard <documentation_standards>`