Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathsetup.py
More file actions
Latest commit
executable file
·206 lines (169 loc) · 6.25 KB
/
Copy pathsetup.py
File metadata and controls
executable file
·206 lines (169 loc) · 6.25 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
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
"""
The test and clean code is shamelessly stolen from
http://da44en.wordpress.com/2002/11/22/using-distutils/
"""
from __future__ importprint_function
importos
importtime
importlogging
fromdistutils.coreimportCommand, setup
fromdistutilsimportlog
fromdistutils.fancy_getoptimportfancy_getopt
fromunittestimportTextTestRunner, TestLoader
fromglobimportglob
fromos.pathimportsplitext, basename, joinaspjoin
importsetuptools
fromdistutils.coreimportsetup
fromintermineimportVERSION
OPTIONS= {
'name': "intermine",
'packages': ["intermine", "intermine.lists"],
'provides': ["intermine"],
'version': VERSION,
'description': "InterMine WebService client",
'author': "InterMine team",
'author_email': "all@intermine.org",
'url': "http://www.intermine.org",
'keywords': ["webservice", "genomic", "bioinformatics"],
'classifiers': [
"Programming Language :: Python :: 2.7",
"Programming Language :: Python :: 3",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Science/Research",
"Intended Audience :: Developers",
"License :: OSI Approved :: GNU Library or "
"Lesser General Public License (LGPL)",
"License :: OSI Approved :: BSD License",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Internet :: WWW/HTTP",
"Topic :: Scientific/Engineering :: Bio-Informatics",
"Topic :: Scientific/Engineering :: Information Analysis",
"Operating System :: OS Independent",
],
'license': "LGPL, BSD",
'long_description': """\
InterMine Webservice Client
----------------------------
A Python API to access bioinformatics
data warehouses powered by the InterMine platform.
"""
}
classTestCommand(Command):
description="Run unit tests"
user_options= [
('verbose', 'v', "produce verbose output"),
('testmodule=', 't', 'test module name')
]
boolean_options= ['verbose']
definitialize_options(self):
self._dir=os.getcwd()
self.test_prefix='test_'
self.verbose=0
self.testmodule=None
deffinalize_options(self):
pass
defrun(self):
'''
Finds all the tests modules in tests/, and runs them,
exiting after they are all done
'''
fromtests.serverimportTestServer
fromtests.test_coreimportWebserviceTest
log.set_verbosity(self.verbose)
ifself.verbose>=2:
self.announce('Setting log level to DEBUG ({0})'.format(
logging.DEBUG), level=2)
logging.basicConfig(level=logging.DEBUG)
testfiles= []
ifself.testmoduleisNone:
fortinglob(pjoin(self._dir, 'tests',
self.test_prefix+'*.py')):
ifnott.endswith('__init__.py'):
testfiles.append(
'.'.join(['tests', splitext(basename(t))[0]]))
else:
testfiles.append(self.testmodule)
server=TestServer(daemonise=True, silent=(self.verbose<3))
server.start()
WebserviceTest.TEST_PORT=server.port
self.announce("Waiting for test server to start on port "+
str(server.port), level=2)
time.sleep(1)
self.announce("Test files:"+str(testfiles), level=2)
tests=TestLoader().loadTestsFromNames(testfiles)
t=TextTestRunner(verbosity=self.verbose)
result=t.run(tests)
failed, errored=map(len, (result.failures, result.errors))
exit(failed+errored)
classPrintVersion(Command):
user_options= []
definitialize_options(self):
self.version=None
deffinalize_options(self):
self.version=OPTIONS['version']
defrun(self):
print(self.version)
classLiveTestCommand(TestCommand):
definitialize_options(self):
TestCommand.initialize_options(self)
self.test_prefix='live'
classCleanCommand(Command):
"""
Remove all build files and all compiled files
=============================================
Remove everything from build, including that
directory, and all .pyc files
"""
user_options= [('verbose', 'v', "produce verbose output")]
definitialize_options(self):
self._files_to_delete= []
self._dirs_to_delete= []
forroot, dirs, filesinos.walk('.'):
forfinfiles:
iff.endswith('.pyc'):
self._files_to_delete.append(pjoin(root, f))
forroot, dirs, filesinos.walk(pjoin('build')):
forfinfiles:
self._files_to_delete.append(pjoin(root, f))
fordindirs:
self._dirs_to_delete.append(pjoin(root, d))
# reverse dir list to only get empty dirs
self._dirs_to_delete.reverse()
self._dirs_to_delete.append('build')
self.verbose=0
deffinalize_options(self):
fancy_getopt(self.user_options, {}, self, None)
defrun(self):
forclean_meinself._files_to_delete:
ifself.dry_run:
log.info("Would have unlinked "+clean_me)
else:
try:
self.announce("Deleting "+clean_me, level=2)
os.unlink(clean_me)
exceptException:
message=" ".join(["Failed to delete file", clean_me])
log.warn(message)
forclean_meinself._dirs_to_delete:
ifself.dry_run:
log.info("Would have rmdir'ed "+clean_me)
else:
ifos.path.exists(clean_me):
try:
self.announce("Going to remove "+clean_me, level=2)
os.rmdir(clean_me)
exceptException:
message=" ".join(["Failed to delete dir", clean_me])
log.warn(message)
elifclean_me!="build":
log.warn(clean_me+" does not exist")
extra= {
'cmdclass': {
'clean': CleanCommand,
'test': TestCommand,
'livetest': LiveTestCommand,
'version': PrintVersion
}
}
OPTIONS.update(extra)
setup(**OPTIONS)