-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsetup.py
206 lines (165 loc) · 5.98 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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
#!/usr/bin/env python
# credit, where credit due:
# A SIGNIFICANT PART OF THIS FILE IS TAKEN FROM numpy/setup.py
import os
from setuptools import setup, find_packages
from sys import version_info
if version_info.major < 3 and version_info.minor < 3:
raise RuntimeError("PyPinT requires at least Python 3.3.")
import subprocess
import builtins
MAJOR = 0
MINOR = 0
MICRO = 4
ISRELEASED = False
RELEASE_CANDIDATE = None # set to None or 0 if it's not a release candidate
VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO)
if RELEASE_CANDIDATE and RELEASE_CANDIDATE > 0:
VERSION += '-rc%d' % RELEASE_CANDIDATE
def git_version():
"""Taken from numpy/setup.py
"""
def _minimal_ext_cmd(cmd):
# construct minimal environment
env = {}
for k in ['SYSTEMROOT', 'PATH']:
v = os.environ.get(k)
if v is not None:
env[k] = v
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"
try:
out = _minimal_ext_cmd(['git', 'describe', '--abbrev=0'])
git_tag = out.strip().decode('ascii')
except OSError:
git_tag = "Unknown"
if git_tag != "Unknown":
try:
out = _minimal_ext_cmd(['git', 'rev-list', '%s..HEAD' % git_tag, '--count'])
git_commits_since = out.strip().decode('ascii')
except OSError:
git_commits_since = None
else:
git_commits_since = None
try:
out = _minimal_ext_cmd(['git', 'describe'])
git_desc = out.strip().decode('ascii')
except OSError:
git_desc = "Unknown"
return git_revision, git_tag, git_commits_since, git_desc
# BEFORE importing distutils, remove MANIFEST. distutils doesn't properly update it when the contents of directories
# change.
if os.path.exists('MANIFEST'):
os.remove('MANIFEST')
# This is a bit hackish: we are setting a global variable so that the main pypint __init__ can detect if it is being
# loaded by the setup routine, to avoid attempting to load components that aren't built yet. While ugly, it's a lot
# more robust than what was previously being used.
builtins.__PYPINT_SETUP__ = True
def get_version_info():
"""Taken from numpy/setup.py
"""
# Adding the git rev number needs to be done inside write_version_py(), otherwise the import of pypint.version
# messes up the build under Python 3.
fullversion = VERSION
if os.path.exists('.git'):
git_revision, git_tag, git_commits_since, git_desc = git_version()
elif os.path.exists('pypint/version.py'):
# must be a source distribution, use existing version file
try:
from pypint.version import git_revision
from pypint.version import git_tag
from pypint.version import git_commits_since
from pypint.version import git_desc
except ImportError:
raise ImportError("Unable to import git_revision. Try removing pypint/version.py and the build directory "
"before building.")
else:
git_revision = "Unknown"
git_tag = "Unknown"
git_commits_since = None
git_desc = "Unknown"
if not ISRELEASED:
fullversion += '-dev'
if git_commits_since:
fullversion += '-' + git_commits_since
fullversion += '-g' + git_revision[:7]
return fullversion, git_revision, git_tag, git_commits_since, git_desc
def write_version_py(filename='pypint/version.py'):
"""Taken from numpy/setup.py
"""
cnt = """# coding=utf-8
# THIS FILE IS GENERATED FROM PYPINT SETUP.PY
short_version = '%(version)s'
version = '%(version)s'
full_version = '%(full_version)s'
git_revision = '%(git_revision)s'
git_tag = '%(git_tag)s'
git_commits_since = '%(git_commits_since)s'
git_desc = '%(git_desc)s'
release = %(isrelease)s
if not release:
version = full_version
"""
full_version, git_revision, git_tag, git_commits_since, git_desc = get_version_info()
a = open(filename, 'w')
try:
a.write(cnt % {'version': VERSION,
'full_version': full_version,
'git_revision': git_revision,
'git_tag': git_tag,
'git_commits_since': git_commits_since,
'git_desc': git_desc,
'isrelease': str(ISRELEASED)})
finally:
a.close()
# rewrite the pypint/version.py each time
write_version_py()
def read(fname):
return open(os.path.join(os.path.abspath(os.path.dirname(__file__)), fname)).read()
CLASSIFIERS = [
"Development Status :: 2 - Pre-Alpha",
"Environment :: Console",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Operating System :: OS Independent",
"Programming Language :: Python :: 3.3",
"Programming Language :: Python :: 3.4",
"Topic :: Scientific/Engineering :: Mathematics"
]
DEPENDENCIES = [
"numpy>=1.6.1",
"scipy>=0.9.0",
"matplotlib>=1.2.0",
"logbook>=0.6.0",
"configobj>=5.0.2"
]
if version_info.major == 3 and version_info.minor < 4:
DEPENDENCIES.append("enum34")
TEST_DEPENDENCIES = [
"nose>=1.3.1"
]
metadata = {
'name': "PyPinT",
'version': get_version_info()[0],
'packages': find_packages(),
'install_requires': DEPENDENCIES,
'include_package_data': True,
'test_suite': "tests",
'tests_require': TEST_DEPENDENCIES,
'author': "Torbjörn Klatt, Dieter Moser",
'author_email': "[email protected], [email protected]",
'description': "a Python framework for Parallel-in-Time integration routines",
'long_description': read('README.md'),
'license': "MIT",
'url': "https://github.com/torbjoernk/PyPinT",
'classifiers': CLASSIFIERS
}
setup(**metadata)