Chaste / PyChaste

A Python Wrapper for Chaste
https://chaste.github.io/pychaste/
Other
1 stars 0 forks source link

Add PyChaste Support for VTK 9 #24

Open kwabenantim opened 11 months ago

kwabenantim commented 11 months ago

Description API changes from VTK 8 to 9: https://vtk.org/Wiki/VTK/API_Changes_8_2_0_to_9_0_0

kwabenantim commented 1 month ago
CMake Error at cmake/Modules/ChasteMacros.cmake:321 (add_library):
  Target "chaste_project_PyChaste" links to target "Freetype::Freetype" but
  the target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?
Call Stack (most recent call first):
  cmake/Modules/ChasteMacros.cmake:411 (Chaste_DO_COMMON)
  projects/PyChaste/CMakeLists.txt:65 (chaste_do_project)

CMake Error at cmake/Modules/ChasteMacros.cmake:321 (add_library):
  Target "chaste_project_PyChaste" links to target "X11::X11" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?
Call Stack (most recent call first):
  cmake/Modules/ChasteMacros.cmake:411 (Chaste_DO_COMMON)
  projects/PyChaste/CMakeLists.txt:65 (chaste_do_project)

CMake Error at cmake/Modules/ChasteMacros.cmake:321 (add_library):
  Target "chaste_project_PyChaste" links to target "GLEW::GLEW" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?
Call Stack (most recent call first):
  cmake/Modules/ChasteMacros.cmake:411 (Chaste_DO_COMMON)
  projects/PyChaste/CMakeLists.txt:65 (chaste_do_project)

CMake Error at cmake/Modules/ChasteMacros.cmake:321 (add_library):
  Target "chaste_project_PyChaste" links to target "X11::X11" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?
Call Stack (most recent call first):
  cmake/Modules/ChasteMacros.cmake:411 (Chaste_DO_COMMON)
  projects/PyChaste/CMakeLists.txt:65 (chaste_do_project)

CMake Error at cmake/Modules/ChasteMacros.cmake:321 (add_library):
  Target "chaste_project_PyChaste" links to target "Python3::Module" but the
  target was not found.  Perhaps a find_package() call is missing for an
  IMPORTED target, or an ALIAS target is missing?
Call Stack (most recent call first):
  cmake/Modules/ChasteMacros.cmake:411 (Chaste_DO_COMMON)
  projects/PyChaste/CMakeLists.txt:65 (chaste_do_project)
kwabenantim commented 1 month ago

Steps to reproduce the CMake configuration errors:

git clone https://github.com/Chaste/Chaste.git

cd Chaste/projects
git clone --recursive https://github.com/PyChaste/PyChaste.git
cd ..

conda create -n vtk9-env
conda activate vtk9-env
mamba install -c conda-forge -c pychaste boost-cpp hdf5="*=*mpi_mpich*" metis mpich parmetis petsc petsc4py sundials vtk=9 tbb-devel xerces-c xsd xvfbwrapper xorg-libxext six notebook

mkdir build
cd build
export PETSC_DIR=$CONDA_PREFIX
export HDF5_ROOT=$CONDA_PREFIX

cmake \
  -DCMAKE_BUILD_TYPE=Release \
  -DPython3_EXECUTABLE=$(which python) \
  -DCMAKE_LIBRARY_PATH="${CONDA_PREFIX}/lib" \
  -DCMAKE_PREFIX_PATH="${CONDA_PREFIX}" \
  -DCMAKE_INSTALL_PREFIX="${CONDA_PREFIX}" \
  -DBUILD_SHARED_LIBS=ON \
  -DBOOST_ROOT="${CONDA_PREFIX}" \
  -DHDF5_C_COMPILER_EXECUTABLE="${CONDA_PREFIX}/bin/h5pcc" \
  -DVTK_DIR=${CONDA_PREFIX} \
  -DXERCESC_INCLUDE="${CONDA_PREFIX}/include" \
  -DXERCESC_LIBRARY="${CONDA_PREFIX}/lib/libxerces-c.so" \
  -DXSD_EXECUTABLE="${CONDA_PREFIX}/bin/xsd" \
  ..
kwabenantim commented 1 month ago

@fcooper8472 suggests investigating fixes like those done in https://github.com/Chaste/Chaste/pull/152/files

kwabenantim commented 1 month ago

There's now a github action testing this: https://github.com/Chaste/PyChaste/actions/runs/9082771049/job/24959931938

kwabenantim commented 1 month ago

CMake errors are from additional VTK components:

RenderingFreeType # needs Freetype::Freetype
RenderingOpenGL2 # needs X11::X11 and GLEW::GLEW
WrappingPythonCore # needs Python3::Module
kwabenantim commented 1 month ago

The errors seem to go away when the extra package modules are searched for directly in Chaste. Possibly subsequent calls to find_package() don't (can't?) add the extra targets correctly?

---find_package(Python3 3.5 )
+++find_package(Python3 3.5 REQUIRED COMPONENTS Interpreter Development)
find_package(
    VTK COMPONENTS CommonCore CommonDataModel FiltersCore FiltersGeneral FiltersGeneric FiltersGeometry
---    FiltersModeling FiltersSources IOCore IOGeometry IOLegacy IOParallelXML IOXML REQUIRED
+++    FiltersModeling FiltersSources IOCore IOGeometry IOLegacy IOParallelXML IOXML
+++    FiltersProgrammable FiltersVerdict InteractionStyle IOImage IOMovie RenderingAnnotation RenderingCore
+++    RenderingFreeType RenderingOpenGL2 WrappingPythonCore  REQUIRED
        )
kwabenantim commented 1 month ago

It still works when find_package() is called twice from Chaste to add extra components. Possibly a scope issue? The targets from the first find_package() call seem to disappear after the second call, however.

kwabenantim commented 4 weeks ago

PyChaste works with VTK9 but needs the cmake find package call to be done above the project scope. This will be done directly in the PyChaste merge into Chaste trunk: https://github.com/Chaste/Chaste/issues/273