forked from mturilli/aimes.emanager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.py
179 lines (144 loc) · 6.07 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
#!/usr/bin/env python
__author__ = "Andre Merzky, Matteo Turilli"
__copyright__ = "Copyright 2014, RADICAL"
__email__ = "[email protected]"
__license__ = "MIT"
""" Setup script. Used by easy_install and pip. """
import os
import sys
import subprocess as sp
from setuptools import setup, Command
name = 'aimes.emanager'
mod_root = ''
#-----------------------------------------------------------------------------
#
# 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_root):
"""
mod_root
a VERSION and VERSION.git file containing the version strings is
created in mod_root, 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` 2>/dev/null ; '\
'branch=`git branch | grep -e "^*" | cut -f 2 -d " "` 2>/dev/null ; '\
'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_root)
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_root)
#------------------------------------------------------------------------------
# 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)
#------------------------------------------------------------------------------
class our_test(Command):
user_options = []
def initialize_options (self) : pass
def finalize_options (self) : pass
def run (self) :
testdir = "%s/tests/" % os.path.dirname(os.path.realpath(__file__))
retval = sp.call([sys.executable,
'%s/run_tests.py' % testdir,
'%s/configs/default.cfg' % testdir])
raise SystemExit(retval)
#------------------------------------------------------------------------------
#
def read(*rnames):
try :
return open(os.path.join(os.path.dirname(__file__), *rnames)).read()
except Exception :
return ""
#------------------------------------------------------------------------------
setup_args = {
'name' : 'emanager',
'version' : version,
'description' : 'AIMES execution manager module',
'long_description' : (read('README.rst') + '\n\n' + read('CHANGES.rst')),
'author' : 'Matteo Turilli, Andre Merzky',
'author_email' : '[email protected]',
'maintainer' : 'Matteo Turilli, Andre Merzky',
'maintainer_email' : '[email protected]',
'url' : 'https://bitbucket.org/shantenujha/aimes',
'license' : 'MIT',
'keywords' : 'AIMES execution_manager',
'classifiers' : [
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Science/Research',
'Environment :: Console',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
'Topic :: Internet :: Scientific/Engineering',
'Topic :: System :: Distributed Computing',
'Operating System :: POSIX',
'Operating System :: Unix'
],
'packages' : [
'aimes.emanager'
],
'scripts' : [
'bin/demo_SC2014.sh',
'bin/demo_SC2014_ve_setup.sh',
'bin/demo_SC2014_env_setup.sh',
'bin/demo_SC2014_script.py'
],
'package_data' : {'' : ['etc/*.conf', 'VERSION', 'VERSION.git']},
'data_files' : [
("%s/etc/"% sys.prefix, ['etc/bundle_demo_SC2014.conf']),
("%s/etc/"% sys.prefix, ['etc/skeleton_demo_SC2014.conf'])
],
'cmdclass' : {
'test' : our_test,
},
'install_requires' : [
'radical.pilot'
],
'extras_require' : {
'bundles' : ['aimes.bundle'],
'skeleton' : ['aimes.skeleton']
},
'tests_require' : [],
'zip_safe' : False
}
#------------------------------------------------------------------------------
setup (**setup_args)
#------------------------------------------------------------------------------