15808f684SSatish BalayInstallation 25808f684SSatish Balay============ 3eaf87d4bSBarry Smith.. _petsc4py_install: 45808f684SSatish Balay 5eaf87d4bSBarry Smith 655a74a43SLisandro DalcinInstall from PyPI using **pip** 755a74a43SLisandro Dalcin------------------------------- 85808f684SSatish Balay 95808f684SSatish BalayYou can use :program:`pip` to install :mod:`petsc4py` and its 105808f684SSatish Balaydependencies (:mod:`mpi4py` is optional but highly recommended):: 115808f684SSatish Balay 1255a74a43SLisandro Dalcin $ python -m pip install mpi4py petsc petsc4py 135808f684SSatish Balay 1455a74a43SLisandro DalcinInstall from the PETSc source tree 1555a74a43SLisandro Dalcin---------------------------------- 165808f684SSatish Balay 1755a74a43SLisandro DalcinFirst `build PETSc <petsc:doc_install>`. Next :file:`cd` to the top of the 1855a74a43SLisandro DalcinPETSc source tree and set the `PETSC_DIR <petsc:doc_multi>` and `PETSC_ARCH 1955a74a43SLisandro Dalcin<petsc:doc_multi>` environment variables. Run:: 20e079f792SAlexei Colin 2155a74a43SLisandro Dalcin $ python -m pip install src/binding/petsc4py 22e079f792SAlexei Colin 23cabd1581SStefano ZampiniThe installation of :mod:`petsc4py` supports multiple `PETSC_ARCH 2415229ffcSPierre Jolivet<petsc:doc_multi>` in the form of colon separated list:: 25cabd1581SStefano Zampini 26cabd1581SStefano Zampini $ PETSC_ARCH='arch-0:...:arch-N' python -m pip install src/binding/petsc4py 27cabd1581SStefano Zampini 2855a74a43SLisandro DalcinIf you are cross-compiling, and the :mod:`numpy` module cannot be loaded on 29*6f336411SStefano Zampiniyour build host, then before invoking :program:`pip`, set the 3055a74a43SLisandro Dalcin:envvar:`NUMPY_INCLUDE` environment variable to the path that would be returned 3155a74a43SLisandro Dalcinby :samp:`import numpy; numpy.get_include()`:: 320f51ee0fSAlexei Colin 330f51ee0fSAlexei Colin $ export NUMPY_INCLUDE=/usr/lib/pythonX/site-packages/numpy/core/include 340f51ee0fSAlexei Colin 35*6f336411SStefano ZampiniRunning the testing suite 36*6f336411SStefano Zampini------------------------- 37*6f336411SStefano Zampini 38*6f336411SStefano ZampiniWhen installing from source, the petsc4py complete testsuite can be run as:: 39*6f336411SStefano Zampini 40*6f336411SStefano Zampini $ cd src/binding/petsc4py 41*6f336411SStefano Zampini $ python test/runtests.py 42*6f336411SStefano Zampini 43*6f336411SStefano Zampinior via the makefile rule ``test``:: 44*6f336411SStefano Zampini 45*6f336411SStefano Zampini $ make test -C src/binding/petsc4py 46*6f336411SStefano Zampini 47*6f336411SStefano ZampiniSpecific tests can be run using the command-line option ``-k``, e.g.:: 48*6f336411SStefano Zampini 49*6f336411SStefano Zampini $ python test/runtests.py -k test_optdb 50*6f336411SStefano Zampini 51*6f336411SStefano Zampinito run all the tests provided in :file:`tests/test_optdb.py`. 52*6f336411SStefano Zampini 53*6f336411SStefano ZampiniFor other command-line options, run:: 54*6f336411SStefano Zampini 55*6f336411SStefano Zampini $ python test/runtests.py --help 56*6f336411SStefano Zampini 57*6f336411SStefano ZampiniIf not otherwise specified, all tests will be run in sequential mode. 58*6f336411SStefano ZampiniTo run all the tests with the same number of MPI processes, for example 59*6f336411SStefano Zampini``4``, run:: 60*6f336411SStefano Zampini 61*6f336411SStefano Zampini $ mpiexec -n 4 python test/runtests.py 62*6f336411SStefano Zampini 63*6f336411SStefano Zampinior:: 64*6f336411SStefano Zampini 65*6f336411SStefano Zampini $ make test-4 -C src/binding/petsc4py 66*6f336411SStefano Zampini 6755a74a43SLisandro DalcinBuilding the documentation 6855a74a43SLisandro Dalcin-------------------------- 69e079f792SAlexei Colin 70*6f336411SStefano ZampiniInstall the documentation dependencies:: 715808f684SSatish Balay 72*6f336411SStefano Zampini $ python -m pip install -r src/binding/petsc4py/conf/requirements-docs.txt 735808f684SSatish Balay 7455a74a43SLisandro DalcinThen:: 75e8c4a563SAlexei Colin 7655a74a43SLisandro Dalcin $ cd src/binding/petsc4py/docs/source 7755a74a43SLisandro Dalcin $ make html 78046f22aeSAlexei Colin 7955a74a43SLisandro DalcinThe resulting HTML files will be in :file:`_build/html`. 80046f22aeSAlexei Colin 8155a74a43SLisandro Dalcin.. note:: 820f51ee0fSAlexei Colin 8355a74a43SLisandro Dalcin Building the documentation requires Python 3.11 or later. 84