#!/usr/bin/env python

# Copyright 2018 Earth Sciences Department, BSC-CNS
#
# This file is part of HERMESv3_GR.
#
# HERMESv3_GR is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# HERMESv3_GR is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with HERMESv3_GR. If not, see <http://www.gnu.org/licenses/>.

import os
import sys
import subprocess
from setuptools import find_packages
from setuptools import setup
from hermesv3_gr import __version__


# Get the version number from the relevant file
version = __version__

with open("README.md", "r") as f:
    long_description = f.read()

# # Determine the path to the NES setup.py
# nes_setup_path = os.path.join(os.path.dirname(__file__), "hermesv3_gr", "sources", "NES")
# if not os.path.exists(nes_setup_path):
#     raise RuntimeError("Submodules where not cloned. Try to clone them using `git clone --recurse-submodules <URL>`" +
#                        "or `git submodule update --init --recursive` if it already cloned")
#
# # Install the NES submodule using pip
# subprocess.check_call([sys.executable, "-m", "pip", "install", nes_setup_path])
# # subprocess.check_call([sys.executable, "-m", "pip", "install", "-e", nes_setup_path])

setup(
    name='hermesv3_gr',
    license='GNU GPL v3',
    # platforms=['GNU/Linux Debian'],
    version=version,
    description='HERMESv3 Global/Regional',
    long_description=long_description,
    long_description_content_type="text/markdown",
    author='Carles Tena Medina',
    author_email='carles.tena@bsc.es',
    url='https://earth.bsc.es/gitlab/es/hermesv3_gr',

    keywords=['emissions', 'emission model', 'top-down', 'cmaq', 'monarch', 'wrf-chem', 'atmospheric composition',
              'air quality', 'earth science'],
    install_requires=[
        'numpy',
        'netCDF4>=1.3.1',
        'pandas',
        'fiona',
        'Rtree',
        'geopandas',
        'pyproj',
        'configargparse',
        'eccodes-python',
        'holidays',
        'pytz',
        'mpi4py',
    ],
    packages=find_packages(),
    classifiers=[
        "Programming Language :: Python :: 3.7",
        "License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
        "Operating System :: OS Independent",
        "Topic :: Scientific/Engineering :: Atmospheric Science"
    ],
    package_data={'': [
        'README.md',
        'CHANGELOG.md',
        'LICENSE',
    ]
    },
    data_files=[('.', ['LICENSE', 'CHANGELOG.md', ]),
                ('conf', ['conf/hermes.conf',
                          'conf/EI_configuration.csv', ]),
                ('data', ['data/global_attributes.csv', ]),
                ('data/profiles', []),
                ('data/profiles/speciation', [
                          'data/profiles/speciation/MolecularWeights.csv',
                          'data/profiles/speciation/Speciation_profile_cb05_aero5_Benchmark.csv',
                          'data/profiles/speciation/Speciation_profile_cb05_aero5_CMAQ.csv',
                          'data/profiles/speciation/Speciation_profile_cb05_aero5_MONARCH.csv',
                          'data/profiles/speciation/Speciation_profile_cb05_aero6_CMAQ.csv',
                          'data/profiles/speciation/Speciation_profile_cb05e51_aero6_CMAQ.csv',
                          'data/profiles/speciation/Speciation_profile_radm2_madesorgam_WRF_CHEM.csv', ]),
                ('data/profiles/temporal', [
                          'data/profiles/temporal/TemporalProfile_Daily.csv',
                          'data/profiles/temporal/TemporalProfile_Weekly.csv',
                          'data/profiles/temporal/TemporalProfile_Hourly.csv', 
                          'data/profiles/temporal/TemporalProfile_Monthly.csv',
                          'data/profiles/temporal/tz_world_country_iso3166.csv', ]),
                ('data/profiles/vertical', [
                          'data/profiles/vertical/Benchmark_15layers_vertical_description.csv',
                          'data/profiles/vertical/Vertical_profile.csv', ]),
                ('preproc', ['preproc/ceds_preproc.py',
                             'preproc/eclipsev5a_preproc.py',
                             'preproc/edgarv432_ap_preproc.py',
                             'preproc/edgarv432_voc_preproc.py',
                             'preproc/emep_preproc.py',
                             'preproc/gfas12_preproc.py',
                             'preproc/GFAS_Parameters.csv',
                             'preproc/htapv2_preproc.py',
                             'preproc/tno_mac_iii_preproc.py',
                             'preproc/tno_mac_iii_preproc_voc_ratios.py',
                             'preproc/VOC_split_AIR.csv',
                             'preproc/VOC_split_SHIP.csv',
                             'preproc/wiedinmyer_preproc.py', ]),
                ('preproc/nmvoc', [
                    'preproc/nmvoc/ratio_voc01.nc',
                    'preproc/nmvoc/ratio_voc02.nc',
                    'preproc/nmvoc/ratio_voc03.nc',
                    'preproc/nmvoc/ratio_voc04.nc',
                    'preproc/nmvoc/ratio_voc05.nc',
                    'preproc/nmvoc/ratio_voc06.nc',
                    'preproc/nmvoc/ratio_voc07.nc',
                    'preproc/nmvoc/ratio_voc08.nc',
                    'preproc/nmvoc/ratio_voc09.nc',
                    'preproc/nmvoc/ratio_voc12.nc',
                    'preproc/nmvoc/ratio_voc13.nc',
                    'preproc/nmvoc/ratio_voc14.nc',
                    'preproc/nmvoc/ratio_voc15.nc',
                    'preproc/nmvoc/ratio_voc16.nc',
                    'preproc/nmvoc/ratio_voc17.nc',
                    'preproc/nmvoc/ratio_voc18.nc',
                    'preproc/nmvoc/ratio_voc19.nc',
                    'preproc/nmvoc/ratio_voc20.nc',
                    'preproc/nmvoc/ratio_voc21.nc',
                    'preproc/nmvoc/ratio_voc22.nc',
                    'preproc/nmvoc/ratio_voc23.nc',
                    'preproc/nmvoc/ratio_voc24.nc',
                    'preproc/nmvoc/ratio_voc25.nc', ]),
                ],

    include_package_data=True,

    entry_points={
        'console_scripts': [
            'hermes_gr = hermesv3_gr.hermes:run',
            'hermes_gr_copy_config_files = hermesv3_gr.tools.sample_files:copy_config_files',
            'hermes_gr_copy_preproc_files = hermesv3_gr.tools.sample_files:copy_preproc_files',
            'hermes_gr_download_benchmark = hermesv3_gr.tools.download_benchmark:download_benchmark',
        ],
    },
)
