# IT4Innovations 2019

easyblock = 'CMakeMake'

name = 'VTK'
version = '8.2.0'
versionsuffix = '-Py-2.7'

homepage = 'http://www.vtk.org'
description = """The Visualization Toolkit (VTK) is an open-source, freely available software system for
 3D computer graphics, image processing and visualization. VTK consists of a C++ class library and several
 interpreted interface layers including Tcl/Tk, Java, and Python. VTK supports a wide variety of visualization
 algorithms including: scalar, vector, tensor, texture, and volumetric methods; and advanced modeling techniques
 such as: implicit modeling, polygon reduction, mesh smoothing, cutting, contouring, and Delaunay triangulation."""

toolchain = {'name': 'intel', 'version': '2017c'}
toolchainopts = {'usempi': True}

source_urls = ['https://www.vtk.org/files/release/%(version_major_minor)s']
sources = [
    SOURCE_TAR_GZ,
    '%(name)sData-%(version)s.tar.gz',
]
checksums = [
    '34c3dc775261be5e45a8049155f7228b6bd668106c72a3c435d95730d17d57bb',  # VTK-8.2.0.tar.gz
    'd1ff312f7a63d90d8b7033a99109801f16a462ae411d648642838aae04bcc21e',  # VTKData-8.2.0.tar.gz
]

builddependencies = [('CMake', '3.14.1', '', True)]

dependencies = [
    ('Py', '2.7', '', True),
    ('XZ', '5.2.4', '', True),
    ('HDF5', '1.10.5'),
    ('netCDF', '4.6.2'),
    ('libGLU', '9.0.0', '', True),
    ('X11', '20190311', '', True),
    ('pandas', '0.23.4', '-Py-2.7', True),
    ('numpy', '1.16.3', '-Py-2.7', True),
    ('scipy', '1.2.1', '-Py-2.7', True),
    ('mpi4py', '3.0.0', '-Py-2.7'),
]

separate_build_dir = True

# Third party modules
configopts = "-DVTK_USE_SYSTEM_MPI4PY=ON "
configopts += "-DVTK_USE_SYSTEM_LZMA=ON "
configopts += "-DVTK_USE_SYSTEM_HDF5=ON "
configopts += "-DVTK_USE_SYSTEM_NETCDF=ON "
# OpenGL
configopts += "-DOPENGL_glu_LIBRARY=$EBROOTLIBGLU/lib/libGLU.%s " % SHLIB_EXT
configopts += "-DOPENGL_gl_LIBRARY=$EBROOTMESA/lib/libGL.%s " % SHLIB_EXT
configopts += "-DOPENGL_INCLUDE_DIR=$EBROOTMESA/include "
# Python
configopts += "-DVTK_WRAP_PYTHON=ON "
configopts += "-DVTK_PYTHON_VERSION=2.7 "
configopts += "-DPYTHON_INCLUDE_DIR=$EBROOTPYTHON/include/python2.7 "
configopts += "-DPYTHON_LIBRARY=$EBROOTPYTHON/lib/libpython2.7.%s " % SHLIB_EXT
# Other
configopts += "-DVTK_Group_MPI:BOOL=ON "
configopts += "-DCMAKE_INSTALL_LIBDIR=lib"

preinstallopts = "export PYTHONPATH=%(installdir)s/lib/python2.7/site-packages:$PYTHONPATH && "

modextrapaths = {'PYTHONPATH': ['lib/python2.7/site-packages']}

sanity_check_paths = {
    'files': ['bin/vtk%s-%%(version_major_minor)s' % x for x in
              ['WrapJava', 'ParseJava', 'WrapPythonInit', 'WrapPython', 'WrapHierarchy']] +
             ['bin/pvtkpython', 'bin/vtkpython'],
    'dirs': ['lib/python2.7/site-packages/', 'include/vtk-%(version_major_minor)s'],
}

sanity_check_commands = [('python', "-c 'import %(namelower)s'")]

moduleclass = 'vis'
