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 296f336411SStefano 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 356f336411SStefano ZampiniRunning the testing suite 366f336411SStefano Zampini------------------------- 376f336411SStefano Zampini 386f336411SStefano ZampiniWhen installing from source, the petsc4py complete testsuite can be run as:: 396f336411SStefano Zampini 406f336411SStefano Zampini $ cd src/binding/petsc4py 416f336411SStefano Zampini $ python test/runtests.py 426f336411SStefano Zampini 436f336411SStefano Zampinior via the makefile rule ``test``:: 446f336411SStefano Zampini 456f336411SStefano Zampini $ make test -C src/binding/petsc4py 466f336411SStefano Zampini 476f336411SStefano ZampiniSpecific tests can be run using the command-line option ``-k``, e.g.:: 486f336411SStefano Zampini 496f336411SStefano Zampini $ python test/runtests.py -k test_optdb 506f336411SStefano Zampini 516f336411SStefano Zampinito run all the tests provided in :file:`tests/test_optdb.py`. 526f336411SStefano Zampini 536f336411SStefano ZampiniFor other command-line options, run:: 546f336411SStefano Zampini 556f336411SStefano Zampini $ python test/runtests.py --help 566f336411SStefano Zampini 576f336411SStefano ZampiniIf not otherwise specified, all tests will be run in sequential mode. 586f336411SStefano ZampiniTo run all the tests with the same number of MPI processes, for example 596f336411SStefano Zampini``4``, run:: 606f336411SStefano Zampini 616f336411SStefano Zampini $ mpiexec -n 4 python test/runtests.py 626f336411SStefano Zampini 636f336411SStefano Zampinior:: 646f336411SStefano Zampini 656f336411SStefano Zampini $ make test-4 -C src/binding/petsc4py 666f336411SStefano Zampini 6755a74a43SLisandro DalcinBuilding the documentation 6855a74a43SLisandro Dalcin-------------------------- 69e079f792SAlexei Colin 706f336411SStefano ZampiniInstall the documentation dependencies:: 715808f684SSatish Balay 72*8348cc77SStefano Zampini $ python -m pip install -r ${PETSC_DIR}/doc/requirements.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