forked from inasafe/inasafe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
78 lines (65 loc) · 2.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
# coding=utf-8
"""Setup file for distutils / pypi."""
try:
from ez_setup import use_setuptools
use_setuptools()
except ImportError:
pass
import os
from setuptools import setup, find_packages
def get_version(version=None):
"""Returns a PEP 386-compliant version number from VERSION.
:param version: A tuple that represent a version.
:type version: tuple
:returns: a PEP 386-compliant version number.
:rtype: str
"""
if version is None:
# Get location of application wide version info
root_dir = os.path.abspath(os.path.join(
os.path.dirname(__file__)))
fid = open(os.path.join(root_dir, 'metadata.txt'))
version_list = []
status = ''
for line in fid.readlines():
if line.startswith('version'):
version_string = line.strip().split('=')[1]
version_list = version_string.split('.')
if line.startswith('status'):
status = line.strip().split('=')[1]
fid.close()
version = tuple(version_list + [status] + ['0'])
if len(version) != 5:
msg = 'Version must be a tuple of length 5. I got %s' % (version,)
raise RuntimeError(msg)
if version[3] not in ('alpha', 'beta', 'rc', 'final'):
msg = 'Version tuple not as expected. I got %s' % (version,)
raise RuntimeError(msg)
# Now build the two parts of the version number:
# main = X.Y[.Z]
# sub = .devN - for pre-alpha releases
# | {a|b|c}N - for alpha, beta and rc releases
parts = 2 if version[2] == 0 else 3
main = '.'.join(str(x) for x in version[:parts])
return main
setup(
name='inasafe-core',
version=get_version(),
packages=find_packages(include=['safe', 'safe.*']),
include_package_data=True,
license='GPL',
author='InaSAFE Team',
author_email='info@inasafe.org',
url='http://inasafe.org/',
description=('Realistic natural hazard impact scenarios for better '
'planning, preparedness and response activities.'),
classifiers=[
'Development Status :: 5 - Stable',
'Intended Audience :: Developers',
'Intended Audience :: Science/Research',
'License :: OSI Approved :: GPL V3 License',
'Operating System :: OS Independent',
'Programming Language :: Python',
'Topic :: Scientific/Engineering :: GIS',
],
)