-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsetup.py
More file actions
156 lines (121 loc) · 5.15 KB
/
setup.py
File metadata and controls
156 lines (121 loc) · 5.15 KB
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
__author__ = ''
__email__ = ''
__copyright__ = 'Copyright 2013/14, AIMES project'
__license__ = 'MIT'
""" Setup script. Used by easy_install and pip. """
import os
import sys
import subprocess as sp
from setuptools import setup, find_packages
name = 'aimes.skeleton'
mod_root = 'src'
mod_path = 'src/aimes/skeleton'
#-----------------------------------------------------------------------------
#
# versioning mechanism:
#
# - version: 1.2.3 - is used for installation
# - version_detail: v1.2.3-9-g0684b06 - is used for debugging
# - version is read from VERSION file in src root, which is on installation
# copied into the module dir.
# - version_detail is derived from the git tag, and only available when
# installed from git -- this is stored in VERSION.git, in the same
# locations, on install.
# - both files, VERSION and VERSION.git are used to provide the runtime
# version information.
#
def get_version (mod_path):
"""
mod_path
a VERSION and VERSION.git file containing the version strings is created
in mod_path, during installation. Those files are used at runtime to
get the version information.
"""
try:
version = None
version_detail = None
# get version from './VERSION'
src_root = os.path.dirname (__file__)
if not src_root :
src_root = '.'
with open (src_root + '/VERSION', 'r') as f :
version = f.readline ().strip()
# attempt to get version detail information from git
p = sp.Popen ('cd %s ; '\
'tag=`git describe --tags --always` ; '\
'branch=`git branch | grep -e "^*" | cut -f 2 -d " "` ; '\
'echo $tag@$branch' % src_root,
stdout=sp.PIPE, stderr=sp.STDOUT, shell=True)
version_detail = p.communicate()[0].strip()
if p.returncode != 0 or \
version_detail == '@' or \
'fatal' in version_detail :
version_detail = 'v%s' % version
print 'version: %s (%s)' % (version, version_detail)
# make sure the version files exist for the runtime version inspection
path = '%s/%s' % (src_root, mod_path)
print 'creating %s/VERSION' % path
with open (path + '/VERSION', 'w') as f : f.write (version + '\n')
with open (path + '/VERSION.git', 'w') as f : f.write (version_detail + '\n')
return version, version_detail
except Exception as e :
raise RuntimeError ('Could not extract/set version: %s' % e)
#-----------------------------------------------------------------------------
# get version info -- this will create VERSION and srcroot/VERSION
version, version_detail = get_version (mod_path)
#-----------------------------------------------------------------------------
# check python version. we need > 2.6, <3.x
if sys.hexversion < 0x02060000 or sys.hexversion >= 0x03000000:
raise RuntimeError('%s requires Python 2.x (2.6 or higher)' % name)
#-----------------------------------------------------------------------------
#
def read(*rnames):
try :
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
except :
return ''
#-----------------------------------------------------------------------------
setup_args = {
'name' : name,
'version' : version,
'description' : 'A Skeleton Generator',
'long_description' : (read('README.md') + '\n\n' + read('CHANGES.md')),
'author' : '',
'author_email' : '',
'maintainer' : 'Yadu Nand Babuji',
'maintainer_email' : 'yadu@uchicago.edu',
'url' : 'https://github.com/applicationskeleton',
'license' : 'MIT',
'keywords' : '',
'classifiers' : [
'Development Status :: 4 - Beta',
'Intended Audience :: Developers',
'Environment :: Console',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.5',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Topic :: Utilities',
'Topic :: System :: Distributed Computing',
'Operating System :: MacOS :: MacOS X',
'Operating System :: POSIX',
'Operating System :: Unix'
],
'namespace_packages': ['aimes'],
'packages' : find_packages('src'),
'package_dir' : {'': 'src'},
'scripts' : ['bin/aimes-skeleton-generate',
'bin/aimes-skeleton-version',
'bin/aimes-skeleton-synapse.py',
'bin/dax2dot'],
'package_data' : {'': ['*.sh', '*.c', 'VERSION', 'VERSION.git']},
'install_requires' : [],
'tests_require' : [],
'test_suite' : '',
'zip_safe' : False,
}
#-----------------------------------------------------------------------------
setup (**setup_args)
#-----------------------------------------------------------------------------