Skip to content
Snippets Groups Projects
setup.py 2.45 KiB
Newer Older
# This is the install file for pymagglobal.
#
# Copyright (C) 2020 Helmholtz Centre Potsdam GFZ,
#     German Research Centre for Geosciences, Potsdam, Germany
#
# Cite as:
# TODO
#
# This file is part of pymagglobal.
#
# pymagglobal 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.
#
# pymagglobal 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 pymagglobal. If not, see <https://www.gnu.org/licenses/>.

import os
import codecs
from setuptools import setup

cmdclass = dict()
command_options = dict()

try:
    from sphinx.setup_command import BuildDoc
    cmdclass['build_sphinx'] = BuildDoc
except ModuleNotFoundError:


# https://packaging.python.org/guides/single-sourcing-package-version/
def read(rel_path):
    here = os.path.abspath(os.path.dirname(__file__))
    with codecs.open(os.path.join(here, rel_path), 'r') as fp:
        return fp.read()


def get_version(rel_path):
    for line in read(rel_path).splitlines():
        if line.startswith('__version__'):
            delim = '"' if '"' in line else "'"
            return line.split(delim)[1]
    else:
        raise RuntimeError("Unable to find version string.")

name = 'pymagglobal'
version = get_version('pymagglobal/__init__.py')
description = '''python interface for global geomagnetic field models '''
copyright = '2020 Helmholtz Centre Potsdam GFZ, German Research Centre for Geosciences, Potsdam, Germany'
# Override docs/conf.py settings
command_options['build_sphinx'] = {'project': ('dfetup.py', name),
    'release':    ('dfetup.py', version),
    'copyright':  ('dfetup.py', copyright),
    'source_dir': ('dfetup.py', 'docs')}
    name=name,
    version=version,
    author='Maximilian Schanner',
    author_email='arthus@gfz-potsdam.de',
    packages=['pymagglobal'],
    license='GPL v3',
    description=description,
    long_description=description,
    install_requires=[],
    package_data={'pymagglobal': ['dat/*']},
    include_package_data=True,
    cmdclass=cmdclass,
    command_options=command_options,
    test_suite='pymagglobal.tests.test_suite',