forked from rubisco-sfa/ILAMB
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.py
111 lines (103 loc) · 3.38 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
#!/usr/bin/env python
from setuptools import setup
from codecs import open
import subprocess
import os
VERSION = '2.5'
def git_version():
"""
Return the sha1 of local git HEAD as a string.
"""
def _minimal_ext_cmd(cmd):
# construct minimal environment
env = {}
for k in ['SYSTEMROOT', 'PATH', 'PYTHONPATH']:
v = os.environ.get(k)
if v is not None:
env[k] = v
# LANGUAGE is used on win32
env['LANGUAGE'] = 'C'
env['LANG'] = 'C'
env['LC_ALL'] = 'C'
out = subprocess.Popen(
cmd,
stdout=subprocess.PIPE,
env=env
).communicate()[0]
return out
try:
out = _minimal_ext_cmd(['git', 'rev-parse', 'HEAD'])
git_revision = out.strip().decode('ascii')
except OSError:
git_revision = "unknown-git"
return git_revision
def write_text(filename, text):
try:
with open(filename, 'w') as a:
a.write(text)
except Exception as e:
print(e)
def write_version_py(filename=os.path.join('src/ILAMB', 'generated_version.py')):
cnt = """
# THIS FILE IS GENERATED FROM ILAMB SETUP.PY
short_version = '%(version)s'
version = '%(version)s'
git_revision = '%(git_revision)s'
full_version = '%(version)s (%%(git_revision)s)' %% {
'git_revision': git_revision}
release = %(isrelease)s
if not release:
version = full_version
"""
FULL_VERSION = VERSION
if os.path.isdir('.git'):
GIT_REVISION = git_version()
ISRELEASED = False
else:
GIT_REVISION = "RELEASE"
ISRELEASED = True
FULL_VERSION += '.dev-' + GIT_REVISION
text = cnt % {'version': VERSION,
'full_version': FULL_VERSION,
'git_revision': GIT_REVISION,
'isrelease': str(ISRELEASED)}
write_text(filename, text)
here = os.path.abspath(os.path.dirname(__file__))
with open(os.path.join(here, 'README.rst'), encoding='utf-8') as f:
long_description = f.read()
write_version_py()
setup(
name='ILAMB',
version=VERSION,
description='The International Land Model Benchmarking Package',
long_description=long_description,
url='https://github.com/rubisco-sfa/ILAMB.git',
author='Nathan Collier',
author_email='[email protected]',
#license='MIT',
classifiers=[
'Development Status :: 5 - Production/Stable',
'Intended Audience :: Science/Research',
'Topic :: Scientific/Engineering',
#'License :: OSI Approved :: MIT License',
'Operating System :: MacOS',
'Operating System :: POSIX',
'Operating System :: POSIX :: Linux',
'Programming Language :: Python :: 3',
],
keywords=['benchmarking','earth system modeling','climate modeling','model intercomparison'],
packages=['ILAMB'],
package_dir={'' : 'src'},
package_data={'ILAMB' : ['data/*.cfg']},
scripts=['bin/ilamb-run','bin/ilamb-fetch','bin/ilamb-mean','bin/ilamb-doctor','bin/ilamb-table',
'bin/ilamb-setup'],
zip_safe=False,
install_requires=['numpy>=1.11.0',
'matplotlib>=2.2',
'cartopy>=0.17.0',
'netCDF4>=1.1.4',
'cf_units>=2.0.0',
'sympy>=0.7.6',
'mpi4py>=1.3.1',
'scipy>=0.9.0']
)