easyblock = 'PythonBundle'

name = 'Cartopy'
version = '0.17.0'
versionsuffix = '-Python-%(pyver)s'

homepage = 'https://scitools.org.uk/cartopy/docs/latest/'
description = """Cartopy is a Python package designed for geospatial data processing in order to produce maps 
    and other geospatial data analyses.
    Cartopy makes use of the powerful PROJ.4, NumPy and Shapely libraries and includes a programmatic interface 
    built on top of Matplotlib for the creation of publication quality maps."""

toolchain = {'name': 'foss', 'version': '2019a'}

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

dependencies = [
    ('Python', '3.7.2'),
    ('SciPy-bundle', '2019.03'),
    ('libpng', '1.6.36'),
    ('freetype', '2.9.1'),
    ('Tkinter', '%(pyver)s'),
    ('GEOS', '3.7.2', versionsuffix),
    ('GDAL', '2.4.1', versionsuffix),
    ('UDUNITS', '2.2.26'),
]

use_pip = 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'],
        'checksums': ['cd7b2d1018258d7247a71425e9f26463dfb444d411c39569972f4ce586b0c9d8'],
    }),
    ('kiwisolver', '1.1.0', {
        'source_urls': ['https://pypi.python.org/packages/source/k/kiwisolver'],
        'checksums': ['53eaed412477c836e1b9522c19858a8557d6e595077830146182225613b11a75'],
    }),
    ('matplotlib', '2.2.4', {
        '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/'],
    }),
    ('Shapely', '1.6.4', {
        'modulename': 'shapely',
        'source_urls': ['https://pypi.python.org/packages/source/s/Shapely/'],
    }),
    ('dask', '2.0.0', {
        'source_urls': ['https://pypi.python.org/packages/source/d/dask/'],
    }),
    ('toolz', '0.9.0', {
        'source_urls': ['https://pypi.python.org/packages/source/t/toolz/'],
        'checksums': ['929f0a7ea7f61c178bd951bdae93920515d3fbdbafc8e6caf82d752b9b3b31c9'],
    }),
    ('cftime', '1.0.3.4', {
        'source_urls': ['https://pypi.python.org/packages/source/c/cftime/'],
    }),
    ('antlr4-python3-runtime', '4.7.2', {
        'modulename': 'antlr4',
        'source_urls': ['https://files.pythonhosted.org/packages/source/a/antlr4-python3-runtime/'],
    }),
    ('cf-units', '2.1.1', {
        'source_urls': ['https://pypi.python.org/packages/source/c/cf_units/'],
    }),
    ('PyKE', '1.1.1', {
        'modulename': 'pyke',
        'source_tmpl': 'pyke3-%(version)s.zip',
        'source_urls': ['https://sourceforge.net/projects/%(name)s/files/%(name)s/%(version)s'],
    }),
    ('pyshp', '2.1.0', {
        'modulename': 'shapefile',
        'source_urls': ['https://pypi.python.org/packages/source/p/pyshp/'],
    }),
    (name, version, {
        'prebuildopts': "export D_GLIBCXX_USE_CXX11_ABI=0 && ",
        'preinstallopts': "export D_GLIBCXX_USE_CXX11_ABI=0 && ",
        'source_tmpl': 'v%(version)s.tar.gz',
        'source_urls': ['https://github.com/SciTools/cartopy/archive/'],
        #'patches': ['Cartopy-0.17.0_fix_setup.patch'],
    }),
    ('netCDF4', '1.5.1.2', {
        'modulename': 'netCDF4',
        'source_urls': ['https://pypi.python.org/packages/source/n/netCDF4/'],
    }),
    ('scitools_iris', '2.2.1', {
        'modulename': 'iris',
        'source_tmpl': 'v%(version)s.tar.gz',
        'source_urls': ['https://github.com/SciTools/iris/archive/'],
    }),
]

sanity_check_commands = ["""python -c 'import matplotlib; matplotlib.use("TkAgg"); import matplotlib.pyplot' """]

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

# see https://matplotlib.org/tutorials/introductory/usage.html#what-is-a-backend
modextravars = {'MPLBACKEND': 'TkAgg'}
  
moduleclass = 'vis'
