1
|
|
|
from codecs import open |
2
|
|
|
from os import path |
3
|
|
|
import re |
4
|
|
|
# Always prefer setuptools over distutils |
5
|
|
|
from setuptools import find_packages, setup |
6
|
|
|
from subprocess import check_call |
7
|
|
|
from distutils.core import Extension |
8
|
|
|
|
9
|
|
|
name = "nrlmsise00" |
10
|
|
|
meta_path = path.join("src", name, "__init__.py") |
11
|
|
|
here = path.abspath(path.dirname(__file__)) |
12
|
|
|
|
13
|
|
|
extnrlmsise00 = Extension( |
14
|
|
|
name="nrlmsise00._nrlmsise00", |
15
|
|
|
sources=[ |
16
|
|
|
"src/nrlmsise00/nrlmsise00module.c", |
17
|
|
|
"src/c_nrlmsise-00/nrlmsise-00.c", |
18
|
|
|
"src/c_nrlmsise-00/nrlmsise-00_data.c" |
19
|
|
|
], |
20
|
|
|
include_dirs=["src/c_nrlmsise-00"]) |
21
|
|
|
|
22
|
|
|
extras_require = { |
23
|
|
|
"tests": ["pytest"], |
24
|
|
|
"dataset": ["xarray"], |
25
|
|
|
} |
26
|
|
|
extras_require["all"] = sorted( |
27
|
|
|
{v for req in extras_require.values() for v in req}) |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
# Approach taken from |
31
|
|
|
# https://packaging.python.org/guides/single-sourcing-package-version/ |
32
|
|
|
# and the `attrs` package https://www.attrs.org/ |
33
|
|
|
# https://github.com/python-attrs/attrs |
34
|
|
|
def read(*parts): |
35
|
|
|
""" |
36
|
|
|
Builds an absolute path from *parts* and and return the contents of the |
37
|
|
|
resulting file. Assumes UTF-8 encoding. |
38
|
|
|
""" |
39
|
|
|
with open(path.join(here, *parts), "rb", "utf-8") as f: |
40
|
|
|
return f.read() |
41
|
|
|
|
42
|
|
|
|
43
|
|
|
def find_meta(meta, *path): |
44
|
|
|
""" |
45
|
|
|
Extract __*meta*__ from *path* (can have multiple components) |
46
|
|
|
""" |
47
|
|
|
meta_file = read(*path) |
48
|
|
|
meta_match = re.search( |
49
|
|
|
r"^__{meta}__ = ['\"]([^'\"]*)['\"]".format(meta=meta), meta_file, re.M |
50
|
|
|
) |
51
|
|
|
if not meta_match: |
52
|
|
|
raise RuntimeError("__{meta}__ string not found.".format(meta=meta)) |
53
|
|
|
return meta_match.group(1) |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
# Get the long description from the README file |
57
|
|
|
long_description = read("README.md") |
58
|
|
|
version = find_meta("version", meta_path) |
59
|
|
|
|
60
|
|
|
if __name__ == "__main__": |
61
|
|
|
# update git submodules |
62
|
|
|
if path.exists(".git"): |
63
|
|
|
check_call(["git", "submodule", "update", "--init", "--recursive"]) |
64
|
|
|
|
65
|
|
|
setup(name=name, |
66
|
|
|
version=version, |
67
|
|
|
description="Python interface for the NRLMSISE-00 neutral atmosphere model", |
68
|
|
|
long_description=long_description, |
69
|
|
|
long_description_content_type="text/markdown", |
70
|
|
|
url="http://github.com/st-bender/pynrlmsise00", |
71
|
|
|
author="Stefan Bender", |
72
|
|
|
author_email="[email protected]", |
73
|
|
|
license="GPLv2", |
74
|
|
|
classifiers=[ |
75
|
|
|
"Development Status :: 3 - Alpha", |
76
|
|
|
"Intended Audience :: Science/Research", |
77
|
|
|
"License :: OSI Approved :: GNU General Public License v2 (GPLv2)", |
78
|
|
|
"Programming Language :: Python", |
79
|
|
|
"Programming Language :: Python :: 2", |
80
|
|
|
"Programming Language :: Python :: 3", |
81
|
|
|
'Programming Language :: Python :: Implementation :: CPython', |
82
|
|
|
'Topic :: Scientific/Engineering :: Physics', |
83
|
|
|
'Topic :: Utilities', |
84
|
|
|
], |
85
|
|
|
packages=find_packages("src"), |
86
|
|
|
package_dir={"": "src"}, |
87
|
|
|
package_data={}, |
88
|
|
|
install_requires=[ |
89
|
|
|
"numpy>=1.13.0", |
90
|
|
|
], |
91
|
|
|
extras_require=extras_require, |
92
|
|
|
ext_modules=[extnrlmsise00], |
93
|
|
|
scripts=[], |
94
|
|
|
entry_points={}, |
95
|
|
|
zip_safe=False) |
96
|
|
|
|