How to build DOLFIN 2019.1.0 with petsc4py and slepc4py support?

Hi,

I tried to build Fenics 2019.1.0 with all dependencies (required & optional), including petsc4py and slepc4py on our HPC cluster.

GCC 6.3.0
OpenMPI 3.0.1
OpenBLAS 0.2.20
Python 3.7.4
Boost 1.66.0
Eigen 3.3.4
HDF5 1.10.1
Metis 5.1.0
ParMetis 4.0.3
Petsc 3.9.4
Slepc 3.9.2
Scotch 6.0.4 + ptscotch
Trilinos 12.8.1
GMP 6.1.2
MPFR 4.0.1

Petsc4py and slepc4py are installed as well for Python 3.7.4. Before running CMake, I started the Python interpreter and could import petsc4py and slepc4py successfully. All dependencies were installed from source.

When running CMake, it does not even check for petsc4py and slepc4py, even though the installation directory contains the CMake module files for both:

[sfux@eu-c7-041-01 build]$ ls ../cmake/modules/Find*4py*
../cmake/modules/FindPETSc4py.cmake  ../cmake/modules/FindSLEPc4py.cmake
[sfux@eu-c7-041-01 build]$  

[sfux@eu-c7-041-01 build]$ python
Python 3.7.4 (default, Oct 16 2019, 13:45:57)
[GCC 6.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import petsc4py
>>> import slepc4py
>>> quit()
[sfux@eu-c7-041-01 build]$ cmake ..
-- Boost version: 1.66.0
-- Found the following Boost libraries:
--   timer
--   filesystem
--   program_options
--   iostreams
--   chrono
--   system
--   regex
-- Checking for one of the modules 'craypetsc_real;PETSc'
-- Test PETSC_TEST_RUNS with shared library linking - Success
-- Checking for one of the modules 'crayslepc_real;SLEPc'
-- Test SLEPC_TEST_RUNS with shared library linking - Success
-- ParMETIS could not be found/configured. (missing: PARMETIS_TEST_RUNS PARMETIS_VERSION PARMETIS_VERSION_OK) (Required is at least version "4.0.2")
-- Checking for package 'SCOTCH-PT'
-- Found SCOTCH (version 6)
-- Performing test SCOTCH_TEST_RUNS
-- Performing test SCOTCH_TEST_RUNS - Success
-- Checking for package 'AMD'
-- Checking for package 'UMFPACK'
-- Checking for package 'AMD'
-- Checking for package 'CHOLMOD'
-- Checking for package 'AMD'
-- Found BLAS: /cluster/apps/gcc-6.3.0/openblas-0.2.20-cot3cawsqf4pkxjwzjexaykbwn2ch3ii/lib/libopenblas.so
-- Performing test CHOLMOD_TEST_RUNS - Success
-- Performing test UMFPACK_TEST_RUNS - Success
-- Checking for package 'CHOLMOD'
-- Checking for package 'AMD'
-- Found BLAS: /cluster/apps/gcc-6.3.0/openblas-0.2.20-cot3cawsqf4pkxjwzjexaykbwn2ch3ii/lib/libopenblas.so
-- Performing test CHOLMOD_TEST_RUNS - Success
-- HDF5: Using hdf5 compiler wrapper to determine C configuration
-- Checking for Trilinos
--   Trilinos version 12.8.1 found. Checking for components
--     Tpetra found
--     Zoltan found
--     MueLu found
--     Amesos2 found
--     Ifpack2 found
--     Belos found
--   All necessary Trilinos components found. Trilinos will be enabled.
-- The following features have been enabled:

 * BUILD_SHARED_LIBS, Build DOLFIN with shared libraries.
 * DOLFIN_AUTO_DETECT_MPI, Detect MPI automatically (turn this off to use the MPI compiler wrappers directly via setting CXX, CXX, FC).
 * DOLFIN_WITH_LIBRARY_VERSION, Build with library version information.
 * DOLFIN_ENABLE_DOCS, Enable generation of documentation.
 * CMAKE_INSTALL_RPATH_USE_LINK_PATH, Add paths to linker search and installed rpath.
 * DOLFIN_ENABLE_MPI, Compile with support for MPI.
 * DOLFIN_ENABLE_PETSC, Compile with support for PETSc.
 * DOLFIN_ENABLE_SLEPC, Compile with support for SLEPc.
 * DOLFIN_ENABLE_TRILINOS, Compile with support for Trilinos.
 * DOLFIN_ENABLE_UMFPACK, Compile with support for UMFPACK.
 * DOLFIN_ENABLE_CHOLMOD, Compile with support for CHOLMOD.
 * DOLFIN_ENABLE_SCOTCH, Compile with support for SCOTCH.
 * DOLFIN_ENABLE_PARMETIS, Compile with support for ParMETIS.
 * DOLFIN_ENABLE_ZLIB, Compile with support for zlib.
 * DOLFIN_ENABLE_HDF5, Compile with support for HDF5.

-- The following OPTIONAL packages have been found:

 * MPI, Message Passing Interface (MPI)
   Enables DOLFIN to run in parallel with MPI
 * PETSc (required version >= 3.7), Portable, Extensible Toolkit for Scientific Computation, <https://www.mcs.anl.gov/petsc/>
   Enables the PETSc linear algebra backend
 * SLEPc (required version >= 3.7), Scalable Library for Eigenvalue Problem Computations, <http://slepc.upv.es/>
 * SCOTCH, Programs and libraries for graph, mesh and hypergraph partitioning, <https://www.labri.fr/perso/pelegrin/scotch>
   Enables parallel graph partitioning
 * UMFPACK, Sparse LU factorization library, <http://faculty.cse.tamu.edu/davis/suitesparse.html>
 * BLAS, Basic Linear Algebra Subprograms, <http://netlib.org/blas/>
 * Threads
 * CHOLMOD, Sparse Cholesky factorization library for sparse matrices, <http://faculty.cse.tamu.edu/davis/suitesparse.html>
 * HDF5, Hierarchical Data Format 5 (HDF5), <https://www.hdfgroup.org/HDF5>
 * ZLIB, Compression library, <http://www.zlib.net>

-- The following REQUIRED packages have been found:

 * Boost, Boost C++ libraries, <http://www.boost.org>
 * Eigen3 (required version >= 3.2.90), Lightweight C++ template library for linear algebra, <http://eigen.tuxfamily.org>
 * PythonInterp (required version >= 3), Interactive high-level object-oriented language, <http://www.python.org>
 * UFC (required version >= 2019.1), Unified language for form-compilers (part of FFC), <https://bitbucket.org/fenics-project/ffc>
 * PkgConfig

-- The following features have been disabled:

 * CMAKE_USE_RELATIVE_PATHS, Use relative paths in makefiles and projects.
 * DOLFIN_ENABLE_CODE_COVERAGE, Enable code coverage.
 * DOLFIN_ENABLE_BENCHMARKS, Enable benchmark programs.
 * DOLFIN_SKIP_BUILD_TESTS, Skip build tests for testing usability of dependency packages.
 * DOLFIN_DEPRECATION_ERROR, Turn deprecation warnings into errors.
 * DOLFIN_ENABLE_GEOMETRY_DEBUGGING, Enable geometry debugging.
 * DOLFIN_ENABLE_SUNDIALS, Compile with support for SUNDIALS.

--
-- Generating demo source files from reStructuredText
-- --------------------------------------------------
extract written to /scratch/111062024.tmpdir/dolfin/demo/documented/auto-adaptive-poisson/cpp/main.cpp
extract written to /scratch/111062024.tmpdir/dolfin/demo/documented/biharmonic/cpp/main.cpp
extract written to /scratch/111062024.tmpdir/dolfin/demo/documented/built-in-meshes/cpp/main.cpp
extract written to /scratch/111062024.tmpdir/dolfin/demo/documented/eigenvalue/cpp/main.cpp
extract written to /scratch/111062024.tmpdir/dolfin/demo/documented/hyperelasticity/cpp/main.cpp
extract written to /scratch/111062024.tmpdir/dolfin/demo/documented/mixed-poisson/cpp/main.cpp
extract written to /scratch/111062024.tmpdir/dolfin/demo/documented/nonmatching-interpolation/cpp/main.cpp
extract written to /scratch/111062024.tmpdir/dolfin/demo/documented/poisson/cpp/main.cpp
extract written to /scratch/111062024.tmpdir/dolfin/demo/documented/auto-adaptive-poisson/cpp/AdaptivePoisson.ufl
extract written to /scratch/111062024.tmpdir/dolfin/demo/documented/biharmonic/cpp/Biharmonic.ufl
extract written to /scratch/111062024.tmpdir/dolfin/demo/documented/eigenvalue/cpp/StiffnessMatrix.ufl
extract written to /scratch/111062024.tmpdir/dolfin/demo/documented/hyperelasticity/cpp/HyperElasticity.ufl
extract written to /scratch/111062024.tmpdir/dolfin/demo/documented/mixed-poisson/cpp/MixedPoisson.ufl
extract written to /scratch/111062024.tmpdir/dolfin/demo/documented/nonmatching-interpolation/cpp/P1.ufl
extract written to /scratch/111062024.tmpdir/dolfin/demo/documented/nonmatching-interpolation/cpp/P3.ufl
extract written to /scratch/111062024.tmpdir/dolfin/demo/documented/poisson/cpp/Poisson.ufl
-- Configuring done
-- Generating done
-- Build files have been written to: /scratch/111062024.tmpdir/dolfin/build
[sfux@eu-c7-041-01 build]

I already tried using the ccmake GUI, but I could not find any variable to specify the location of petsc4py or slepc4py. Therefore my question is, how can I build DOLFIN with support for petsc4py and slepc4py ?

When compiling it without specifying anything related to slepc4py and petsc4py, then I get runtime errors like:

RuntimeError: DOLFIN has not been configured with petsc4py. Accessing underlying PETSc object requires petsc4py

Any help is appreciated. In case any additional information is required then I would be happy to provide it.

Best regards

Sam

PETSc4py is found when building the python layer of dolfin. See the dolfin/python/CMakeLists.txt