xref: /petsc/src/binding/petsc4py/docs/source/install.rst (revision 8aa39e1bf17a5ea28fa0458095c26b0a3b4f2478)
15808f684SSatish BalayInstallation
25808f684SSatish Balay============
3eaf87d4bSBarry Smith.. _petsc4py_install:
45808f684SSatish Balay
5eaf87d4bSBarry Smith
655a74a43SLisandro DalcinInstall from PyPI using **pip**
755a74a43SLisandro Dalcin-------------------------------
85808f684SSatish Balay
96e8294f6SStefano ZampiniYou can use :program:`pip` to install :mod:`petsc4py` and its dependencies::
105808f684SSatish Balay
116e8294f6SStefano Zampini  $ python -m pip install petsc petsc4py
125808f684SSatish Balay
1355a74a43SLisandro DalcinInstall from the PETSc source tree
1455a74a43SLisandro Dalcin----------------------------------
155808f684SSatish Balay
1655a74a43SLisandro DalcinFirst `build PETSc <petsc:doc_install>`. Next :file:`cd` to the top of the
1755a74a43SLisandro DalcinPETSc source tree and set the `PETSC_DIR <petsc:doc_multi>` and `PETSC_ARCH
1855a74a43SLisandro Dalcin<petsc:doc_multi>` environment variables. Run::
19e079f792SAlexei Colin
2055a74a43SLisandro Dalcin  $ python -m pip install src/binding/petsc4py
21e079f792SAlexei Colin
22cabd1581SStefano ZampiniThe installation of :mod:`petsc4py` supports multiple `PETSC_ARCH
2315229ffcSPierre Jolivet<petsc:doc_multi>` in the form of colon separated list::
24cabd1581SStefano Zampini
25cabd1581SStefano Zampini  $ PETSC_ARCH='arch-0:...:arch-N' python -m pip install src/binding/petsc4py
26cabd1581SStefano Zampini
2755a74a43SLisandro DalcinIf you are cross-compiling, and the :mod:`numpy` module cannot be loaded on
286f336411SStefano Zampiniyour build host, then before invoking :program:`pip`, set the
2955a74a43SLisandro Dalcin:envvar:`NUMPY_INCLUDE` environment variable to the path that would be returned
3055a74a43SLisandro Dalcinby :samp:`import numpy; numpy.get_include()`::
310f51ee0fSAlexei Colin
320f51ee0fSAlexei Colin  $ export NUMPY_INCLUDE=/usr/lib/pythonX/site-packages/numpy/core/include
330f51ee0fSAlexei Colin
346f336411SStefano ZampiniRunning the testing suite
356f336411SStefano Zampini-------------------------
366f336411SStefano Zampini
376f336411SStefano ZampiniWhen installing from source, the petsc4py complete testsuite can be run as::
386f336411SStefano Zampini
396f336411SStefano Zampini  $ cd src/binding/petsc4py
406f336411SStefano Zampini  $ python test/runtests.py
416f336411SStefano Zampini
426f336411SStefano Zampinior via the makefile rule ``test``::
436f336411SStefano Zampini
446f336411SStefano Zampini  $ make test -C src/binding/petsc4py
456f336411SStefano Zampini
466f336411SStefano ZampiniSpecific tests can be run using the command-line option ``-k``, e.g.::
476f336411SStefano Zampini
486f336411SStefano Zampini  $ python test/runtests.py -k test_optdb
496f336411SStefano Zampini
506f336411SStefano Zampinito run all the tests provided in :file:`tests/test_optdb.py`.
516f336411SStefano Zampini
526f336411SStefano ZampiniFor other command-line options, run::
536f336411SStefano Zampini
546f336411SStefano Zampini  $ python test/runtests.py --help
556f336411SStefano Zampini
566f336411SStefano ZampiniIf not otherwise specified, all tests will be run in sequential mode.
576f336411SStefano ZampiniTo run all the tests with the same number of MPI processes, for example
586f336411SStefano Zampini``4``, run::
596f336411SStefano Zampini
606f336411SStefano Zampini  $ mpiexec -n 4 python test/runtests.py
616f336411SStefano Zampini
626f336411SStefano Zampinior::
636f336411SStefano Zampini
646f336411SStefano Zampini  $ make test-4 -C src/binding/petsc4py
656f336411SStefano Zampini
6655a74a43SLisandro DalcinBuilding the documentation
6755a74a43SLisandro Dalcin--------------------------
68e079f792SAlexei Colin
696f336411SStefano ZampiniInstall the documentation dependencies::
705808f684SSatish Balay
71*88386097SStefano Zampini  $ python -m pip install -r src/binding/petsc4py/conf/requirements-docs.txt
725808f684SSatish Balay
7355a74a43SLisandro DalcinThen::
74e8c4a563SAlexei Colin
7555a74a43SLisandro Dalcin  $ cd src/binding/petsc4py/docs/source
7655a74a43SLisandro Dalcin  $ make html
77046f22aeSAlexei Colin
7855a74a43SLisandro DalcinThe resulting HTML files will be in :file:`_build/html`.
79046f22aeSAlexei Colin
8055a74a43SLisandro Dalcin.. note::
810f51ee0fSAlexei Colin
8255a74a43SLisandro Dalcin  Building the documentation requires Python 3.11 or later.
83