easyblock = 'PythonBundle'

name = 'matplotlib'
version = '3.3.3'
versionsuffix = '-Python-%(pyver)s'

homepage = 'https://matplotlib.org'
description = """matplotlib is a python 2D plotting library which produces publication quality figures in a variety of
 hardcopy formats and interactive environments across platforms. matplotlib can be used in python scripts, the python
 and ipython shell, web application servers, and six graphical user interface toolkits."""

toolchain = {'name': 'foss', 'version': '2020b'}

builddependencies = [
    ('pkg-config', '0.29.2'),
]

dependencies = [
    ('Python', '3.8.6'),
    ('libjpeg-turbo', '2.0.5'),
    ('SciPy-bundle', '2020.11'),
    ('libpng', '1.6.37'),
    ('zlib', '1.2.11'),
    ('LibTIFF', '4.1.0'),
    ('freetype', '2.10.3'),
    ('Tkinter', '%(pyver)s'),
    ('Pillow', '8.0.1', versionsuffix),
]

use_pip = True
sanity_pip_check = True

exts_list = [
    ('Cycler', '0.10.0', {
        'modulename': 'cycler',
        'source_tmpl': 'cycler-%(version)s.tar.gz',
        'source_urls': ['https://pypi.python.org/packages/source/C/Cycler'],
    }),
    ('kiwisolver', '1.1.0', {
        'source_urls': ['https://pypi.python.org/packages/source/k/kiwisolver'],
    }),
    (name, version, {
        'prebuildopts': "export CPLUS_INCLUDE_PATH=$EBROOTFREETYPE/include/freetype2:${CPLUS_INCLUDE_PATH} && ",
        'preinstallopts': "export CPLUS_INCLUDE_PATH=$EBROOTFREETYPE/include/freetype2:${CPLUS_INCLUDE_PATH} && ",
        'source_urls': ['https://pypi.python.org/packages/source/m/matplotlib'],
    }),
]

postinstallcmds = [
    "cd %(installdir)s && " +
    'python3 -m pip install --upgrade Pillow '
]

sanity_check_commands = [
    """python -c 'import matplotlib; matplotlib.use("Agg"); import matplotlib.pyplot' """,
    "python -c 'from mpl_toolkits.mplot3d import Axes3D'",
]

# use non-interactive plotting backend as default
# see https://matplotlib.org/tutorials/introductory/usage.html#what-is-a-backend
modextravars = {'MPLBACKEND': 'Agg'}

moduleclass = 'vis'
