forked from UW-Hydro/RVIC
-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
117 lines (104 loc) · 3.84 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
#!/usr/bin/env python
import os
import re
import sys
import warnings
try:
from setuptools import setup
from setuptools.extension import Extension
except:
from distutils.core import setup
from distutils.extension import Extension
MAJOR = 1
MINOR = 0
MICRO = 1
ISRELEASED = False
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
QUALIFIER = ''
FULLVERSION = VERSION
write_version = True
# -------------------------------------------------------------------- #
def write_version_py(filename=None):
cnt = """\
version = '%s'
short_version = '%s'
"""
if not filename:
filename = os.path.join(
os.path.dirname(__file__), 'rvic', 'version.py')
a = open(filename, 'w')
try:
a.write(cnt % (FULLVERSION, VERSION))
finally:
a.close()
return
# -------------------------------------------------------------------- #
# -------------------------------------------------------------------- #
# Get version string
if ISRELEASED:
FULLVERSION += QUALIFIER
else:
import subprocess
FULLVERSION += '.dev'
pipe = None
for cmd in ['git', 'git.cmd']:
try:
pipe = subprocess.Popen(
[cmd, "describe", "--always", "--match", "v[0-9]*"],
stdout=subprocess.PIPE)
(so, serr) = pipe.communicate()
if pipe.returncode == 0:
break
except:
pass
if pipe is None or pipe.returncode != 0:
# no git, or not in git dir
if os.path.exists('rvic/version.py'):
warnings.warn("WARNING: Couldn't get git revision, using existing "
"rvic/version.py")
write_version = False
else:
warnings.warn("WARNING: Couldn't get git revision, using generic "
"version string")
else:
# have git, in git dir, but may have used a shallow clone
# (travis does this)
rev = so.strip()
# makes distutils blow up on Python 2.7
if sys.version_info[0] >= 3:
rev = rev.decode('ascii')
if not rev.startswith('v') and re.match("[a-zA-Z0-9]{7,9}", rev):
# partial clone, manually construct version string
# this is the format before we started using git-describe
# to get an ordering on dev version strings.
rev = "v%s.dev-%s" % (VERSION, rev)
# Strip leading v from tags format "vx.y.z" to get th version string
FULLVERSION = rev.lstrip('v')
# -------------------------------------------------------------------- #
# -------------------------------------------------------------------- #
if write_version:
write_version_py()
# -------------------------------------------------------------------- #
# -------------------------------------------------------------------- #
# Run Setup
setup(name='rvic',
version=FULLVERSION,
description='The RVIC Streamflow Routing Model',
long_description='The RVIC streamflow routing model is based on the '
'original model of Lohmann, et al., 1996, Tellus, '
'48(A), 708-721',
author='Joe Hamman',
author_email='[email protected]',
install_requires=['scipy >= 0.13', 'numpy >= 1.8',
'netCDF4 >= 1.0.6', 'matplotlib >= 1.3.1'],
tests_require=['pytest >= 2.5.2'],
url='https://github.com/jhamman/RVIC',
test_suite='pytest.collector',
packages=['rvic', 'rvic.core'],
platform=['any'],
py_modules=['rvic.parameters', 'rvic.convolution', 'rvic.convert'],
scripts=['scripts/rvic', 'tools/find_pour_points.py',
'tools/fraction2domain.bash'],
ext_modules=[Extension('rvic_convolution',
sources=['rvic/clib/rvic_convolution.c'])])
# -------------------------------------------------------------------- #