# JH 2020

##
# This file is an EasyBuild reciPY as per https://github.com/easybuilders/easybuild
#
# Copyright:: Copyright 2012-2014 Uni.Lu/LCSB, NTUA
# Authors::   Fotis Georgatos <fotis@cern.ch>
# License::   MIT/GPL
# $Id$
#
# This work implements a part of the HPCBIOS project and is a component of the policy:
# http://hpcbios.readthedocs.org/en/latest/HPCBIOS_2012-97.html
##

easyblock = 'CMakeMake'

name = 'VTK'
version = '8.1.0'
versionsuffix = '-Python-%(pyver)s'

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': 'foss', 'version': '2018a'}
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 = [
    '6e269f07b64fb13774f5925161fb4e1f379f4e6a0131c8408c555f6b58ef3cb7',  # VTK-8.1.0.tar.gz
    '320562de621a93bc173e6823968353f5ee2cbeac8623093a6057d76cb4315d05',  # VTKData-8.1.0.tar.gz
]


#https://www.paraview.org/pipermail/paraview-developers/2017-March/005199.html
patches = ["VTK-8.1.0-foss-2018a-Python-3.6.6.patch"]

builddependencies = [('CMake', '3.11.4')]

dependencies = [
    ('Python', '3.6.6'),
    ('HDF5', '1.10.4', '-parallel'),
    ('Mesa', '18.3.1', '', True), # Don't use new MESA, libGL is missing!
    ('libGLU', '9.0.0', '', True),
]

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 "
configopts += "-DVTK_PYTHON_VERSION=%(pyshortver)s "
configopts += "-DPYTHON_INCLUDE_DIR=$EBROOTPYTHON/include/python%(pyshortver)sm "
configopts += "-DPYTHON_LIBRARY=$EBROOTPYTHON/lib/libpython%%(pyshortver)sm.%s " % SHLIB_EXT
configopts += "-DVTK_Group_MPI:BOOL=ON "
configopts += "-DVTK_WRAP_PYTHON=ON "
preinstallopts = "mkdir -p %(installdir)s/lib/python%(pyshortver)s/site-packages/ && "
preinstallopts += "export PYTHONPATH=%(installdir)s/lib/python%(pyshortver)s/site-packages:$PYTHONPATH && "

modextrapaths = {'PYTHONPATH': ['lib/python%(pyshortver)s/site-packages']}

sanity_check_paths = {
    'files': ['bin/vtk%s-%%(version_major_minor)s' % x for x in ['EncodeString', 'HashSource']],
    'dirs': ['lib/python%(pyshortver)s/site-packages/', 'include/vtk-%(version_major_minor)s'],
}

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

moduleclass = 'vis'
