# JH 2020

easyblock = 'CMakeMake'

name = 'ParaView'
version = '5.8.0'
versionsuffix = '-Python-%(pyver)s-mpi'

homepage = "https://www.paraview.org"
description = "ParaView is a scientific parallel visualizer."

toolchain = {'name': 'intel', 'version': '2019a'}
toolchainopts = {'pic': True, 'usempi': True}

local_download_suffix = 'download.php?submit=Download&version=v%(version_major_minor)s&type=source&os=all&downloadFile='
source_urls = ['https://www.paraview.org/paraview-downloads/%s' % local_download_suffix]
sources = ["ParaView-v%(version)s.tar.xz"]
checksums = ['219e4107abf40317ce054408e9c3b22fb935d464238c1c00c0161f1c8697a3f9']

dependencies = [
    ('Python', '3.7.2'),
    ('SciPy-bundle', '2019.03'),
    ('XZ', '5.2.4'),
    ('HDF5', '1.10.5'),
    ('netCDF', '4.6.2'),
    ('libGLU', '9.0.0'),
    ('X11', '20190311'),
    ('Mesa', '19.0.1'),
    ('Qt5', '5.12.3'),
    ('zlib', '1.2.11'),
    ('FFmpeg', '4.1.3'),
    ('Szip', '2.1.1'),
]

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

separate_build_dir = True

# Paraview
configopts = '-DPARAVIEW_INSTALL_DEVELOPMENT_FILES=ON -DPARAVIEW_BUILD_SHARED_LIBS=ON '
configopts += '-DPARAVIEW_USE_MPI=ON '
configopts += '-DPARAVIEW_ENABLE_FFMPEG=ON '
configopts += '-DPARAVIEW_USE_PYTHON=ON '
configopts += '-DPython3_ROOT_DIR=$EBROOTPYTHON '

# There is a problem with intel compiler. It seems that -ipo triggers some bug, which results in a
# messages like 'icpc: error #10014: problem during multi-file optimization compilation (code 4)'.
# Thus, -no-ipo is set.
configopts += '-DCMAKE_CXX_FLAGS_RELEASE="$CXXFLAGS -DNDEBUG -no-ipo" '

# OpenGL & Mesa
configopts += '-DOPENGL_glu_LIBRARY=$EBROOTLIBGLU/lib/libGLU.%s ' % SHLIB_EXT
configopts += '-DOPENGL_INCLUDE_DIR=$EBROOTMESA/include'
configopts += '-DVTK_OPENGL_HAS_OSMESA=ON '

sanity_check_paths = {
    'files': ['bin/paraview', 'bin/pvpython'],
    'dirs': ['include/paraview-%(version_major_minor)s', 'lib/python%(pyshortver)s/site-packages'],
}

sanity_check_commands = ['python -c "import paraview"']

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

moduleclass = 'vis'
