I tried troubleshooting. I realised that the DOLFIN Python component needs to be built separately to link with the DOLFIN C++ libraries.
I got it working now using a “hybrid” approach:
-
Install FEniCS 2019.1.0 using Ubuntu PPA
(see: https://fenics.readthedocs.io/en/latest/installation.html#ubuntu-ppa) -
Install
fenics
Python-only components in Slicer usingpip
:{MY_SLICER_DIR}/bin/PythonSlicer -m pip install fenics
-
Download and install Python header files in Slicer:
wget -P ${MY_SLICER_DIR}/lib/Python/include/python3.6m/ https://github.com/python/cpython/archive/v3.6.7.tar.gz cd ${MY_SLICER_DIR}/lib/Python/include/python3.6m/ tar --strip-components=2 -zxf v3.6.7.tar.gz cpython-3.6.7/Include
-
Install Python interface of DOLFIN:
${MY_SLICER_DIR}/bin/PythonSlicer -m pip install ${MY_FENICS_SRC}/dolfin/python
Step 3 was suggested by @jcfr when I was developing Slicer FEniCS in Boston. Maybe it would be worthwhile to include these headers within the Slicer distribution. It is the only complicated step in the installation process here.