1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
Installation
============
.. _petsc4py_install:
Install from PyPI using **pip**
-------------------------------
You can use :program:`pip` to install :mod:`petsc4py` and its dependencies::
$ python -m pip install petsc petsc4py
Install from the PETSc source tree
----------------------------------
First `build PETSc <petsc:doc_install>`. Next :file:`cd` to the top of the
PETSc source tree and set the `PETSC_DIR <petsc:doc_multi>` and `PETSC_ARCH
<petsc:doc_multi>` environment variables. Run::
$ python -m pip install src/binding/petsc4py
The installation of :mod:`petsc4py` supports multiple `PETSC_ARCH
<petsc:doc_multi>` in the form of colon separated list::
$ PETSC_ARCH='arch-0:...:arch-N' python -m pip install src/binding/petsc4py
If you are cross-compiling, and the :mod:`numpy` module cannot be loaded on
your build host, then before invoking :program:`pip`, set the
:envvar:`NUMPY_INCLUDE` environment variable to the path that would be returned
by :samp:`import numpy; numpy.get_include()`::
$ export NUMPY_INCLUDE=/usr/lib/pythonX/site-packages/numpy/core/include
Running the testing suite
-------------------------
When installing from source, the petsc4py complete testsuite can be run as::
$ cd src/binding/petsc4py
$ python test/runtests.py
or via the makefile rule ``test``::
$ make test -C src/binding/petsc4py
Specific tests can be run using the command-line option ``-k``, e.g.::
$ python test/runtests.py -k test_optdb
to run all the tests provided in :file:`tests/test_optdb.py`.
For other command-line options, run::
$ python test/runtests.py --help
If not otherwise specified, all tests will be run in sequential mode.
To run all the tests with the same number of MPI processes, for example
``4``, run::
$ mpiexec -n 4 python test/runtests.py
or::
$ make test-4 -C src/binding/petsc4py
Building the documentation
--------------------------
Install the documentation dependencies::
$ python -m pip install -r ${PETSC_DIR}/doc/requirements.txt
Then::
$ cd src/binding/petsc4py/docs/source
$ make html
The resulting HTML files will be in :file:`_build/html`.
.. note::
Building the documentation requires Python 3.11 or later.
|