1
|
|
|
#!/usr/bin/env python |
2
|
|
|
# -*- encoding: utf-8 -*- |
3
|
|
|
from __future__ import absolute_import, print_function |
4
|
|
|
|
5
|
|
|
import io |
6
|
|
|
import os |
7
|
|
|
import re |
8
|
|
|
from glob import glob |
9
|
|
|
from os.path import basename |
10
|
|
|
from os.path import dirname |
11
|
|
|
from os.path import join |
12
|
|
|
from os.path import splitext |
13
|
|
|
|
14
|
|
|
from setuptools import find_packages |
15
|
|
|
from setuptools import setup |
16
|
|
|
from distutils.core import Extension |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
def read(*names, **kwargs): |
20
|
|
|
return io.open( |
21
|
|
|
join(dirname(__file__), *names), |
22
|
|
|
encoding=kwargs.get('encoding', 'utf8') |
23
|
|
|
).read() |
24
|
|
|
|
25
|
|
|
|
26
|
|
|
def find_meta(meta, *path): |
27
|
|
|
""" |
28
|
|
|
Extract __*meta*__ from *path* (can have multiple components) |
29
|
|
|
""" |
30
|
|
|
meta_file = read(*path) |
31
|
|
|
meta_match = re.search( |
32
|
|
|
r"^__{meta}__ = ['\"]([^'\"]*)['\"]".format(meta=meta), meta_file, re.M |
33
|
|
|
) |
34
|
|
|
if not meta_match: |
35
|
|
|
raise RuntimeError("__{meta}__ string not found.".format(meta=meta)) |
36
|
|
|
return meta_match.group(1) |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
# enable code coverage for C code |
40
|
|
|
# We can't use CFLAGS=-coverage in tox.ini, since that may mess with |
41
|
|
|
# compiling dependencies (e.g. numpy). Therefore we set PY_CCOV=-coverage |
42
|
|
|
# in tox.ini and copy it to CFLAGS here (after deps have been installed) |
43
|
|
|
if 'PY_CCOV' in os.environ.keys(): |
44
|
|
|
os.environ['CFLAGS'] = os.environ['PY_CCOV'] |
45
|
|
|
|
46
|
|
|
name = "aacgm2" |
47
|
|
|
meta_path = os.path.join("src", name, "__init__.py") |
48
|
|
|
version = find_meta("version", meta_path) |
49
|
|
|
long_description = '%s\n%s' % ( |
50
|
|
|
read('README.rst'), |
51
|
|
|
re.sub(':[a-z]+:`~?(.*?)`', r'``\1``', read('CHANGELOG.rst')) |
52
|
|
|
) |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
setup( |
56
|
|
|
name=name, |
57
|
|
|
version=version, |
58
|
|
|
license='MIT', |
59
|
|
|
description='A Python wrapper for AACGM-v2 magnetic coordinates', |
60
|
|
|
long_description=long_description, |
61
|
|
|
long_description_content_type='text/x-rst', |
62
|
|
|
author='Angeline G. Burrell, Christer van der Meeren', |
63
|
|
|
author_email='[email protected]', |
64
|
|
|
maintainer='Stefan Bender', |
65
|
|
|
maintainer_email='[email protected]', |
66
|
|
|
url='https://github.com/st-bender/aacgmv2', |
67
|
|
|
packages=find_packages('src'), |
68
|
|
|
package_dir={'': 'src'}, |
69
|
|
|
py_modules=[splitext(basename(path))[0] for path in glob('src/*.py')], |
70
|
|
|
package_data={'aacgm2': ['aacgm_coeffs/*.asc', 'igrf*coeffs.txt', 'magmodel_*.txt']}, |
71
|
|
|
zip_safe=False, |
72
|
|
|
classifiers=[ |
73
|
|
|
# complete classifier list: http://pypi.python.org/pypi?%3Aaction=list_classifiers |
74
|
|
|
'Development Status :: 5 - Production/Stable', |
75
|
|
|
'Intended Audience :: Science/Research', |
76
|
|
|
'License :: OSI Approved :: MIT License', |
77
|
|
|
'Operating System :: Unix', |
78
|
|
|
'Operating System :: POSIX', |
79
|
|
|
'Operating System :: Microsoft :: Windows', |
80
|
|
|
'Programming Language :: Python', |
81
|
|
|
'Programming Language :: Python :: 2', |
82
|
|
|
'Programming Language :: Python :: 2.7', |
83
|
|
|
'Programming Language :: Python :: 3', |
84
|
|
|
'Programming Language :: Python :: 3.4', |
85
|
|
|
'Programming Language :: Python :: 3.5', |
86
|
|
|
'Programming Language :: Python :: 3.6', |
87
|
|
|
'Programming Language :: Python :: 3.7', |
88
|
|
|
'Programming Language :: Python :: 3.8', |
89
|
|
|
'Programming Language :: Python :: Implementation :: CPython', |
90
|
|
|
'Topic :: Scientific/Engineering :: Physics', |
91
|
|
|
'Topic :: Utilities', |
92
|
|
|
], |
93
|
|
|
keywords=[ |
94
|
|
|
'aacgm', |
95
|
|
|
'aacgm-v2', |
96
|
|
|
'aacgmv2', |
97
|
|
|
'magnetic coordinates', |
98
|
|
|
'altitude adjusted corrected geomagnetic coordinates', |
99
|
|
|
'mlt', |
100
|
|
|
'magnetic local time', |
101
|
|
|
'conversion', |
102
|
|
|
'converting', |
103
|
|
|
], |
104
|
|
|
install_requires=[ |
105
|
|
|
'numpy', |
106
|
|
|
], |
107
|
|
|
ext_modules=[ |
108
|
|
|
Extension('aacgm2._aacgmv2', |
109
|
|
|
sources=['src/aacgm2/aacgmv2module.c', |
110
|
|
|
'src/c_aacgm_v2/aacgmlib_v2.c', |
111
|
|
|
'src/c_aacgm_v2/astalglib.c', |
112
|
|
|
'src/c_aacgm_v2/genmag.c', |
113
|
|
|
'src/c_aacgm_v2/igrflib.c', |
114
|
|
|
'src/c_aacgm_v2/mlt_v2.c', |
115
|
|
|
'src/c_aacgm_v2/rtime.c'], |
116
|
|
|
extra_compile_args=['-D_USE_MATH_DEFINES'], |
117
|
|
|
include_dirs=['src/c_aacgm_v2']) |
118
|
|
|
], |
119
|
|
|
entry_points={ |
120
|
|
|
'console_scripts': [ |
121
|
|
|
'aacgm2 = aacgm2.__main__:main', |
122
|
|
|
] |
123
|
|
|
}, |
124
|
|
|
) |
125
|
|
|
|