-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
executable file
·159 lines (142 loc) · 4.08 KB
/
setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
from setuptools import Extension, find_packages, setup
# Test if compiling with cython or using the C source
try:
from Cython.Distutils import build_ext as _build_ext
except ImportError:
from setuptools.command.build_ext import build_ext as _build_ext
ext = '.c'
print('Using GCC')
else:
ext = '.pyx'
print('Using Cython')
def c_name_from_path(location, name):
return os.path.join(location, name).replace('/', '.')
class build_ext(_build_ext):
def finalize_options(self):
_build_ext.finalize_options(self)
# Prevent numpy from thinking it is still in its setup process:
__builtins__.__NUMPY_SETUP__ = False
import numpy
self.include_dirs.append(numpy.get_include())
# Give user option to specify local compiler name
if "CC" not in os.environ:
os.environ["CC"] = "gcc"
print(os.environ["CC"])
# extension parameters
extension_params = dict(
extra_compile_args=['-fopenmp', '-O3'],
extra_link_args=['-fopenmp', '-O3'],
)
ext_modules = []
# detrended kriging
source_folder = 'smrf/spatial/dk'
ext_modules += [
Extension(
c_name_from_path(source_folder, 'detrended_kriging'),
sources=[os.path.join(source_folder, val) for val in [
"detrended_kriging" + ext,
"krige.c",
"lusolv.c",
"array.c"
]],
**extension_params
),
]
# envphys core c functions
source_folder = 'smrf/envphys/core'
ext_modules += [
Extension(
c_name_from_path(source_folder, 'envphys_c'),
sources=[os.path.join(source_folder, val) for val in [
"envphys_c" + ext,
"topotherm.c",
"dewpt.c",
"iwbt.c"
]],
**extension_params
),
]
# wind model c functions
source_folder = 'smrf/utils/wind'
ext_modules += [
Extension(
c_name_from_path(source_folder, 'wind_c'),
sources=[os.path.join(source_folder, val) for val in [
"wind_c" + ext,
"breshen.c",
"calc_wind.c"
]],
**extension_params
),
]
with open('requirements.txt') as requirements_file:
requirements = requirements_file.read()
with open('README_smrf.md') as readme_file:
readme = readme_file.read()
setup(
name='smrf-dev',
description="Distributed snow modeling for water resources",
author="USDA ARS NWRC",
author_email='snow@ars.usda.gov',
url='https://github.com/USDA-ARS-NWRC/smrf',
long_description=readme,
long_description_content_type="text/markdown",
packages=find_packages(include=['smrf', 'smrf.*']),
install_requires=requirements,
python_requires='>=3.6',
include_package_data=True,
package_data={
'smrf': [
'./framework/CoreConfig.ini',
'./framework/.qotw',
'./framework/recipes.ini',
'./framework/changelog.ini'
]
},
license="CC0 1.0",
zip_safe=False,
keywords='smrf',
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'Natural Language :: English',
'License :: CC0 1.0 Universal (CC0 1.0) Public Domain Dedication',
'Programming Language :: Python :: 3',
'Programming Language :: Python :: 3.6',
'Programming Language :: Python :: 3.7',
'Programming Language :: Python :: 3.8',
'Programming Language :: Python :: 3.9'
],
test_suite='smrf.tests',
# tests_require=test_requirements,
cmdclass={
'build_ext': build_ext
},
ext_modules=ext_modules,
scripts=[
'scripts/update_configs',
'scripts/run_smrf',
'scripts/gen_maxus'
],
extras_require={
'docs': [
'Sphinx>=3.0,<=4.0',
'pydata-sphinx-theme',
'sphinxcontrib-bibtex>=1.0',
'sphinxcontrib-websupport>=1.0.1',
],
'tests': [
'mock',
],
},
use_scm_version={
'local_scheme': 'node-and-date',
},
setup_requires=[
'setuptools_scm',
'numpy'
],
)